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/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0)
Date: Tue, 10 Jan 2023 12:41:27 +0000	[thread overview]
Message-ID: <bug-108354-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 108354
           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 54229
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54229&action=edit
presented code as file

cat case.c #617
int b;
int *c;
int e;
static int *f = &e;
int g;
void foo();
short(a)(short h, short i) { return h - i; }
int(d)(int h) { return h == 83647 ? 0 : -h; }
int main() {
  short j;
  int *k = &e, *l = &b;
  *f = 0 == c;
  j = a(0 != 2, *k);
  if (d(j ^ (0 == l || *k)) != *k)
    ;
  else
    foo();
  c = &g;
}

`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:
.LFB2:
        .cfi_startproc
        xorl    %eax, %eax
        cmpq    $0, c(%rip)
        setne   %dl
        sete    %al
        movzbl  %dl, %edx
        movl    %eax, e(%rip)
        orl     %eax, %edx
        je      .L12
        movq    $g, c(%rip)
        xorl    %eax, %eax
        ret
.L12:
        pushq   %rax
        .cfi_def_cfa_offset 16
        xorl    %eax, %eax
        call    foo
        xorl    %eax, %eax
        movq    $g, c(%rip)
        popq    %rdx
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------


`gcc-releases/gcc-12.2.0 -O2 -S -o /dev/stdout case.c`
--------- OUTPUT ---------
main:
.LFB2:
        .cfi_startproc
        xorl    %eax, %eax
        cmpq    $0, c(%rip)
        movq    $g, c(%rip)
        sete    %al
        movl    %eax, e(%rip)
        xorl    %eax, %eax
        ret
---------- END OUTPUT ---------


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

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

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 12:41 yann at ywg dot ch [this message]
2023-01-10 14:44 ` [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16 marxin at gcc dot gnu.org
2023-01-31  4:33 ` pinskia at gcc dot gnu.org
2023-01-31  4:52 ` pinskia at gcc dot gnu.org
2023-01-31  8:23 ` pinskia at gcc dot gnu.org
2023-01-31 20:01 ` pinskia at gcc dot gnu.org
2023-01-31 20:06 ` pinskia at gcc dot gnu.org
2023-01-31 20:07 ` pinskia at gcc dot gnu.org
2023-02-14 21:47 ` pinskia at gcc dot gnu.org
2023-02-14 21:48 ` pinskia 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-108354-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).