public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "yann at ywg dot ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/108352] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0)
Date: Tue, 10 Jan 2023 12:21:55 +0000	[thread overview]
Message-ID: <bug-108352-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2023-01-10 12:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 12:21 yann at ywg dot ch [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108352-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).