+2016-04-21 Marc Glisse <marc.glisse@inria.fr>
+
+ * match.pd (min(int_max, x), max(int_min, x)): New transformations.
+
2016-04-20 Jan Hubicka <jh@suse.cz>
* ipa-inline.c (can_inline_edge_p): Pass caller info to
@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. */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+static int min(int a,int b){return (a<b)?a:b;}
+static int max(int a,int b){return (a<b)?b:a;}
+int f(int x){return max(x,-__INT_MAX__-1);}
+int g(int x){return min(x,__INT_MAX__);}
+
+/* { dg-final { scan-tree-dump-times "return x_\[0-9\]+.D.;" 2 "optimized" } } */