https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125295

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2026-05-13
           Keywords|                            |wrong-code
                 CC|                            |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue with shifts (ISTR there's unfixed cases elsewhere) is that we do not
have a (cheap) way to turn it defined (we can mask the shift operand I guess).

But yes, PRE only avoids hoisting trapping instructions over calls that
might not return and PRE does not in general rewrite undefined to
not undefined variants because it doesn't change whether a stmt is
executed or not (with the exception of calls not returning ...)

In principle we could rewrite the PRE expressions (or drop them for missed
optimizations).  What we cannot easily do is know at insertion time whether
dataflow crossed such a problematical point.

Similar case:

 # _1 = PHI <_2, 0>
 check_if_1_plus_5_overflows_and_exit (_1);
 _3 = _1 + 5;

where we'd PRE _1 + 5 to 5 on the path from 0 and _2 + 5 on the path
from _2, crossing an overflow check in the function that might just
exit(0) in that case.

You can probably make a ubsan case from that.

Reply via email to