https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115762
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
You get the undefined behavior sanitizer error which is all you need.
testcase.c:13:15: runtime error: division by zero
The reason why you don't get the FPE is because it is not needed here as we
have (x | e) >= e which optimizes just to (x, 1) and since x has no side
effects (traps can be removed), it can just become 1.
/*
U & N <= U -> true
U & N > U -> false
U needs to be non-negative.
U | N < U -> false
U | N >= U -> true
U and N needs to be non-negative
U | N < U -> true
U | N >= U -> false
U needs to be non-negative and N needs to be a negative constant.
*/
(for cmp (lt ge le gt )
bitop (bit_ior bit_ior bit_and bit_and)
(simplify
(cmp:c (bitop:c tree_expr_nonnegative_p@0 @1) @0)
(if (INTEGRAL_TYPE_P (TREE_TYPE (@0)))
(if (bitop == BIT_AND_EXPR || tree_expr_nonnegative_p (@1))
{ constant_boolean_node (cmp == GE_EXPR || cmp == LE_EXPR, type); }
/* The sign is opposite now so the comparison is swapped around. */
(if (TREE_CODE (@1) == INTEGER_CST && wi::neg_p (wi::to_wide (@1)))
{ constant_boolean_node (cmp == LT_EXPR, type); })))))