https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101373
--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Eric Botcazou from comment #12)
> > Maybe for that we just have to use the result of the call in the
> > non-throwing case.
>
> That seems to block the hoisting in all cases.
function Bar (A : access Integer; N : Integer) return Integer is
Ret : Integer := 0;
Ret2 : Integer := 0;
begin
if N /= 0 then
Ret2 := Foo (N);
Ret := A.all;
end if;
Ret := Ret + A.all;
return Ret + Ret2;
end;
seems to work as in, FAIL without the patch and PASS with it.