https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123887
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I'll note that another pattern uses expr_no_side_effects_p:
/* a != 0 ? a / b : 0 -> a / b iff b is nonzero. */
(for op (trunc_div ceil_div floor_div round_div exact_div)
(simplify
(cond (ne @0 integer_zerop) (op@2 @3 @1) integer_zerop )
(if (bitwise_equal_p (@0, @3)
&& tree_expr_nonzero_p (@1)
/* Cannot make a expression with side effects
unconditional. */
&& expr_no_side_effects_p (@3))
@2)))
that, for GIMPLE, asserts we only see is_gimple_val, and for GENERIC
does
if (TREE_SIDE_EFFECTS (t))
return false;
if (generic_expr_could_trap_p (t))
return false;
I'm testing the genmatch fix, since for GENERIC it was intended to be
catched by the side-effects check. The above would then be redundant.