diff options
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr110271.c | 24 | ||||
-rw-r--r-- | gcc/tree-ssa-math-opts.cc | 9 |
2 files changed, 30 insertions, 3 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr110271.c b/gcc/testsuite/gcc.c-torture/compile/pr110271.c new file mode 100644 index 0000000..0cb91be --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr110271.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/110271 */ + +unsigned a, b, c, d, e; + +void +foo (unsigned *x, int y, unsigned int *z) +{ + for (int i = 0; i < y; i++) + { + b += d; + a += b < d; + a += c = (__PTRDIFF_TYPE__) x > 3; + d = z[1] + (a < c); + a += e; + d += a < e; + } +} + +void +bar (unsigned int *z) +{ + unsigned *x = x; + foo (x, 9, z); +} diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc index b2764d4..d2b7129 100644 --- a/gcc/tree-ssa-math-opts.cc +++ b/gcc/tree-ssa-math-opts.cc @@ -5558,9 +5558,12 @@ math_opts_dom_walker::after_dom_children (basic_block bb) case PLUS_EXPR: case MINUS_EXPR: - if (!convert_plusminus_to_widen (&gsi, stmt, code) - && !match_arith_overflow (&gsi, stmt, code, m_cfg_changed_p)) - match_uaddc_usubc (&gsi, stmt, code); + if (!convert_plusminus_to_widen (&gsi, stmt, code)) + { + match_arith_overflow (&gsi, stmt, code, m_cfg_changed_p); + if (gsi_stmt (gsi) == stmt) + match_uaddc_usubc (&gsi, stmt, code); + } break; case BIT_NOT_EXPR: |