public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111003] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2161-g237e83e2158
@ 2023-08-12 13:53 scherrer.sv at gmail dot com
  2023-08-12 17:39 ` [Bug tree-optimization/111003] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: scherrer.sv at gmail dot com @ 2023-08-12 13:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111003
           Summary: [14 Regression] Dead Code Elimination Regression at
                    -O3 since r14-2161-g237e83e2158
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static int c, d, e, f;
static short g;
static int *h = &c;
void foo(void);
short(a)();
static unsigned b(unsigned char j, int l) { return j > l ? j : j << l; }
static int *i();
static void k(int j, unsigned char l) {
  i();
  g = f;
  f = g;
  for (; g;) {
    int m;
    d = a();
    for (; d;) {
      if (l)
        if (!(j >= -639457069 && j <= -639457069))
          if (m)
            foo();
      m = (10 != (l ^ b(j, 6))) < (0 > e);
    }
  }
}
static int *i() {
  for (; e; e = a(e, 6))
    ;
  return h;
}
int main() { k(c, c); }

gcc-8441841a1b9 (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
-----------------------------------------------------------------------
gcc-8441841a1b985d68245954af1ff023db121b0635 -O3 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB3:
        .cfi_startproc
        pushq   %r13
        .cfi_def_cfa_offset 16
        .cfi_offset 13, -16
        pushq   %r12
        .cfi_def_cfa_offset 24
        .cfi_offset 12, -24
        pushq   %rbp
        .cfi_def_cfa_offset 32
        .cfi_offset 6, -32
        pushq   %rbx
        .cfi_def_cfa_offset 40
        .cfi_offset 3, -40
        subq    $8, %rsp
        .cfi_def_cfa_offset 48
        movl    e(%rip), %edi
        movl    c(%rip), %ebx
        testl   %edi, %edi
        je      .L5
        .p2align 4,,10
        .p2align 3
.L2:
        movl    $6, %esi
        xorl    %eax, %eax
        call    a
        movswl  %ax, %edi
        movl    %edi, e(%rip)
        testl   %edi, %edi
        jne     .L2
.L5:
        movl    f(%rip), %eax
        movswl  %ax, %edx
        movw    %ax, g(%rip)
        movl    %edx, f(%rip)
        testw   %ax, %ax
        je      .L36
        movzbl  %bl, %ebp
        testb   %bl, %bl
        je      .L39
        movl    %ebp, %eax
        sall    $6, %eax
        xorl    %ebp, %eax
        cmpl    $10, %eax
        setne   %r12b
        .p2align 4,,10
        .p2align 3
.L18:
        xorl    %eax, %eax
        call    a
        cwtl
        movl    %eax, d(%rip)
        testl   %eax, %eax
        je      .L14
        cmpl    $-639457069, %ebx
        jne     .L17
.L19:
        jmp     .L19
        .p2align 4,,10
        .p2align 3
.L16:
        cmpl    $6, %ebp
        jg      .L20
        movl    e(%rip), %eax
        xorl    %r13d, %r13d
        shrl    $31, %eax
        cmpb    %al, %r12b
        setb    %r13b
        .p2align 4,,10
        .p2align 3
.L17:
        testl   %r13d, %r13d
        je      .L16
        call    foo
        movl    e(%rip), %eax
        shrl    $31, %eax
        cmpl    $6, %ebp
        setg    %dl
        xorl    %r13d, %r13d
        orl     %r12d, %edx
        cmpb    %al, %dl
        movl    d(%rip), %eax
        setb    %r13b
        testl   %eax, %eax
        jne     .L17
.L14:
        cmpw    $0, g(%rip)
        jne     .L18
.L36:
        addq    $8, %rsp
        .cfi_remember_state
        .cfi_def_cfa_offset 40
        xorl    %eax, %eax
        popq    %rbx
        .cfi_def_cfa_offset 32
        popq    %rbp
        .cfi_def_cfa_offset 24
        popq    %r12
        .cfi_def_cfa_offset 16
        popq    %r13
        .cfi_def_cfa_offset 8
        ret
.L39:
        .cfi_restore_state
        cmpl    $6, %ebp
        jg      .L7
        .p2align 4,,10
        .p2align 3
.L10:
        xorl    %eax, %eax
        call    a
        cwtl
        movl    %eax, d(%rip)
        testl   %eax, %eax
        je      .L8
.L9:
        jmp     .L9
        .p2align 4,,10
        .p2align 3
.L12:
        cmpw    $0, g(%rip)
        je      .L36
.L7:
        xorl    %eax, %eax
        call    a
        cwtl
        movl    %eax, d(%rip)
        testl   %eax, %eax
        je      .L12
.L13:
        jmp     .L13
        .p2align 4,,10
        .p2align 3
.L8:
        cmpw    $0, g(%rip)
        jne     .L10
        jmp     .L36
        .p2align 4,,10
        .p2align 3
.L20:
        cmpl    $-639457069, %ebx
        jne     .L20
        jmp     .L19
---------- END OUTPUT ---------

-----------------------------------------------------------------------
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB3:
        .cfi_startproc
        movl    e(%rip), %edi
        pushq   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset 3, -16
        movl    c(%rip), %ebx
        testl   %edi, %edi
        je      .L5
        .p2align 4,,10
        .p2align 3
.L2:
        movl    $6, %esi
        xorl    %eax, %eax
        call    a
        movswl  %ax, %edi
        movl    %edi, e(%rip)
        testl   %edi, %edi
        jne     .L2
.L5:
        movl    f(%rip), %eax
        movswl  %ax, %edx
        movw    %ax, g(%rip)
        movl    %edx, f(%rip)
        testw   %ax, %ax
        je      .L37
        movzbl  %bl, %eax
        cmpl    $6, %eax
        jg      .L6
        testb   %bl, %bl
        jne     .L7
        .p2align 4,,10
        .p2align 3
.L10:
        xorl    %eax, %eax
        call    a
        cwtl
        movl    %eax, d(%rip)
        testl   %eax, %eax
        je      .L8
.L9:
        jmp     .L9
        .p2align 4,,10
        .p2align 3
.L18:
        cmpw    $0, g(%rip)
        je      .L37
.L6:
        xorl    %eax, %eax
        call    a
        cwtl
        movl    %eax, d(%rip)
        testl   %eax, %eax
        je      .L18
        cmpl    $-639457069, %ebx
        je      .L39
.L19:
        testl   %eax, %eax
        je      .L18
        cmpl    $-639457069, %ebx
        jne     .L19
.L39:
        jmp     .L39
        .p2align 4,,10
        .p2align 3
.L8:
        cmpw    $0, g(%rip)
        jne     .L10
.L37:
        xorl    %eax, %eax
        popq    %rbx
        .cfi_remember_state
        .cfi_def_cfa_offset 8
        ret
.L7:
        .cfi_restore_state
        cmpl    $-639457069, %ebx
        je      .L15
        .p2align 4,,10
        .p2align 3
.L12:
        xorl    %eax, %eax
        call    a
        cwtl
        movl    %eax, d(%rip)
        testl   %eax, %eax
        je      .L16
.L17:
        jmp     .L17
        .p2align 4,,10
        .p2align 3
.L13:
        cmpw    $0, g(%rip)
        je      .L37
.L15:
        xorl    %eax, %eax
        call    a
        cwtl
        movl    %eax, d(%rip)
        testl   %eax, %eax
        je      .L13
.L14:
        jmp     .L14
        .p2align 4,,10
        .p2align 3
.L16:
        cmpw    $0, g(%rip)
        jne     .L12
        jmp     .L37
---------- END OUTPUT ---------

-----------------------------------------------------------------------
Bisects to r14-2161-g237e83e2158
CC to include: rguenther@suse.de

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

end of thread, other threads:[~2024-01-11  8:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-12 13:53 [Bug tree-optimization/111003] New: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2161-g237e83e2158 scherrer.sv at gmail dot com
2023-08-12 17:39 ` [Bug tree-optimization/111003] " pinskia at gcc dot gnu.org
2023-08-12 17:45 ` pinskia at gcc dot gnu.org
2023-08-14  8:03 ` rguenth at gcc dot gnu.org
2023-11-24  4:33 ` pinskia at gcc dot gnu.org
2024-01-10 14:39 ` jamborm at gcc dot gnu.org
2024-01-11  7:52 ` rguenth at gcc dot gnu.org
2024-01-11  8:15 ` cvs-commit 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).