* [PATCH] Fix gcc.dg/tree-ssa/reassoc-23.c
@ 2017-08-03 11:55 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2017-08-03 11:55 UTC (permalink / raw)
To: gcc-patches
The following makes reassoc also break up subtracts for values used
on the positive side of a MINUS_EXPR.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
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.
Index: gcc/tree-ssa-reassoc.c
===================================================================
--- gcc/tree-ssa-reassoc.c (revision 250818)
+++ gcc/tree-ssa-reassoc.c (working copy)
@@ -4718,7 +4718,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;
}
Index: gcc/testsuite/gcc.dg/tree-ssa/reassoc-23.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/reassoc-23.c (revision 250818)
+++ gcc/testsuite/gcc.dg/tree-ssa/reassoc-23.c (working copy)
@@ -6,9 +6,10 @@ foo(unsigned int a, unsigned int b, unsi
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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-08-03 11:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-03 11:55 [PATCH] Fix gcc.dg/tree-ssa/reassoc-23.c Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).