On 9/26/26 12:57 PM, Andrea Pinski wrote:
On Sat, Sep 26, 2026 at 10:31 AM Dominic P<[email protected]> wrote:
The ((X + C1) | (C2 - X)) < 0 fold from r17-4207 and its variants drop the
C2 - X or -X operand, which traps on overflow under -ftrapv: for
X = INT_MIN, ((X + 3) | -X) < 0 traps at -O0 but not at -O2.  Do not
match when overflow traps.  The ABS_EXPR form from r17-4207 already
requires TYPE_OVERFLOW_UNDEFINED.
I am trying to remember the rules here but I think what this might be
doing is ok.  -ftrapv and -fsanitize=undefined are fine to remove
traps with optimizations turned on.  The only issue would be remove
the sanitization at -O0.
I think we often defer removal of a potentially trapping operation until after sanitization instrumentation has been inserted.  SO we end up with fragments like this:

     && (!sanitize_flags_p (SANITIZE_BUILTIN)
          || (cfun && (cfun->curr_properties & PROP_ssa) != 0)))


So it may be the case that we're missing that kind of clause here .
jeff

Reply via email to