public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102879] New: [12 Regression] Dead Code Elimination Regression at -O3
@ 2021-10-21 12:51 theodort at inf dot ethz.ch
  2021-10-21 13:19 ` [Bug tree-optimization/102879] " marxin 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-21 12:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102879
           Summary: [12 Regression] Dead Code Elimination Regression 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 test.c
void foo(void);

static int b, c, d;
static char a(char e, int f) { return e < 0 ? e : e >> f; }

int main() {
  c = 2;
  for (int g = 0; g < 2; g++) {
    for (int h = 0; h < 3; h++)
      d = a(c, d == b);
    if (!d)
      foo();
  }
}


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


gcc-11 -O3 -S test.c -o /dev/stdout
...
main:
.LFB1:
        .cfi_startproc
        movl    $2, c(%rip)
        xorl    %eax, %eax
        movl    $2, d(%rip)
        ret
        .cfi_endproc

gcc-trunk test.c -S -O3 -o /dev/stdout
...
main:
.LFB1:
        .cfi_startproc
        movl    $2, %edx
        pushq   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset 3, -16
        movl    d(%rip), %ecx
        movl    $2, %ebx
        movl    $2, c(%rip)
        movsbl  %dl, %eax
        testb   %dl, %dl
        js      .L9
.L4:
        testl   %ecx, %ecx
        movl    %eax, %edx
        sete    %cl
        sarl    %cl, %edx
        testl   %edx, %edx
        movl    %eax, %edx
        sete    %cl
        sarl    %cl, %edx
        testl   %edx, %edx
        sete    %cl
        sarl    %cl, %eax
        movl    %eax, d(%rip)
        testl   %eax, %eax
        jne     .L5
        call    foo
.L5:
        cmpl    $1, %ebx
        je      .L3
.L10:
        movl    c(%rip), %edx
        movl    d(%rip), %ecx
        movl    $1, %ebx
        movsbl  %dl, %eax
        testb   %dl, %dl
        jns     .L4
.L9:
        movl    %eax, d(%rip)
        cmpl    $1, %ebx
        jne     .L10
.L3:
        xorl    %eax, %eax
        popq    %rbx
        .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 20211021 (experimental) (GCC)

Started with
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=2e96b5f14e4025691b57d2301d71aa6092ed44bc

^ 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-21 12:51 [Bug tree-optimization/102879] New: [12 Regression] Dead Code Elimination Regression at -O3 theodort at inf dot ethz.ch
2021-10-21 13:19 ` [Bug tree-optimization/102879] " marxin at gcc dot gnu.org
2021-10-21 14:09 ` aldyh at gcc dot gnu.org
2021-10-21 14:42 ` amacleod at redhat dot com
2021-10-21 20:01 ` pinskia at gcc dot gnu.org
2022-03-10  9:42 ` rguenth at gcc dot gnu.org
2022-03-10 10:06 ` rguenth at gcc dot gnu.org
2022-04-25 13:12 ` rguenth at gcc dot gnu.org
2022-05-06  8:31 ` [Bug tree-optimization/102879] [12/13 " jakub at gcc dot gnu.org
2022-07-26 13:22 ` rguenth at gcc dot gnu.org
2023-05-08 12:22 ` [Bug tree-optimization/102879] [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).