From 297db279102e9c5f5b32f0580a303dab6a0a5fd5 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 3 Aug 2017 14:08:15 +0000 Subject: [PATCH] tree-ssa-reassoc.c (should_break_up_subtract): Also break up if the use is in USE - X. 2017-08-03 Richard Biener * tree-ssa-reassoc.c (should_break_up_subtract): Also break up if the use is in USE - X. * gcc.dg/tree-ssa/reassoc-23.c: Adjust to fool early folding and CSE. From-SVN: r250855 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/reassoc-23.c | 7 ++++--- gcc/tree-ssa-reassoc.c | 4 +++- 4 files changed, 17 insertions(+), 4 deletions(-) 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; } -- 2.30.2