diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9e3a8aac28d..3febddcc051 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-08-03 Richard Biener + + * tree-ssa-reassoc.c (should_break_up_subtract): Also break + up if the use is in USE - X. + 2017-08-03 Alexander Monakov * toplev.c (dumpfile.h): New include. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3613d165232..03b66265855 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-03 Richard Biener + + * gcc.dg/tree-ssa/reassoc-23.c: Adjust to fool early folding + and CSE. + 2017-08-03 Richard Biener PR middle-end/81148 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-23.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-23.c index 0ab967d20ab..a5451ade6ef 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-23.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-23.c @@ -6,9 +6,10 @@ foo(unsigned int a, unsigned int b, unsigned int c, unsigned int d, unsigned int e, unsigned int f, unsigned int g, unsigned int h) { /* Should be transformed into e = 20 */ - unsigned int i = (a + 9) + (c + 8); - unsigned int j = (-c + 1) + (-a + 2); - + unsigned int i = (a + 9); + unsigned int j = (-c + 1); + i += (c + 8); + j += (-a + 2); e = i + j; return e; } diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 6ecba809199..561acea4dcc 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -4729,7 +4729,9 @@ should_break_up_subtract (gimple *stmt) && (immusestmt = get_single_immediate_use (lhs)) && is_gimple_assign (immusestmt) && (gimple_assign_rhs_code (immusestmt) == PLUS_EXPR - || gimple_assign_rhs_code (immusestmt) == MULT_EXPR)) + || (gimple_assign_rhs_code (immusestmt) == MINUS_EXPR + && gimple_assign_rhs1 (immusestmt) == lhs) + || gimple_assign_rhs_code (immusestmt) == MULT_EXPR)) return true; return false; }