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

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

            Bug ID: 103281
           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 case.c
void foo(void);

static unsigned b;

int main() {
  for (; b < 3; b++) {
    char c = b;
    char a = c ? c : c << 1;
    if (!(a < 1 ^ b))
      foo();
  }
}

trunk cannot eliminate the call to foo but 11.2.0 can:

gcc-11.2.0 -O3 -S -o /dev/stdout case.c
main:
.LFB0:
        .cfi_startproc
        movl    b(%rip), %eax
        cmpl    $2, %eax
        ja      .L6
        testl   %eax, %eax
        movl    $1, %edx
        cmove   %edx, %eax
.L8:
        addl    $1, %eax
        movl    %eax, b(%rip)
        cmpl    $2, %eax
        je      .L8
.L6:
        xorl    %eax, %eax
        ret
        .cfi_endproc


gcc-trunk -O3 -S -o /dev/stdout case.c
main:
.LFB0:
        .cfi_startproc
        movl    b(%rip), %eax
        cmpl    $2, %eax
        ja      .L13
        .p2align 4,,10
        .p2align 3
.L12:
        xorl    %edx, %edx
        testb   %al, %al
        setle   %dl
        cmpl    %eax, %edx
        je      .L16
        addl    $1, %eax
        movl    %eax, b(%rip)
        cmpl    $3, %eax
        jne     .L12
.L13:
        xorl    %eax, %eax
        ret
        .p2align 4,,10
        .p2align 3
.L16:
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
.L14:
        call    foo
        movl    b(%rip), %eax
        addl    $1, %eax
        movl    %eax, b(%rip)
        cmpl    $2, %eax
        ja      .L7
.L2:
        xorl    %edx, %edx
        testb   %al, %al
        setle   %dl
        cmpl    %eax, %edx
        je      .L14
        addl    $1, %eax
        movl    %eax, b(%rip)
        cmpl    $3, %eax
        jne     .L2
.L7:
        xorl    %eax, %eax
        popq    %rdx
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc


gcc-trunk -v
Using built-in specs.
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211116 (experimental) (GCC)

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

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

end of thread, other threads:[~2023-08-08 15:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 18:31 [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) theodort at inf dot ethz.ch
2021-11-16 20:51 ` [Bug tree-optimization/103281] [9/12 " pinskia at gcc dot gnu.org
2021-11-16 20:52 ` [Bug tree-optimization/103281] [9/10/12 " pinskia at gcc dot gnu.org
2021-11-16 21:03 ` pinskia at gcc dot gnu.org
2021-11-16 21:16 ` pinskia at gcc dot gnu.org
2021-11-18 10:31 ` marxin at gcc dot gnu.org
2022-01-18 14:28 ` rguenth at gcc dot gnu.org
2022-05-27  9:46 ` [Bug tree-optimization/103281] [10/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-05-01 23:49 ` [Bug tree-optimization/103281] [10/12/13/14 " pinskia at gcc dot gnu.org
2023-08-07  5:47 ` [Bug tree-optimization/103281] [12/13/14 " pinskia at gcc dot gnu.org
2023-08-07  6:34 ` pinskia at gcc dot gnu.org
2023-08-07  6:34 ` pinskia at gcc dot gnu.org
2023-08-08 15:42 ` cvs-commit at gcc dot gnu.org
2023-08-08 15:43 ` pinskia at gcc dot gnu.org
2023-08-08 15:46 ` 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).