(cmp (bit_and@2 @0 integer_pow2p@1) @1)
(icmp @2 { build_zero_cst (TREE_TYPE (@0)); })))
-#if GIMPLE
-/* From fold_binary_op_with_conditional_arg handle the case of
- rewriting (a ? b : c) > d to a ? (b > d) : (c > d) when the
- compares simplify. */
-(for cmp (simple_comparison)
- (simplify
- (cmp:c (cond @0 @1 @2) @3)
- /* Do not move possibly trapping operations into the conditional as this
- pessimizes code and causes gimplification issues when applied late. */
- (if (!FLOAT_TYPE_P (TREE_TYPE (@3))
- || !operation_could_trap_p (cmp, true, false, @3))
- (cond @0 (cmp! @1 @3) (cmp! @2 @3)))))
-#endif
-
(for cmp (ge lt)
/* x < 0 ? ~y : y into (x >> (prec-1)) ^ y. */
/* x >= 0 ? ~y : y into ~((x >> (prec-1)) ^ y). */
replace if (x == 0) with tem = ~x; if (tem != 0) which is
clearly less optimal and which we'll transform again in forwprop. */
+#if GIMPLE
+/* From fold_binary_op_with_conditional_arg handle the case of
+ rewriting (a ? b : c) > d to a ? (b > d) : (c > d) when the
+ compares simplify.
+ This should be after the boolean comparison simplification so
+ that it can remove the outer comparison before appling it to
+ the inner condtional operands. */
+(for cmp (simple_comparison)
+ (simplify
+ (cmp:c (cond @0 @1 @2) @3)
+ /* Do not move possibly trapping operations into the conditional as this
+ pessimizes code and causes gimplification issues when applied late. */
+ (if (!FLOAT_TYPE_P (TREE_TYPE (@3))
+ || !operation_could_trap_p (cmp, true, false, @3))
+ (cond @0 (cmp! @1 @3) (cmp! @2 @3)))))
+#endif
+
/* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
where ~Y + 1 == pow2 and Z = ~Y. */
(for cst (VECTOR_CST INTEGER_CST)