aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-fold.cc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2023-04-12 13:10:55 -0400
committerAndrew MacLeod <amacleod@redhat.com>2023-04-13 14:12:04 -0400
commit9c2a5db997446a9438a3e01f5229dec3f78b09e7 (patch)
tree9cc090d2104f2033d75fbcc21db9e3314a337e89 /gcc/gimple-range-fold.cc
parent52bb22bb5e1f951c73b5cd43b0b3a423f67e5e7a (diff)
downloadgcc-9c2a5db997446a9438a3e01f5229dec3f78b09e7.zip
gcc-9c2a5db997446a9438a3e01f5229dec3f78b09e7.tar.gz
gcc-9c2a5db997446a9438a3e01f5229dec3f78b09e7.tar.bz2
Ensure PHI equivalencies do not dominate the argument edge.
When we create an equivalency between a PHI definition and an argument, ensure the definition does not dominate the incoming argument edge. PR tree-optimization/108139 PR tree-optimization/109462 * gimple-range-cache.cc (ranger_cache::fill_block_cache): Remove equivalency check for PHI nodes. * gimple-range-fold.cc (fold_using_range::range_of_phi): Ensure def does not dominate single-arg equivalency edges.
Diffstat (limited to 'gcc/gimple-range-fold.cc')
-rw-r--r--gcc/gimple-range-fold.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index e81f6b3..429734f 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -795,9 +795,28 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src)
// If the PHI boils down to a single effective argument, look at it.
if (single_arg)
{
- // Symbolic arguments are equivalences.
+ // Symbolic arguments can be equivalences.
if (gimple_range_ssa_p (single_arg))
- src.register_relation (phi, VREL_EQ, phi_def, single_arg);
+ {
+ // Only allow the equivalence if the PHI definition does not
+ // dominate any incoming edge for SINGLE_ARG.
+ // See PR 108139 and 109462.
+ basic_block bb = gimple_bb (phi);
+ if (!dom_info_available_p (CDI_DOMINATORS))
+ single_arg = NULL;
+ else
+ for (x = 0; x < gimple_phi_num_args (phi); x++)
+ if (gimple_phi_arg_def (phi, x) == single_arg
+ && dominated_by_p (CDI_DOMINATORS,
+ gimple_phi_arg_edge (phi, x)->src,
+ bb))
+ {
+ single_arg = NULL;
+ break;
+ }
+ if (single_arg)
+ src.register_relation (phi, VREL_EQ, phi_def, single_arg);
+ }
else if (src.get_operand (arg_range, single_arg)
&& arg_range.singleton_p ())
{