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

            Bug ID: 117006
           Summary: [15 regression] GCC trunk generates larger code than
                    GCC 14 at -Os
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dccitaliano at gmail dot com
  Target Milestone: ---

Similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116994

https://godbolt.org/z/64bxGvnrh

long patatino() {
    long x = 0;
    for (int i = 0; i < 5; ++i) {
        while (x < 10) {
            if ((x % 2 == 0 && x % 3 != 0) || (x % 5 == 0 && x > 5)) {
                if (x > 7) {
                    x += 4;
                } else {
                    x += 2;
                }
            } else {
                x += 1;
            }
            while (x % 4 == 0) {
                x += 3;
            }
        }
    }
    return x;
}


In particular, trunk generates

.L4:
        lea     rax, [rcx+4]
        lea     rdx, [rcx+2]
        cmp     rcx, 8
        cmovl   rax, rdx
        mov     rcx, rax
        jmp     .L7


instead of:

.L4:
        cmp     rcx, 7
        jle     .L6
        add     rcx, 4
        jmp     .L7
.L6:
        add     rcx, 2
        jmp     .L7

Reply via email to