diff options
-rw-r--r-- | gcc/testsuite/gcc.dg/pr112430.c | 30 | ||||
-rw-r--r-- | gcc/tree-ssa-math-opts.cc | 8 |
2 files changed, 35 insertions, 3 deletions
diff --git a/gcc/testsuite/gcc.dg/pr112430.c b/gcc/testsuite/gcc.dg/pr112430.c new file mode 100644 index 0000000..16c34fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr112430.c @@ -0,0 +1,30 @@ +/* PR middle-end/112430 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +int a, b, c, d, e; +unsigned int f; + +static void +foo (unsigned int x) +{ + unsigned int g = x < c; + int h = f < b; + x += h; + g += x < h; + f = x; + x = g; + g = f += a; + h = f < a; + x += h; + c += f < d; + x += c; + g += x < c; + e = g; +} + +void +bar (unsigned int x) +{ + foo (x); +} diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc index 363f316..95eda43 100644 --- a/gcc/tree-ssa-math-opts.cc +++ b/gcc/tree-ssa-math-opts.cc @@ -5047,11 +5047,11 @@ match_uaddc_usubc (gimple_stmt_iterator *gsi, gimple *stmt, tree_code code) gsi_insert_before (gsi, g, GSI_SAME_STMT); /* Remove some further statements which can't be kept in the IL because they can use SSA_NAMEs whose setter is going to be removed too. */ - while (temp_stmts.length ()) + for (gimple *g2 : temp_stmts) { - g = temp_stmts.pop (); - gsi2 = gsi_for_stmt (g); + gsi2 = gsi_for_stmt (g2); gsi_remove (&gsi2, true); + release_defs (g2); } } else @@ -5068,10 +5068,12 @@ match_uaddc_usubc (gimple_stmt_iterator *gsi, gimple *stmt, tree_code code) rhs1 = gimple_assign_rhs1 (g); gsi2 = gsi_for_stmt (g); gsi_remove (&gsi2, true); + release_defs (g); } gcc_checking_assert (rhs1 == gimple_assign_lhs (im2)); gsi2 = gsi_for_stmt (im2); gsi_remove (&gsi2, true); + release_defs (im2); /* Replace the re2 statement with __real__ of the newly added .UADDC/.USUBC call. */ if (re2) |