mirror of git://gcc.gnu.org/git/gcc.git
match.pd (max:c @0 (plus@2 @0 INTEGER_CST@1)): New Pattern.
2016-12-22 Andrew Pinski <apinski@cavium.com>
Naveen H.S <Naveen.Hurugalawadi@cavium.com>
gcc
* match.pd (max:c @0 (plus@2 @0 INTEGER_CST@1)): New Pattern.
(min:c @0 (plus@2 @0 INTEGER_CST@1)) : New Pattern.
gcc/testsuite
* gcc.dg/max.c: New Testcase.
* gcc.dg/min.c: New Testcase.
From-SVN: r243838
This commit is contained in:
parent
899614c10b
commit
182f37c9ac
|
|
@ -1,3 +1,8 @@
|
||||||
|
2016-12-22 Andrew Pinski <apinski@cavium.com>
|
||||||
|
|
||||||
|
* match.pd (max:c @0 (plus@2 @0 INTEGER_CST@1)): New Pattern.
|
||||||
|
(min:c @0 (plus@2 @0 INTEGER_CST@1)) : New Pattern.
|
||||||
|
|
||||||
2016-12-20 James Greenhalgh <james.greenhalghj@arm.com>
|
2016-12-20 James Greenhalgh <james.greenhalghj@arm.com>
|
||||||
|
|
||||||
* common.opt (excess_precision): Tag as SetByCombined.
|
* common.opt (excess_precision): Tag as SetByCombined.
|
||||||
|
|
|
||||||
18
gcc/match.pd
18
gcc/match.pd
|
|
@ -1373,6 +1373,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
|
||||||
&& operand_equal_p (@1, TYPE_MIN_VALUE (type), OEP_ONLY_CONST))
|
&& operand_equal_p (@1, TYPE_MIN_VALUE (type), OEP_ONLY_CONST))
|
||||||
@0)))
|
@0)))
|
||||||
|
|
||||||
|
/* max (a, a + CST) -> a + CST where CST is positive. */
|
||||||
|
/* max (a, a + CST) -> a where CST is negative. */
|
||||||
|
(simplify
|
||||||
|
(max:c @0 (plus@2 @0 INTEGER_CST@1))
|
||||||
|
(if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))
|
||||||
|
(if (tree_int_cst_sgn (@1) > 0)
|
||||||
|
@2
|
||||||
|
@0)))
|
||||||
|
|
||||||
|
/* min (a, a + CST) -> a where CST is positive. */
|
||||||
|
/* min (a, a + CST) -> a + CST where CST is negative. */
|
||||||
|
(simplify
|
||||||
|
(min:c @0 (plus@2 @0 INTEGER_CST@1))
|
||||||
|
(if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))
|
||||||
|
(if (tree_int_cst_sgn (@1) > 0)
|
||||||
|
@0
|
||||||
|
@2)))
|
||||||
|
|
||||||
/* (convert (minmax ((convert (x) c)))) -> minmax (x c) if x is promoted
|
/* (convert (minmax ((convert (x) c)))) -> minmax (x c) if x is promoted
|
||||||
and the outer convert demotes the expression back to x's type. */
|
and the outer convert demotes the expression back to x's type. */
|
||||||
(for minmax (min max)
|
(for minmax (min max)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
2016-12-22 Naveen H.S <Naveen.Hurugalawadi@cavium.com>
|
||||||
|
|
||||||
|
* gcc.dg/max.c: New Testcase.
|
||||||
|
* gcc.dg/min.c: New Testcase.
|
||||||
|
|
||||||
2016-12-21 Jakub Jelinek <jakub@redhat.com>
|
2016-12-21 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR c/77767
|
PR c/77767
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O2 -fdump-tree-optimized" } */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
max (int a, int b)
|
||||||
|
{
|
||||||
|
return a < b ? b : a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
test_00 (int a)
|
||||||
|
{
|
||||||
|
return max (a, a + 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
test_01 (int a)
|
||||||
|
{
|
||||||
|
return max (a, a - 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* { dg-final { scan-tree-dump-not "MAX_EXPR" "optimized" } } */
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O2 -fdump-tree-optimized" } */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
min (int a, int b)
|
||||||
|
{
|
||||||
|
return a < b ? a : b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
test_00 (int a)
|
||||||
|
{
|
||||||
|
return min (a, a + 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
test_01 (int a)
|
||||||
|
{
|
||||||
|
return min (a, a - 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* { dg-final { scan-tree-dump-not "MIN_EXPR" "optimized" } } */
|
||||||
Loading…
Reference in New Issue