aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorNaveen H.S <naveenh@gcc.gnu.org>2016-12-21 08:37:47 +0000
committerNaveen H.S <naveenh@gcc.gnu.org>2016-12-21 08:37:47 +0000
commit182f37c9ac733391323494e5f0ee394a0a065b27 (patch)
treece38343c14f2c6bf2a64434cb40493a12d00cd0d /gcc/match.pd
parent899614c10b3e214e0a5f9699565e83ba1627213b (diff)
downloadgcc-182f37c9ac733391323494e5f0ee394a0a065b27.zip
gcc-182f37c9ac733391323494e5f0ee394a0a065b27.tar.gz
gcc-182f37c9ac733391323494e5f0ee394a0a065b27.tar.bz2
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
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index f4cc2d8..1570ac8 100644
--- a/gcc/match.pd
+++ b/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))
@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
and the outer convert demotes the expression back to x's type. */
(for minmax (min max)