From patchwork Mon Feb 20 10:02:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 59337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1225642wrn; Mon, 20 Feb 2023 02:11:31 -0800 (PST) X-Google-Smtp-Source: AK7set+WJf8Qy31ajI2sKtcooUbhhJZSyZw7wvG89rbVqRAw0FrZy18QAdeIBCI7kWf58GD/JtpU X-Received: by 2002:a17:906:f88f:b0:8af:1a8c:f13f with SMTP id lg15-20020a170906f88f00b008af1a8cf13fmr8373774ejb.71.1676887890949; Mon, 20 Feb 2023 02:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676887890; cv=none; d=google.com; s=arc-20160816; b=kVto77yEfGvq5rBSEjMK71O68MI/7ONwp97OTK6It0FAcT8IkHiQNZZaynSnRG7IYC FbkbyNrl6Yv9augzJP0zOAaZMqvjnGgeSn6i+1M3LNgncl2r8UKJb1XecHrWwXlZb8Wh l2qJAwFVytrt5b5Ea+JU1URkAzra+owBK0uDCTP93oWy3YWvl576F4p8J+0G7UYzsW8a o3LLoqKBecWk/CiKkoOv7YoO2d5i++YHG2hEOtwPKyFAqrz+n/Jtyp6OIuWDHk0SWM2l yipKHqqQSkQOBcQFW9V0j6MGg9csWM9P4ziq9NmcEtfGJ5eMKiEItMH2ed/5IKEkwDdS LLpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=oJAo6It+FokEltMv7foSmo4CPGtzkxi4ol4mFq5HE+g=; b=Yk3O5eeQ3+KEaUbdU1p9NCzi52F7hVvV97JSScNMSYfMbj0HqwMwKH5RDkOPoKZd1y J+vQ0B0omEdjrr/VblnUJJsBdzaepAsi39AUZU1jFwHGp2aChKzRrKfJZVb6mh0r6D2r XNq8D6fdVjhy290+kHgFwsAKAhOc8eSdPi3eWKPkNiU6RJI6TZf2jTuGSswGXLYDB5Nb IDpDWbtA/HPeJpiACGfPS6/GjprzETi6ABaDv6tp0IW+OlUOnDuyLLAJXmW5KKdumcn1 4u7mfzEbXAfbgchsoWDNBZkG3z3b3nln2jlUvD11w55mkEH8JCUE5dBmvkRpUnv12hpU +BCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hkHTbrv+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id kb17-20020a170907925100b008cdb0cd5e80si4236108ejb.107.2023.02.20.02.11.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 02:11:30 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hkHTbrv+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CFFE43AA8C16 for ; Mon, 20 Feb 2023 10:03:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFFE43AA8C16 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676887386; bh=oJAo6It+FokEltMv7foSmo4CPGtzkxi4ol4mFq5HE+g=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hkHTbrv+1W1RO9M0rZdMwcDDJUs7BIR1rYHJltDOHvwyFbYyX2BmCfOm1FbcsQzG5 7sG+vmiQrQkvCP0newscaBmVyb4b65NgsVSWoXZ9tq1LgOSvrKwUORe96oYDHre8PT LUk7EdsFcUoHED3B+C/JKnsiiKnHm5Z46rVySpG8= 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 [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 69AD73887F6C for ; Mon, 20 Feb 2023 10:02:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69AD73887F6C Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5D1131FF33 for ; Mon, 20 Feb 2023 10:02:19 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (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 5440E2C141 for ; Mon, 20 Feb 2023 10:02:19 +0000 (UTC) Date: Mon, 20 Feb 2023 10:02:19 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/108825 - checking ICE with unroll-and-jam User-Agent: Alpine 2.22 (LSU 394 2020-01-19) 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, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20230220100306.CFFE43AA8C16@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758344396699767725?= X-GMAIL-MSGID: =?utf-8?q?1758344396699767725?= The issue is that unroll-and-jam applies RPO VN on the transformed body but that leaves the IL in "indetermined" state (it returns a TODO to make it valid again). But unroll-and-jam then continues to transform another loop and in using the tree_unroll_loop helper runs into tree_transform_and_unroll_loop performing IL checking on the whole function. While the real fix is to elide all such checking I'm only making the loop-local LC SSA verifier not perform function-wide SSA verification at this point. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/108825 * tree-ssa-loop-manip.cc (verify_loop_closed_ssa): For loop-local verfication only verify there's no pending SSA update. * gcc.dg/torture/pr108825.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr108825.c | 20 ++++++++++++++++++++ gcc/tree-ssa-loop-manip.cc | 11 ++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr108825.c diff --git a/gcc/testsuite/gcc.dg/torture/pr108825.c b/gcc/testsuite/gcc.dg/torture/pr108825.c new file mode 100644 index 00000000000..ada2da86054 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr108825.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int safe_mul_func_uint8_t_u_u_ui2, g_231, g_277_1, g_568, func_35___trans_tmp_10; +int g_81[7]; +extern int g_96[]; +char func_35___trans_tmp_11; +static inline int safe_add_func_int32_t_s_s(int si1, int si2) +{ return si1 > 647 - si2 ?: si1; } +void func_35() { + for (; g_277_1; g_277_1 += 1) { + g_231 = 0; + for (; g_231 <= 6; g_231 += 1) { + func_35___trans_tmp_10 = + safe_add_func_int32_t_s_s(g_81[g_231], g_568 || g_96[1]); + func_35___trans_tmp_11 = + func_35___trans_tmp_10 * safe_mul_func_uint8_t_u_u_ui2; + g_81[g_231] = func_35___trans_tmp_11; + } + } +} diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc index 14fe65f134d..09acc1c94cc 100644 --- a/gcc/tree-ssa-loop-manip.cc +++ b/gcc/tree-ssa-loop-manip.cc @@ -681,15 +681,15 @@ verify_loop_closed_ssa (bool verify_ssa_p, class loop *loop) if (number_of_loops (cfun) <= 1) return; - if (verify_ssa_p) - verify_ssa (false, true); - timevar_push (TV_VERIFY_LOOP_CLOSED); if (loop == NULL) { basic_block bb; + if (verify_ssa_p) + verify_ssa (false, true); + FOR_EACH_BB_FN (bb, cfun) if (bb->loop_father && bb->loop_father->num > 0) check_loop_closed_ssa_bb (bb); @@ -698,6 +698,11 @@ verify_loop_closed_ssa (bool verify_ssa_p, class loop *loop) { basic_block *bbs = get_loop_body (loop); + /* We do not have loop-local SSA verification so just + check there's no update queued. */ + if (verify_ssa_p) + gcc_assert (!need_ssa_update_p (cfun)); + for (unsigned i = 0; i < loop->num_nodes; ++i) check_loop_closed_ssa_bb (bbs[i]);