diff --git a/gcc/testsuite/gcc.c-torture/compile/pr113201.c b/gcc/testsuite/gcc.c-torture/compile/pr113201.c new file mode 100644 index 0000000000000000000000000000000000000000..72ec76169bdbc806a255412678dd80d9d4d81686 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr113201.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/113201 */ + +void foo (void) __attribute__((returns_twice)); +void bar (void); + +int +baz (void) +{ + int x = 42; + foo (); + while (--x) + ; + bar (); + return x; +} diff --git a/gcc/tree-scalar-evolution.cc b/gcc/tree-scalar-evolution.cc index 481ce7cf9439a4a0e74cbec862e624cce2768695..25e3130e2f1282823f6a477ca5df58dff9ec06b8 100644 --- a/gcc/tree-scalar-evolution.cc +++ b/gcc/tree-scalar-evolution.cc @@ -3881,7 +3881,7 @@ final_value_replacement_loop (class loop *loop) /* Propagate constants immediately, but leave an unused initialization around to avoid invalidating the SCEV cache. */ - if (CONSTANT_CLASS_P (def)) + if (CONSTANT_CLASS_P (def) && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rslt)) replace_uses_by (rslt, def); /* Create the replacement statements. */