summaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-21 09:32:32 +0000
committerglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-21 09:32:32 +0000
commit523f3a9d4fcbb5281bfd83c4010b22ce8aadad7b (patch)
tree1ee36064cb859fba2a08608c049082bd1282c2cd /gcc/match.pd
parentfda1b8b5d86ce32cb429faeb2e1c27e13831d0a8 (diff)
downloadgcc-523f3a9d4fcbb5281bfd83c4010b22ce8aadad7b.tar.gz
max(INT_MIN, x) -> x
2016-04-21 Marc Glisse <marc.glisse@inria.fr> gcc/ * match.pd (min(int_max, x), max(int_min, x)): New transformations. gcc/testsuite/ * gcc.dg/tree-ssa/minmax-1.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235323 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd26
1 files changed, 18 insertions, 8 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 75aa6013b2e..38193216aee 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1192,16 +1192,26 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
@1)
(simplify
(min @0 @1)
- (if (INTEGRAL_TYPE_P (type)
- && TYPE_MIN_VALUE (type)
- && operand_equal_p (@1, TYPE_MIN_VALUE (type), OEP_ONLY_CONST))
- @1))
+ (switch
+ (if (INTEGRAL_TYPE_P (type)
+ && TYPE_MIN_VALUE (type)
+ && operand_equal_p (@1, TYPE_MIN_VALUE (type), OEP_ONLY_CONST))
+ @1)
+ (if (INTEGRAL_TYPE_P (type)
+ && TYPE_MAX_VALUE (type)
+ && operand_equal_p (@1, TYPE_MAX_VALUE (type), OEP_ONLY_CONST))
+ @0)))
(simplify
(max @0 @1)
- (if (INTEGRAL_TYPE_P (type)
- && TYPE_MAX_VALUE (type)
- && operand_equal_p (@1, TYPE_MAX_VALUE (type), OEP_ONLY_CONST))
- @1))
+ (switch
+ (if (INTEGRAL_TYPE_P (type)
+ && TYPE_MAX_VALUE (type)
+ && operand_equal_p (@1, TYPE_MAX_VALUE (type), OEP_ONLY_CONST))
+ @1)
+ (if (INTEGRAL_TYPE_P (type)
+ && TYPE_MIN_VALUE (type)
+ && operand_equal_p (@1, TYPE_MIN_VALUE (type), OEP_ONLY_CONST))
+ @0)))
(for minmax (FMIN FMAX)
/* If either argument is NaN, return the other one. Avoid the
transformation if we get (and honor) a signalling NaN. */