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

            Bug ID: 126085
           Summary: If a in (-CST, 1-CST), then a + CST to a == (CST + 1)
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kaelfandrew at gmail dot com
  Target Milestone: ---

Created attachment 64921
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64921&action=edit
C code

https://godbolt.org/z/Pnx6jvfx7
With -O2, src_uadd_cst and src_usub_cst should optimize to a == (CST + 1).

With -O2, src_sadd_cst and src_ssub_cst should optimize to a == (CST + 1)
only if (a + CST or a - CST) does not cause signed wraparound. If it does cause
signed wraparound, then -O2 -fwrapv is needed to optimize src_sadd_cst and
src_ssub_cst.

Reply via email to