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

            Bug ID: 94174
           Summary: __builtin_add_overflow vs ccmp
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rth at gcc dot gnu.org
  Target Milestone: ---

(1) Case 1:

void doit(void);
void test(unsigned long a, unsigned long l)
{
  if (!__builtin_add_overflow(a, 8 - 1, &a) && a <= l)
    doit();
}

currently generates as

        adds    x0, x0, #7
        cset    x2, cs
        cmp     x0, x1
        eor     w2, w2, 1
        cset    w0, ls
        tst     w0, w2
        bne     .L22

but could be

        adds    x2, x0, #7
        ccmp    x2, x1, #0, cc
        b.ls    .L22

Reply via email to