public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112545] New: [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25
@ 2023-11-15 12:50 theodort at inf dot ethz.ch
  2023-11-15 13:43 ` [Bug tree-optimization/112545] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-11-15 12:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112545
           Summary: [14 Regression] Size regression when using -Os
                    starting with r14-569-g21e2ef2dc25
           Product: gcc
           Version: 14.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: ---

https://godbolt.org/z/hcq8sKhvP

Given the following code:

static struct {
    int a;
    int b;
} c;
static int d, e, g;
static short f, i;
static void h(unsigned short j) {
    c.a = i;
    if (!(((j) >= 1) && ((j) <= 65535))) {
        __builtin_unreachable();
    }
}
int main1() {
    d = 6;
    for (; d != -7; d--) {
        h(d ^ d < (0 <= 6));
        if (d >= 12)
            if (e) {
                for (; f; ++f) g = c.b;
                if (g) e = 0;
            }
    }
}

gcc-trunk -Os generates significantly more complex code:

main1:
        movl    e(%rip), %ecx
        movl    $6, %eax
        xorl    %edi, %edi
        xorl    %r8d, %r8d
        movl    c+4(%rip), %r10d
        movl    g(%rip), %esi
        xorl    %r9d, %r9d
        movl    $6, d(%rip)
        movw    f(%rip), %dx
.L2:
        cmpl    $-7, %eax
        je      .L31
        xorl    %r11d, %r11d
        testl   %eax, %eax
        setle   %r11b
        cmpw    %ax, %r11w
        jne     .L3
        testb   %r8b, %r8b
        je      .L4
        movl    %eax, d(%rip)
.L4:
        testb   %dil, %dil
        je      .L5
        movl    %ecx, e(%rip)
.L5:
        xorl    %ecx, %ecx
        movw    %dx, f(%rip)
        movl    %ecx, c(%rip)
        movl    %esi, g(%rip)
.L3:
        cmpl    $11, %eax
        jle     .L6
        testl   %ecx, %ecx
        je      .L6
.L7:
        testw   %dx, %dx
        je      .L32
        incl    %edx
        movl    %r10d, %esi
        movb    $1, %r9b
        jmp     .L7
.L32:
        testl   %esi, %esi
        je      .L6
        movb    $1, %dil
        xorl    %ecx, %ecx
.L6:
        decl    %eax
        movb    $1, %r8b
        jmp     .L2
.L31:
        testb   %r8b, %r8b
        je      .L10
        movl    $-7, d(%rip)
        testb   %dil, %dil
        je      .L11
        movl    %ecx, e(%rip)
.L11:
        xorl    %eax, %eax
        movl    %eax, c(%rip)
.L12:
        testb   %r9b, %r9b
        je      .L13
        movw    %dx, f(%rip)
        movl    %esi, g(%rip)
        jmp     .L13
.L10:
        testb   %dil, %dil
        je      .L12
        movl    %ecx, e(%rip)
        jmp     .L12
.L13:
        xorl    %eax, %eax
        ret


than gcc-13.2.0 -Os:

main1:
        movl    $-7, d(%rip)
        xorl    %eax, %eax
        movl    %eax, c(%rip)
        ret



Bisects to r14-569-g21e2ef2dc25

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-07  7:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 12:50 [Bug tree-optimization/112545] New: [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25 theodort at inf dot ethz.ch
2023-11-15 13:43 ` [Bug tree-optimization/112545] " rguenth at gcc dot gnu.org
2023-11-15 16:26 ` pinskia at gcc dot gnu.org
2024-03-07 21:01 ` law at gcc dot gnu.org
2024-03-09  5:04 ` law at gcc dot gnu.org
2024-05-07  7:42 ` [Bug tree-optimization/112545] [14/15 " rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).