https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95649

--- Comment #7 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Hmmm, previous code propagating into PHI args had:

-         if (vr->singleton_p (&val) && may_propagate_copy (arg, val))
-           propagate_value (use_p, val);

We seem to have lost the check for constants, and we're now propagating any old
value from get_value_range-- which may be another SSA name:

+         if (val && may_propagate_copy (arg, val))
+           propagate_value (use_p, val);


Testing the following:

diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 4fda296ef9e..01ee7fd33eb 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1035,7 +1035,8 @@ substitute_and_fold_engine::propagate_into_phi_args
(basic_block bb)
              || virtual_operand_p (arg))
            continue;
          tree val = get_value (arg, phi);
-         if (val && may_propagate_copy (arg, val))
+         if (val && is_gimple_min_invariant (val)
+             && may_propagate_copy (arg, val))
            propagate_value (use_p, val);
        }
     }

Reply via email to