From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id EE3D4385840F; Thu, 1 Dec 2022 09:18:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE3D4385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669886338; bh=vlcSRAvovTyFkqkcUClax5DRcmVWNxsakX3nrQWjA/E=; h=From:To:Subject:Date:From; b=TlB8D7bYmgCylusQojp43jzpogFnu7EAJzcD+8iE8LtWLodzYtx8d7Cck2DO3xlIt xt9c97fLap7lYfN6AGGyNx3/fbH+/DSiHuw5lzVPb3m9J7qAPeDB9YPvamEntvdqGb 2kQhoBWlqFWSuSNKI5Hcr7Q/ebUBPNTVA5/NqQ+8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4436] tree-optimization/107935 - fixup equivalence handling in PHI VN X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 2c089640279614e34b8712bfb318a9d4fc8ac8fe X-Git-Newrev: 8629f212af0acb113879d0bc45291c54743790f1 Message-Id: <20221201091858.EE3D4385840F@sourceware.org> Date: Thu, 1 Dec 2022 09:18:58 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8629f212af0acb113879d0bc45291c54743790f1 commit r13-4436-g8629f212af0acb113879d0bc45291c54743790f1 Author: Richard Biener Date: Thu Dec 1 09:01:20 2022 +0100 tree-optimization/107935 - fixup equivalence handling in PHI VN The following makes sure to honor the backedge processing logic that forces VARYING there. PR tree-optimization/107935 * tree-ssa-sccvn.cc (visit_phi): Honor forced VARYING on backedges. * gcc.dg/torture/pr107935.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/torture/pr107935.c | 18 ++++++++++++++++++ gcc/tree-ssa-sccvn.cc | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr107935.c b/gcc/testsuite/gcc.dg/torture/pr107935.c new file mode 100644 index 00000000000..78175100f80 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr107935.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +int *a, **b; +int main() { + int d = 0, *e = &d; + L: + *e = d; + if (a) { + int *g = e = *b; + if (!e) + __builtin_abort(); + if (**b) + return 0; + *g = 1; + goto L; + } + return 0; +} diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 1e7763baa38..b9f289b6eca 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -5840,7 +5840,12 @@ visit_phi (gimple *phi, bool *inserted, bool backedges_varying_p) continue; } /* There's also the possibility to use equivalences. */ - if (!FLOAT_TYPE_P (TREE_TYPE (def))) + if (!FLOAT_TYPE_P (TREE_TYPE (def)) + /* But only do this if we didn't force any of sameval or + val to VARYING because of backedge processing rules. */ + && (TREE_CODE (sameval) != SSA_NAME + || SSA_VAL (sameval) == sameval) + && (TREE_CODE (def) != SSA_NAME || SSA_VAL (def) == def)) { vn_nary_op_t vnresult; tree ops[2];