public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/108352] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0)
@ 2023-01-10 12:21 yann at ywg dot ch
  2023-01-10 14:42 ` [Bug tree-optimization/108352] Dead Code Elimination Regression at -O2 since r13-1960-gd86d81a449c036 marxin at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: yann at ywg dot ch @ 2023-01-10 12:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108352
           Summary: Dead Code Elimination Regression at -O2 (trunk vs.
                    12.2.0)
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yann at ywg dot ch
  Target Milestone: ---

Created attachment 54227
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54227&action=edit
Code as file

cat case.c #30
long a;
int b;
void bar64_(void);
void foo();
int main() {
  char c = 0;
  unsigned d = 10;
  int e = 2;
  for (; d; d--) {
    bar64_();
    b = d;
    e && (c = (e = 0) != 4) > 1;
  }
  if (c < 1)
    foo();
  a = b;
}

`gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2` can not eliminate
`foo` but `gcc-releases/gcc-12.2.0 -O2` can.

`gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2 -S -o /dev/stdout
case.c`
--------- OUTPUT ---------
main:
.LFB0:
        .cfi_startproc
        pushq   %r13
        .cfi_def_cfa_offset 16
        .cfi_offset 13, -16
        movl    $1, %r13d
        pushq   %r12
        .cfi_def_cfa_offset 24
        .cfi_offset 12, -24
        movl    $2, %r12d
        pushq   %rbp
        .cfi_def_cfa_offset 32
        .cfi_offset 6, -32
        xorl    %ebp, %ebp
        pushq   %rbx
        .cfi_def_cfa_offset 40
        .cfi_offset 3, -40
        movl    $10, %ebx
        subq    $8, %rsp
        .cfi_def_cfa_offset 48
        .p2align 4,,10
        .p2align 3
.L3:
        call    bar64_
        testl   %r12d, %r12d
        movl    %ebx, b(%rip)
        cmovne  %r13d, %ebp
        xorl    %r12d, %r12d
        subl    $1, %ebx
        jne     .L3
        movl    $1, %eax
        testb   %bpl, %bpl
        je      .L10
.L4:
        movq    %rax, a(%rip)
        addq    $8, %rsp
        .cfi_remember_state
        .cfi_def_cfa_offset 40
        xorl    %eax, %eax
        popq    %rbx
        .cfi_def_cfa_offset 32
        popq    %rbp
        .cfi_def_cfa_offset 24
        popq    %r12
        .cfi_def_cfa_offset 16
        popq    %r13
        .cfi_def_cfa_offset 8
        ret
.L10:
        .cfi_restore_state
        xorl    %eax, %eax
        call    foo
        movslq  b(%rip), %rax
        jmp     .L4
---------- END OUTPUT ---------


`gcc-releases/gcc-12.2.0 -O2 -S -o /dev/stdout case.c`
--------- OUTPUT ---------
main:
.LFB0:
        .cfi_startproc
        pushq   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset 3, -16
        movl    $10, %ebx
        call    bar64_
        movl    $10, %eax
        jmp     .L3
        .p2align 4,,10
        .p2align 3
.L6:
        call    bar64_
        movl    %ebx, %eax
.L3:
        movl    %eax, b(%rip)
        subl    $1, %ebx
        jne     .L6
        movq    $1, a(%rip)
        xorl    %eax, %eax
        popq    %rbx
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------


Bisects to:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d86d81a449c03641e079f23a2b3e1b2279a162fe

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

end of thread, other threads:[~2023-01-11 12:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 12:21 [Bug tree-optimization/108352] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
2023-01-10 14:42 ` [Bug tree-optimization/108352] Dead Code Elimination Regression at -O2 since r13-1960-gd86d81a449c036 marxin at gcc dot gnu.org
2023-01-10 16:26 ` [Bug tree-optimization/108352] [13 Regression] " rguenth at gcc dot gnu.org
2023-01-11 11:14 ` rguenth at gcc dot gnu.org
2023-01-11 11:59 ` cvs-commit at gcc dot gnu.org
2023-01-11 12:07 ` 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).