public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102880] New: [12 Regression] Dead Code Elimination Regression at -O3
@ 2021-10-21 13:27 theodort at inf dot ethz.ch
  2021-10-21 13:46 ` [Bug tree-optimization/102880] " marxin at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: theodort at inf dot ethz.ch @ 2021-10-21 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102880
           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, e, f, ah;
static short g, ai, am, aq, as;
static char an, at, av, ax, ay;
static char a(char h, char i) { return i == 0 || h && i == 1 ? 0 : h % i; }
static void ae(int h) {
  if (a(b, h))
    foo();

}
int main() {
  ae(1);
  ay = a(0, ay);
  ax = a(g, aq);
  at = a(0, as);
  av = a(c, 1);
  an = a(am, f);
  int al = e || ((a(1, ah) && b) & d) == 2;
  ai = al;
}

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:
.LFB2:
        .cfi_startproc
        movb    $0, ay(%rip)
        xorl    %eax, %eax
        ret
        .cfi_endproc

gcc-11 -O3 -S test.c -o /dev/stdout
...
a.part.0:
.LFB3:
        .cfi_startproc
        testb   %dil, %dil
        je      .L5
        xorl    %eax, %eax
        cmpb    $1, %sil
        jne     .L5
        ret
.L5:
        movsbl  %dil, %eax
        movsbl  %sil, %esi
        cltd
        idivl   %esi
        movl    %edx, %eax
        ret
        .cfi_endproc
...
main:
.LFB2:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        xorl    %edi, %edi
        movl    $1, %esi
        call    a.part.0
        testb   %al, %al
        jne     .L18
.L9:
        movzbl  ay(%rip), %eax
        testb   %al, %al
        je      .L10
        movsbl  %al, %esi
        xorl    %edi, %edi
        call    a.part.0
.L10:
        movb    %al, ay(%rip)
        xorl    %eax, %eax
        addq    $8, %rsp
        .cfi_remember_state
        .cfi_def_cfa_offset 8
        ret
.L18:
        .cfi_restore_state
        call    foo
        jmp     .L9
        .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=b58dc0b803057c0e6032e0d9bd92cd834f72c75c

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

end of thread, other threads:[~2021-11-18  8:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 13:27 [Bug tree-optimization/102880] New: [12 Regression] Dead Code Elimination Regression at -O3 theodort at inf dot ethz.ch
2021-10-21 13:46 ` [Bug tree-optimization/102880] " marxin at gcc dot gnu.org
2021-10-22  6:56 ` pinskia at gcc dot gnu.org
2021-10-22  6:57 ` rguenth at gcc dot gnu.org
2021-10-22  8:44 ` rguenth at gcc dot gnu.org
2021-10-29  9:09 ` rguenth at gcc dot gnu.org
2021-11-11 12:42 ` rguenth at gcc dot gnu.org
2021-11-16 10:31 ` cvs-commit at gcc dot gnu.org
2021-11-16 10:32 ` cvs-commit at gcc dot gnu.org
2021-11-16 10:33 ` rguenth at gcc dot gnu.org
2021-11-17  8:41 ` clyon at gcc dot gnu.org
2021-11-17  8:47 ` pinskia at gcc dot gnu.org
2021-11-18  8:56 ` 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).