public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102705] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
@ 2021-10-12 13:41 theodort at inf dot ethz.ch
  2021-10-12 13:51 ` [Bug tree-optimization/102705] [12 Regression] Dead Code Elimination Regression at -O3 since r12-2637-g145bc41dae7c7bfa093d61e77346f98e6a595a0e marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: theodort at inf dot ethz.ch @ 2021-10-12 13:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102705
           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);
static int b;
static char c;
static short a(short d, short e) { return e == 0 || d && e == 1 ? 0 : d % e; }
int main() {
  b = c = b >= 2 ? 0 : 1 >> b;
  short f = a(0 >= 0 ^ c, 5);
  if (f == c)
    foo();
  a(0, 9);
}

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

gcc-11.2.0 test.c -S -O3 -o /dev/stdout
main:
.LFB1:
        .cfi_startproc
        movl    b(%rip), %ecx
        movl    $1, %eax
        sarl    %cl, %eax
        movl    %eax, %edx
        xorl    %eax, %eax
        cmpl    $2, %ecx
        cmovl   %edx, %eax
        movsbl  %al, %eax
        movl    %eax, b(%rip)
        xorl    %eax, %eax
        ret
        .cfi_endproc


gcc-trunk test.c -S -O3 -o /dev/stdout
main:
.LFB1:
        .cfi_startproc
        movl    b(%rip), %ecx
        cmpl    $1, %ecx
        jle     .L2
        xorl    %ecx, %ecx
        movl    %ecx, b(%rip)
.L5:
        xorl    %eax, %eax
        ret
.L2:
        movl    $1, %eax
        sarl    %cl, %eax
        movl    %eax, %edx
        movl    %eax, b(%rip)
        xorl    $1, %edx
        movsbw  %dl, %dx
        cmpw    %ax, %dx
        jne     .L5
        pushq   %rax
        .cfi_def_cfa_offset 16
        call    foo
        xorl    %eax, %eax
        popq    %rdx
        .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 20211012 (experimental) (GCC)

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

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

end of thread, other threads:[~2024-02-21  7:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 13:41 [Bug tree-optimization/102705] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
2021-10-12 13:51 ` [Bug tree-optimization/102705] [12 Regression] Dead Code Elimination Regression at -O3 since r12-2637-g145bc41dae7c7bfa093d61e77346f98e6a595a0e marxin at gcc dot gnu.org
2021-10-13  6:22 ` rguenth at gcc dot gnu.org
2021-10-13 19:25 ` amacleod at redhat dot com
2022-01-19  9:18 ` rguenth at gcc dot gnu.org
2022-05-06  8:31 ` [Bug tree-optimization/102705] [12/13 " jakub at gcc dot gnu.org
2022-10-19  9:35 ` rguenth at gcc dot gnu.org
2023-05-08 12:22 ` [Bug tree-optimization/102705] [12/13/14 " rguenth at gcc dot gnu.org
2024-02-21  7:00 ` pinskia 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).