From patchwork Thu Jun 22 08:13:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 111481 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4904589vqr; Thu, 22 Jun 2023 01:14:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5q3oEzU3a5z32JHIo2ZeVgA+ZlyvTGQy8VYubcvsxm/FZYUQa3e1PUa6yK9JS7B2TA3a7h X-Received: by 2002:a17:907:972a:b0:98c:f298:cd70 with SMTP id jg42-20020a170907972a00b0098cf298cd70mr2394118ejc.1.1687421655281; Thu, 22 Jun 2023 01:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687421655; cv=none; d=google.com; s=arc-20160816; b=WF+DO4jSDLLrR0OUfINtg8dCugUaHhU7ulg6wiiy2YSrW/FcIIM7MaqiFh8ghwty0c n7xU9RSTxp7HiORSoOXJM50LLoPVhhE7OGYTNgFO05334sfyredm2Oj/MF+MsVysoMYD M24ZOKXITkiQzMdaBzHyCx6kcf0TI2wn4Pf6Gbt62+Qs+3VmB655ObplU7qsN0SHhVvL 8SkUJDWLxrK6eVCuL+GnoUjJpzUTV+qqrSDX5chEvzI9GeIP9AZPb4TvsSro7FIXRlbx KSlginWECgTcCIEwuST2jzUdmp7CVK/goVlNCDvk7HqRjfjz9+NOK9f2+cg7dJhXiUP9 ZsEg== 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=FOvHQSfUJpw/oPmKzLY6od63jd58MB7BnUy+Kp/HE+s=; b=f7yQSuaksuelkQk6qy86tvZiEVtuj0/ao1g/xMgAjLDwzhjhRYt29ilqBSw1YWnqkx 67oPINw1i8KMU4m+oabt2Cvb9XyoGm5dqviAJgkf68mXbFlGJf8BY/eMn88KB0uI7t2k 2VNT56FtVNpFppBl6tZQZ2sExBWvg5gSzlCg9oySYUh40hjpKnwL+D91C/ghXFdoqJLE 2dxLwZP7fiijzzTCYl9QO1wg7fb8RKfCDxPwAtYV74fuybgje1tXV1E+jK0K5wd1a6cr Lc0C5JANM6ehlW/ALiz26r5NmXVIOqhDp57AZMPZilm7RbEGWcS44iVS09SHr1PyBOjN 0gLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kErzMV+M; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s7-20020a1709067b8700b0098770f63085si3208302ejo.33.2023.06.22.01.14.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 01:14:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kErzMV+M; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 EA6D53858C39 for ; Thu, 22 Jun 2023 08:14:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA6D53858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687421654; bh=FOvHQSfUJpw/oPmKzLY6od63jd58MB7BnUy+Kp/HE+s=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kErzMV+MCN9kwngyRAFy0bIUG1TXkVrop4l1ahGhf0xcBZ03o7UurlmT5YtnOruwA 2w9Nl75Ytzko9eDfB77l/TvrMSQh6dzhdnUD+1NZZaoOsgJiLFUeX7WfNCo8OOW8UD 5v0cmMs0/3EKLwfEKSXh23ZDq11AwMcF6xCAiq1w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id B03313858D35 for ; Thu, 22 Jun 2023 08:13:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B03313858D35 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9CA2C22976 for ; Thu, 22 Jun 2023 08:13:28 +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 932652C141 for ; Thu, 22 Jun 2023 08:13:28 +0000 (UTC) Date: Thu, 22 Jun 2023 08:13:28 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/110332 - fix ICE with phiprop User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 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, T_SCC_BODY_TEXT_LINE 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: <20230622081413.EA6D53858C39@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769389849368700100?= X-GMAIL-MSGID: =?utf-8?q?1769389849368700100?= The following fixes an ICE that occurs when we visit an edge inserted load from the code validating correctness for inserting an aggregate copy there. We can simply skip those loads here. Boostrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/110332 * tree-ssa-phiprop.cc (propagate_with_phi): Always check aliasing with edge inserted loads. * g++.dg/torture/pr110332.C: New testcase. * gcc.dg/torture/pr110332-1.c: Likewise. * gcc.dg/torture/pr110332-2.c: Likewise. --- gcc/testsuite/g++.dg/torture/pr110332.C | 16 ++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr110332-1.c | 13 +++++++++++++ gcc/testsuite/gcc.dg/torture/pr110332-2.c | 10 ++++++++++ gcc/tree-ssa-phiprop.cc | 10 +++++++--- 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr110332.C create mode 100644 gcc/testsuite/gcc.dg/torture/pr110332-1.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr110332-2.c diff --git a/gcc/testsuite/g++.dg/torture/pr110332.C b/gcc/testsuite/g++.dg/torture/pr110332.C new file mode 100644 index 00000000000..31dc93ecee4 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr110332.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +struct SlotIndex { int lie; }; +SlotIndex si7, si8; + +unsigned u9, u6; +bool b3, b4; +unsigned &value() { + return b4 ? u6 : u9; +} +void transferValues() { + unsigned RegIdx; + SlotIndex End; + RegIdx = value(); + End = b3 ? si7 : si8; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr110332-1.c b/gcc/testsuite/gcc.dg/torture/pr110332-1.c new file mode 100644 index 00000000000..438993e8daf --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr110332-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +struct s { int lie; }; +struct s si7, si8; +unsigned u9, u6; +_Bool b3, b4; +unsigned transferValues(struct s *End) { + unsigned RegIdx; + unsigned *t = b4 ? &u6 : &u9; + RegIdx = *t; + *End = *(b3 ? &si7 : &si8); + return RegIdx; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr110332-2.c b/gcc/testsuite/gcc.dg/torture/pr110332-2.c new file mode 100644 index 00000000000..18b656ffb2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr110332-2.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +_Bool a; +struct s { int t; } c, d; +unsigned e, f; +unsigned transferValues(struct s *End) { + unsigned RegIdx = *(a ? &e : &f); + *End = *(a ? &c : &d); + return RegIdx; +} diff --git a/gcc/tree-ssa-phiprop.cc b/gcc/tree-ssa-phiprop.cc index 21a349a25e2..8c9ce903472 100644 --- a/gcc/tree-ssa-phiprop.cc +++ b/gcc/tree-ssa-phiprop.cc @@ -399,14 +399,18 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, there are no statements that could read from memory aliasing the lhs in between the start of bb and use_stmt. As we require use_stmt to have a VDEF above, loads after - use_stmt will use a different virtual SSA_NAME. */ + use_stmt will use a different virtual SSA_NAME. When + we reach an edge inserted load the constraints we place + on processing guarantees that program order is preserved + so we can avoid checking those. */ FOR_EACH_IMM_USE_FAST (vuse_p, vui, vuse) { vuse_stmt = USE_STMT (vuse_p); if (vuse_stmt == use_stmt) continue; - if (!dominated_by_p (CDI_DOMINATORS, - gimple_bb (vuse_stmt), bb)) + if (!gimple_bb (vuse_stmt) + || !dominated_by_p (CDI_DOMINATORS, + gimple_bb (vuse_stmt), bb)) continue; if (ref_maybe_used_by_stmt_p (vuse_stmt, gimple_assign_lhs (use_stmt)))