From patchwork Mon Jun 14 13:12:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1491665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=WqC/3XcF; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=GV5Ua37M; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G3X336Wvpz9sW7 for ; Mon, 14 Jun 2021 23:14:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35A723893C67 for ; Mon, 14 Jun 2021 13:14:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 27B803890407 for ; Mon, 14 Jun 2021 13:12:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 27B803890407 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D75A61FD29 for ; Mon, 14 Jun 2021 13:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623676324; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=sLdzPLtXTXvKJS9tuOeXmHkNwyDnPDPCKHzLvEO5JVc=; b=WqC/3XcFzJog4g0NMBuTDViReY1eVOXAnt2zsPNdIVwCLIwyLgRYPRwRJC91+RtjjDaJDP tk+DbebSaf4uugt3fl6VlqpkztpGzXjF+2RH2zkE47Lpxec47eK09cZgVCNK2dHyYN+1gy 12EjRGyuvRgyy6FD6hpBgArIfgdvM/8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623676324; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=sLdzPLtXTXvKJS9tuOeXmHkNwyDnPDPCKHzLvEO5JVc=; b=GV5Ua37MrkQiXBbJmquJtF8kzkpqG3c6sgmfJBEou2wzVQzXHlAdJ1a9YffwcGKlvmnCyZ +gTkrSl9wkhtFiAQ== Received: from [10.163.41.62] (unknown [10.163.41.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C6FC7A3BB7 for ; Mon, 14 Jun 2021 13:12:04 +0000 (UTC) Date: Mon, 14 Jun 2021 15:12:04 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/100934 - properly mark irreducible regions for DOM Message-ID: MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The jump threading code requires marked irreducible regions for the purpose of validating jump threading paths but DOM fails to provide that resulting in mised number of iteration upper bounds clearing. Bootstrap / regtest running on x86_64-unknown-linux-gnu. 2021-06-14 Richard Biener PR tree-optimization/100934 * tree-ssa-dom.c (pass_dominator::execute): Properly mark irreducible regions. * gcc.dg/torture/pr100934.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr100934.c | 21 +++++++++++++++++++++ gcc/tree-ssa-dom.c | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr100934.c diff --git a/gcc/testsuite/gcc.dg/torture/pr100934.c b/gcc/testsuite/gcc.dg/torture/pr100934.c new file mode 100644 index 00000000000..43b78849895 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr100934.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ + +int a, b, c, d, e; +int main() +{ + int f = 0, g = 0; + for (; f < 2; f++) + { + int h, i; + for (h = 0; h < 2; h++) + { + b = e = g ? a % g : 0; + c = d; + for (i = 0; i < 1; i++) + g = 0; + for (; g < 2; g++) + ; + } + } + return 0; +} diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 075b1ccb9de..c231e6c8467 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -727,7 +727,8 @@ pass_dominator::execute (function *fun) gcc.dg/tree-ssa/pr21417.c can't be threaded if loop preheader is missing. We should improve jump threading in future then LOOPS_HAVE_PREHEADERS won't be needed here. */ - loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES); + loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES + | LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS); /* We need accurate information regarding back edges in the CFG for jump threading; this may include back edges that are not part of