Fix pasto in the substitute_and_fold_engine merge with evrp.
The original code only propagated into PHI arguments if the value was a constant. This behavior was lost in the conversion, allowing any value (SSAs for instance) to be propagated into PHIs. gcc/ChangeLog: PR tree-optimization/95649 * tree-ssa-propagate.c (propagate_into_phi_args): Do not propagate unless value is a constant. gcc/testsuite/ChangeLog: * g++.dg/tree-ssa/pr95649.C: New test. * gcc.dg/tree-ssa/pr95649.c: New test.
This commit is contained in:
parent
12df77ab6d
commit
8fb4d1d583
|
@ -0,0 +1,13 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2" } */
|
||||
|
||||
extern unsigned short var_5;
|
||||
extern int var_8, var_9;
|
||||
extern short arr_7[];
|
||||
void test() {
|
||||
for (; 0 < (char)var_5;)
|
||||
for (int a(var_9 ? var_5 : 0); a < 3002972621U + 1291994699;
|
||||
a += 19499 - 19497)
|
||||
for (long b(var_8); b; b += 4)
|
||||
arr_7[a * b] = 0;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -fno-tree-scev-cprop" } */
|
||||
|
||||
char b (void);
|
||||
char *d;
|
||||
int e;
|
||||
int f;
|
||||
void
|
||||
g (char *h)
|
||||
{
|
||||
while (d)
|
||||
{
|
||||
long i = b ();
|
||||
if (h + i > d)
|
||||
break;
|
||||
if (f > 0 || e)
|
||||
do
|
||||
*h++ = *h;
|
||||
while (--i);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue