diff options
author | Richard Biener <rguenther@suse.de> | 2022-12-01 09:01:20 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-12-01 10:18:46 +0100 |
commit | 8629f212af0acb113879d0bc45291c54743790f1 (patch) | |
tree | 0705ee3348fa1a29ba809124d4da1352c6982589 | |
parent | 2c089640279614e34b8712bfb318a9d4fc8ac8fe (diff) | |
download | gcc-8629f212af0acb113879d0bc45291c54743790f1.zip gcc-8629f212af0acb113879d0bc45291c54743790f1.tar.gz gcc-8629f212af0acb113879d0bc45291c54743790f1.tar.bz2 |
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.
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr107935.c | 18 | ||||
-rw-r--r-- | gcc/tree-ssa-sccvn.cc | 7 |
2 files changed, 24 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr107935.c b/gcc/testsuite/gcc.dg/torture/pr107935.c new file mode 100644 index 0000000..7817510 --- /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 1e7763b..b9f289b 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]; |