public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102981] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
@ 2021-10-28  9:38 theodort at inf dot ethz.ch
  2021-10-28 11:45 ` [Bug tree-optimization/102981] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: theodort at inf dot ethz.ch @ 2021-10-28  9:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102981
           Summary: [12 Regression] Dead Code Elimination Regression at
                    -O3 (trunk vs 11.2.0)
           Product: gcc
           Version: 12.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: ---

cat test.c    
void foo(void);
void bar(void);

static int a;
static short b[2][2][2] = {1};
int main() {
  int c = 0;
  short d = 0;
  for (; d <= 1; d++) {
    if (c)
      foo();
    for (; a < 0; a++) {
      bar();
      if (!b[d][d][d])
        c = 1;
    }
  }
}


11.2.0 at -O3 can eliminate the call to foo but trunk at -O3 cannot:

gcc-11 test.c -O3 -S -o /dev/stdout
...
main:
.LFB0:
        .cfi_startproc
        movl    a(%rip), %eax
        testl   %eax, %eax
        jns     .L6
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        .p2align 4,,10
        .p2align 3
.L3:
        call    bar
        addl    $1, a(%rip)
        js      .L3
        xorl    %eax, %eax
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        ret
.L6:
        xorl    %eax, %eax
        ret
        .cfi_endproc

gcc-trunk test.c -O3 -S -o /dev/stdout
main:
.LFB0:
        .cfi_startproc
        pushq   %r12
        .cfi_def_cfa_offset 16
        .cfi_offset 12, -16
        movl    $1, %r12d
        pushq   %rbp
        .cfi_def_cfa_offset 24
        .cfi_offset 6, -24
        movl    $b, %ebp
        pushq   %rbx
        .cfi_def_cfa_offset 32
        .cfi_offset 3, -32
        xorl    %ebx, %ebx
.L2:
        movl    a(%rip), %eax
        testl   %eax, %eax
        jns     .L4
        .p2align 4,,10
        .p2align 3
.L6:
        call    bar
        cmpw    $0, 0(%rbp)
        cmove   %r12d, %ebx
        addl    $1, a(%rip)
        js      .L6
.L4:
        addq    $14, %rbp
        cmpq    $b+28, %rbp
        je      .L14
        testl   %ebx, %ebx
        je      .L2
        call    foo
        jmp     .L2
        .p2align 4,,10
        .p2align 3
.L14:
        popq    %rbx
        .cfi_def_cfa_offset 24
        xorl    %eax, %eax
        popq    %rbp
        .cfi_def_cfa_offset 16
        popq    %r12
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc

gcc-trunk -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211028 (experimental) (GCC)

It started with
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d8edfadfc7a9795b65177a50ce44fd348858e844

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

end of thread, other threads:[~2023-05-08 12:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28  9:38 [Bug tree-optimization/102981] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
2021-10-28 11:45 ` [Bug tree-optimization/102981] " rguenth at gcc dot gnu.org
2021-10-30  7:03 ` aldyh at gcc dot gnu.org
2021-10-30 17:42 ` aldyh at gcc dot gnu.org
2021-10-30 18:08 ` aldyh at gcc dot gnu.org
2021-11-04 18:47 ` law at gcc dot gnu.org
2021-11-16 20:08 ` aldyh at gcc dot gnu.org
2021-11-17  9:49 ` aldyh at gcc dot gnu.org
2021-11-23 19:19 ` aldyh at gcc dot gnu.org
2022-05-06  8:31 ` [Bug tree-optimization/102981] [12/13 " jakub at gcc dot gnu.org
2023-05-08 12:22 ` [Bug tree-optimization/102981] [12/13/14 " 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).