aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-fold.cc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2021-11-29 09:19:34 -0500
committerAndrew MacLeod <amacleod@redhat.com>2021-11-30 09:07:21 -0500
commite43b15c88c242b14a8ced8e631c1f9b80e83d63c (patch)
tree80d5dae509a532247a94efe060bec069984ece96 /gcc/gimple-range-fold.cc
parentfa01e206c87581186f64f4500f926cdb70549de0 (diff)
downloadgcc-e43b15c88c242b14a8ced8e631c1f9b80e83d63c.zip
gcc-e43b15c88c242b14a8ced8e631c1f9b80e83d63c.tar.gz
gcc-e43b15c88c242b14a8ced8e631c1f9b80e83d63c.tar.bz2
Always track arguments, even when ignoring equiv params.
To "ignore" ranges from equivalences, we should track the range separately, but still do the other name processing which determiens if there is a single name or not for equivalence. Otherwise we mistakently think we can introduce an equivalences. gcc/ PR tree-optimization/103440 * gimple-range-fold.cc (fold_using_range::range_of_phi): Continue normal param processing for equiv params. gcc/testsuite/ * gcc.dg/pr103440.c: New.
Diffstat (limited to 'gcc/gimple-range-fold.cc')
-rw-r--r--gcc/gimple-range-fold.cc21
1 files changed, 9 insertions, 12 deletions
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index d66ada5..5812229 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -795,20 +795,17 @@ fold_using_range::range_of_phi (irange &r, gphi *phi, fur_source &src)
// Get the range of the argument on its edge.
src.get_phi_operand (arg_range, arg, e);
- // Likewise, if the incoming PHI argument is equivalent to this
- // PHI definition, it provides no new info. Accumulate these ranges
- // in case all arguments are equivalences.
- if (src.query ()->query_relation (e, arg, phi_def, false) == EQ_EXPR)
- {
- single_arg = arg;
- equiv_range.union_(arg_range);
- continue;
- }
-
if (!arg_range.undefined_p ())
{
// Register potential dependencies for stale value tracking.
- r.union_ (arg_range);
+ // Likewise, if the incoming PHI argument is equivalent to this
+ // PHI definition, it provides no new info. Accumulate these ranges
+ // in case all arguments are equivalences.
+ if (src.query ()->query_relation (e, arg, phi_def, false) == EQ_EXPR)
+ equiv_range.union_(arg_range);
+ else
+ r.union_ (arg_range);
+
if (gimple_range_ssa_p (arg) && src.gori ())
src.gori ()->register_dependency (phi_def, arg);
@@ -829,7 +826,7 @@ fold_using_range::range_of_phi (irange &r, gphi *phi, fur_source &src)
// If all arguments were equivalences, use the equivalence ranges as no
// arguments were processed.
- if (!seen_arg)
+ if (r.undefined_p () && !equiv_range.undefined_p ())
r = equiv_range;
// If the PHI boils down to a single effective argument, look at it.