min(-x, -y), min(~x, ~y)
2016-04-21 Marc Glisse <marc.glisse@inria.fr> gcc/ * match.pd (min(-x, -y), max(-x, -y), min(~x, ~y), max(~x, ~y)): New transformations. gcc/testsuite/ * gcc.dg/tree-ssa/minmax-2.c: New testcase. From-SVN: r235332
This commit is contained in:
parent
6c7f7b8c69
commit
ce0e66ffb2
4 changed files with 35 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2016-04-21 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
* match.pd (min(-x, -y), max(-x, -y), min(~x, ~y), max(~x, ~y)):
|
||||
New transformations.
|
||||
|
||||
2016-04-21 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
* match.pd (min(int_max, x), max(int_min, x)): New transformations.
|
||||
|
|
16
gcc/match.pd
16
gcc/match.pd
|
@ -1232,6 +1232,22 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
|
|||
(simplify
|
||||
(FMAX @0 @1)
|
||||
(max @0 @1)))
|
||||
/* min (-A, -B) -> -max (A, B) */
|
||||
(for minmax (min max FMIN FMAX)
|
||||
maxmin (max min FMAX FMIN)
|
||||
(simplify
|
||||
(minmax (negate:s@2 @0) (negate:s@3 @1))
|
||||
(if (FLOAT_TYPE_P (TREE_TYPE (@0))
|
||||
|| (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
|
||||
&& TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0))))
|
||||
(negate (maxmin @0 @1)))))
|
||||
/* MIN (~X, ~Y) -> ~MAX (X, Y)
|
||||
MAX (~X, ~Y) -> ~MIN (X, Y) */
|
||||
(for minmax (min max)
|
||||
maxmin (max min)
|
||||
(simplify
|
||||
(minmax (bit_not:s@2 @0) (bit_not:s@3 @1))
|
||||
(bit_not (maxmin @0 @1))))
|
||||
|
||||
/* Simplifications of shift and rotates. */
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2016-04-21 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
* gcc.dg/tree-ssa/minmax-2.c: New testcase.
|
||||
|
||||
2016-04-21 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
* gcc.dg/tree-ssa/minmax-1.c: New testcase.
|
||||
|
|
10
gcc/testsuite/gcc.dg/tree-ssa/minmax-2.c
Normal file
10
gcc/testsuite/gcc.dg/tree-ssa/minmax-2.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O -fstrict-overflow -fdump-tree-optimized" } */
|
||||
|
||||
static int max(int a,int b){return (a<b)?b:a;}
|
||||
int f(int x,int y){return max(-x,-y);}
|
||||
int g(int x,int y){return max(~x,~y);}
|
||||
double h(double x,double y){return __builtin_fmax(-x,-y);}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "optimized" } } */
|
||||
/* { dg-final { scan-tree-dump "__builtin_fmin" "optimized" } } */
|
Loading…
Add table
Reference in a new issue