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

            Bug ID: 109213
           Summary: [13 Regression] -Os generates significantly more code
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: theodort at inf dot ethz.ch
  Target Milestone: ---

Input C-code:

static char g, d[5] = {0};
static int f = 0, *e;
static void b(int) {};

static int i() {
    for (int j =0; j < 1; j +=1)
        f = 0;
    return 0;
}

static void m() {
    int n[10];
    int o[56] = {};
    for (int h = 0; h < 3; h++)
        if (d[h])
            for (; f; f++)
                if (n[0])
                    break;

    int *r[] = {&o[0]};
}


int main() {
    int p[10] = {};
    m();
    if (!i()) {
        int *q = &p[0];
        for (; g;)
            b(e == q);
    }
}

-----------------------------------------------------
12.2 -Os:

main:
        xorl    %eax, %eax
        movl    %eax, f(%rip)
        xorl    %eax, %eax
        ret

-----------------------------------------------------
trunk -Os: 

m:
        movl    f(%rip), %eax
        xorl    %edx, %edx
        xorl    %ecx, %ecx
.L5:
        cmpb    $0, d(%rdx)
        je      .L2
        movl    -40(%rsp), %esi
.L3:
        testl   %eax, %eax
        je      .L2
        testl   %esi, %esi
        jne     .L2
        incl    %eax
        movb    $1, %cl
        jmp     .L3
.L2:
        incq    %rdx
        cmpq    $3, %rdx
        jne     .L5
        testb   %cl, %cl
        je      .L1
        movl    %eax, f(%rip)
.L1:
        ret
main:
        xorl    %eax, %eax
        call    m
        xorl    %eax, %eax
        movl    %eax, f(%rip)
        xorl    %eax, %eax
        ret
d:
        .zero   5

Reply via email to