(convert (absu:utype @0)))
@3))))
+/* X > Positive ? X : ABS(X) -> ABS(X) */
+/* X >= Positive ? X : ABS(X) -> ABS(X) */
+/* X == Positive ? X : ABS(X) -> ABS(X) */
+(for cmp (eq gt ge)
+ (simplify
+ (cond (cmp:c @0 tree_expr_nonnegative_p@1) @0 (abs@3 @0))
+ (if (INTEGRAL_TYPE_P (type))
+ @3)))
+
+/* X == Positive ? Positive : ABS(X) -> ABS(X) */
+(simplify
+ (cond (eq:c @0 tree_expr_nonnegative_p@1) @1 (abs@3 @0))
+ (if (INTEGRAL_TYPE_P (type))
+ @3))
+
/* (X + 1) > Y ? -X : 1 simplifies to X >= Y ? -X : 1 when
X is unsigned, as when X + 1 overflows, X is -1, so -X == 1. */
(simplify
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-phiopt1" } */
+/* PR tree-optimization/112392 */
+
+int feq_1(int a, unsigned char b)
+{
+ int absb = b;
+ if (a == absb) return absb;
+ return a > 0 ? a : -a;
+}
+int feq_2(int a, unsigned char b)
+{
+ int absb = b;
+ if (a == absb) return a;
+ return a > 0 ? a : -a;
+}
+
+int fgt(int a, unsigned char b)
+{
+ int absb = b;
+ if (a > absb) return a;
+ return a > 0 ? a : -a;
+}
+
+int fge(int a, unsigned char b)
+{
+ int absb = b;
+ if (a >= absb) return a;
+ return a > 0 ? a : -a;
+}
+
+
+/* { dg-final { scan-tree-dump-not "if " "phiopt1" } } */
+/* { dg-final { scan-tree-dump-times "ABS_EXPR <" 4 "phiopt1" } } */