public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102546] New: Missed Dead Code Elimination regression (trunk vs 11.2.0) at -O3
@ 2021-09-30 13:22 theodort at inf dot ethz.ch
  2021-09-30 13:22 ` [Bug tree-optimization/102546] " theodort at inf dot ethz.ch
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: theodort at inf dot ethz.ch @ 2021-09-30 13:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102546
           Summary: Missed Dead Code Elimination regression (trunk vs
                    11.2.0) at -O3
           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 missed_case.c
static int a;
static char b, c, d;
void bar(void);
void foo(void);

int main() {
    int f = 0;
    for (; f <= 5; f++) {
        bar();
        b = b && f;
        d = f << f;
        if (!(a >= d || f))
            foo();
        c = 1;
        for (; c; c = 0)
            ;
    }
}


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

gcc-trunk -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++ 
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20210930 (experimental) (GCC)

gcc-trunk -O3 -S missed_case.c

main:
.LFB0:
        .cfi_startproc
        pushq   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset 3, -16
        xorl    %ebx, %ebx
.L6:
        call    bar
        cmpb    $0, b(%rip)
        je      .L2
        testl   %ebx, %ebx
        jne     .L5
        movb    $0, b(%rip)
        movl    $1, %ebx
        movb    $0, c(%rip)
        call    bar
        cmpb    $0, b(%rip)
        je      .L4
.L5:
        movb    $1, b(%rip)
.L4:
        addl    $1, %ebx
        movb    $0, c(%rip)
        cmpl    $6, %ebx
        jne     .L6
        xorl    %eax, %eax
        popq    %rbx
        .cfi_remember_state
        .cfi_def_cfa_offset 8
        ret
        .p2align 4,,10
        .p2align 3
.L2:
        .cfi_restore_state
        movl    %ebx, %eax
        movl    %ebx, %ecx
        sall    %cl, %eax
        testb   %al, %al
        jle     .L4
        testl   %ebx, %ebx
        jne     .L4
        call    foo
        movb    $0, c(%rip)
        movl    $1, %ebx
        call    bar
        cmpb    $0, b(%rip)
        jne     .L5
        jmp     .L2
        .cfi_endproc


gcc-11 -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++ 
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (GCC)

cat missed_case.s

main:
.LFB0:
        .cfi_startproc
        pushq   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset 3, -16
        movl    $5, %ebx
        call    bar
        movb    $0, b(%rip)
        movb    $0, c(%rip)
        .p2align 4,,10
        .p2align 3
.L2:
        call    bar
        cmpb    $0, b(%rip)
        movb    $0, c(%rip)
        setne   b(%rip)
        subl    $1, %ebx
        jne     .L2
        xorl    %eax, %eax
        popq    %rbx
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc

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

end of thread, other threads:[~2021-10-01 22:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 13:22 [Bug tree-optimization/102546] New: Missed Dead Code Elimination regression (trunk vs 11.2.0) at -O3 theodort at inf dot ethz.ch
2021-09-30 13:22 ` [Bug tree-optimization/102546] " theodort at inf dot ethz.ch
2021-09-30 17:21 ` aldyh at gcc dot gnu.org
2021-09-30 17:44 ` aldyh at gcc dot gnu.org
2021-09-30 22:50 ` [Bug tree-optimization/102546] [12 Regregression] " pinskia at gcc dot gnu.org
2021-10-01  6:30 ` rguenth at gcc dot gnu.org
2021-10-01  9:18 ` aldyh at gcc dot gnu.org
2021-10-01  9:19 ` aldyh at gcc dot gnu.org
2021-10-01  9:36 ` zhendong.su at inf dot ethz.ch
2021-10-01 13:02 ` amacleod at redhat dot com
2021-10-01 22:04 ` cvs-commit at gcc dot gnu.org
2021-10-01 22:05 ` aldyh at gcc dot gnu.org
2021-10-01 22:20 ` jakub at gcc dot gnu.org
2021-10-01 22:24 ` aldyh at redhat dot com
2021-10-01 22:38 ` jakub 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).