https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104356
--- Comment #36 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- > with System.Unsigned_Types; use System.Unsigned_Types; > > function F (X, Y : Unsigned) return Unsigned is > Z : Unsigned; > begin > if X >=2 then > return 0; > end if; > Z := Y; > if X = 1 then > Z := Y + 4; > end if; > return Z / X; > end; > and there evrp does with -O2 -gnatp optimize away the division. Indeed, I see this with GCC 11 & 12 (patched or not) but not with GCC 9 & 10. > Though that is likely the X / boolean_range_Y case which you've disabled. > In any case, I think you want to hear from Andrew/Aldy where exactly does > VRP/ranger assume UB on integer division by zero. Let's close this PR first, which is a 12 regression, and I'll open a PR for the VRP issue in 11 & 12.