tree-ssa-reassoc.c (should_break_up_subtract): Also break up if the use is in USE - X.

2017-08-03  Richard Biener  <rguenther@suse.de>

	* 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
This commit is contained in:
Richard Biener 2017-08-03 14:08:15 +00:00 committed by Richard Biener
parent 75560de5f5
commit 297db27910
4 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2017-08-03 Richard Biener <rguenther@suse.de>
* tree-ssa-reassoc.c (should_break_up_subtract): Also break
up if the use is in USE - X.
2017-08-03 Alexander Monakov <amonakov@ispras.ru>
* toplev.c (dumpfile.h): New include.

View File

@ -1,3 +1,8 @@
2017-08-03 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/reassoc-23.c: Adjust to fool early folding
and CSE.
2017-08-03 Richard Biener <rguenther@suse.de>
PR middle-end/81148

View File

@ -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;
}

View File

@ -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;
}