https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104356
--- Comment #32 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Comment on attachment 52340 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52340 Tentative fix For the X / bool_range_Y is X. case I think just !flag_non_call_exceptions would be better. If @1 has boolean range and is known to be non-zero, it is known to be 1, so we should be optimizing it elsewhere, that is the constant case. Anyway, that's probably it in match.pd. path isolation is already guarding is_divmod_with_given_divisor calls with !cfun->can_throw_non_call_exceptions. >From the to me known issues that leaves VRP. As Ada expects the division by zero to trap, I guess we don't care much about the range it emits for the result, but it shouldn't be for cfun->can_throw_non_call_exceptions be undefined or single value range, because then it would be just optimized into a constant I bet. But there is also the problem that ranger doesn't walk just from stmts to its immediate uses, but also from stmts to their operand's def stmts. Can you try to rewrite the unsigned foo (unsigned x, unsigned y) { if (x >= 2) return 0; if (x == 1) y += 4; return y / x; } testcase I've posted into Ada and see if it will optimize away the division in evrp or vrp?