diff options
-rw-r--r-- | gcc/gimple-range-fold.cc | 21 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr103440.c | 24 |
2 files changed, 33 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. diff --git a/gcc/testsuite/gcc.dg/pr103440.c b/gcc/testsuite/gcc.dg/pr103440.c new file mode 100644 index 0000000..b97f45c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr103440.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-Os" } */ +/* { dg-timeout 10 } */ + +int a, b, c, d, e; +int main() { + int f = 2, g = 1, h = -3; +L1: + c = b ^ 1; + if (!f) + goto L3; + if (d) + g = e; + f = h; + if (!c) + goto L1; +L2: + if (g) + a = 0; +L3: + if (d == g) + goto L2; + return 0; +} |