Commit 1e7df2e6 by Marc Glisse Committed by Marc Glisse

Simple reassoc transforms in match.pd

2017-06-27  Marc Glisse  <marc.glisse@inria.fr>

gcc/
	* match.pd ((A+-B)+(C-A), (A+B)-(A-C)): New transformations.

gcc/testsuite/
	* gcc.dg/tree-ssa/assoc-1.c: New file.

From-SVN: r249686
parent a889d6aa
2017-06-27 Marc Glisse <marc.glisse@inria.fr>
* match.pd ((A+-B)+(C-A), (A+B)-(A-C)): New transformations.
2017-06-27 Marc Glisse <marc.glisse@inria.fr>
* builtin-types.def (BT_FENV_T_PTR, BT_CONST_FENV_T_PTR,
BT_FEXCEPT_T_PTR, BT_CONST_FEXCEPT_T_PTR): New primitive types.
(BT_FN_INT_FENV_T_PTR, BT_FN_INT_CONST_FENV_T_PTR,
......
......@@ -1321,6 +1321,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(simplify
(minus @0 (minus @0 @1))
@1)
/* (A +- B) + (C - A) -> C +- B */
/* (A + B) - (A - C) -> B + C */
/* More cases are handled with comparisons. */
(simplify
(plus:c (plus:c @0 @1) (minus @2 @0))
(plus @2 @1))
(simplify
(plus:c (minus @0 @1) (minus @2 @0))
(minus @2 @1))
(simplify
(minus (plus:c @0 @1) (minus @0 @2))
(plus @1 @2))
/* (A +- CST1) +- CST2 -> A + CST3
Use view_convert because it is safe for vectors and equivalent for
......
2017-06-27 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/assoc-1.c: New file.
2017-06-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/62046
......
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized-raw -fno-tree-reassoc" } */
int f0(int a,int b,int c){
int d = a + b;
int e = c + b;
return d - e;
}
int f1(int a,int b,int c){
int d = a + b;
int e = b - c;
return d - e;
}
int f2(int a,int b,int c){
int d = a + b;
int e = c - b;
return e + d;
}
int f3(int a,int b,int c){
int d = a - b;
int e = c - b;
return d - e;
}
int f4(int a,int b,int c){
int d = b - a;
int e = c - b;
return e + d;
}
/* { dg-final { scan-tree-dump-times "plus_expr" 2 "optimized" } } */
/* { dg-final { scan-tree-dump-times "minus_expr" 3 "optimized" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment