public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "theodort at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/110539] New: [14 Regression] Dead Code Elimination Regression at since r14-338-g1dd154f6407
Date: Tue, 04 Jul 2023 09:38:04 +0000	[thread overview]
Message-ID: <bug-110539-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110539
           Summary: [14 Regression] Dead Code Elimination Regression at
                    since r14-338-g1dd154f6407
           Product: gcc
           Version: 14.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: ---

https://godbolt.org/z/h9vrrj5je

Given the following code:

void foo(void);
static int a, c = 1;
static short b;
static int *d = &c, *e = &a;
static int **f = &d;
void __assert_fail() __attribute__((__noreturn__));
static void g(short h) {
    if (*d)
        ;
    else {
        if (e) __assert_fail();
        if (a) {
            __builtin_unreachable();
        } else
            __assert_fail();
    }
    if ((((0, 0) || h) == h) + b) *f = 0;
}
int main() {
    int i = 0 != 10 & a;
    g(i);
    *e = 9;
    e = 0;
    if (d == 0)
        ;
    else
        foo();
    ;
}

gcc-trunk -O2 does not eliminate the call to foo:

main:
        subq    $8, %rsp
        movq    d(%rip), %rax
        movq    e(%rip), %rdx
        movl    (%rax), %edi
        testl   %edi, %edi
        jne     .L2
        xorl    %eax, %eax
        call    __assert_fail
.L2:
        xorl    %ecx, %ecx
        xorl    %esi, %esi
        movq    %rcx, d(%rip)
        cmpq    $0, d(%rip)
        movl    $9, (%rdx)
        movq    %rsi, e(%rip)
        je      .L3
        call    foo
.L3:
        xorl    %eax, %eax
        popq    %rdx
        ret

gcc-13.1.0 -O2 eliminates the call to foo:

main:
        movq    d(%rip), %rax
        movq    e(%rip), %rdx
        movl    (%rax), %esi
        testl   %esi, %esi
        jne     .L2
        pushq   %rcx
        xorl    %eax, %eax
        call    __assert_fail
.L2:
        xorl    %eax, %eax
        movq    %rax, d(%rip)
        xorl    %eax, %eax
        movl    $9, (%rdx)
        xorl    %edx, %edx
        movq    %rdx, e(%rip)
        ret

Bisects to r14-338-g1dd154f6407

             reply	other threads:[~2023-07-04  9:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04  9:38 theodort at inf dot ethz.ch [this message]
2023-07-05  6:44 ` [Bug tree-optimization/110539] " rguenth at gcc dot gnu.org
2023-07-06 21:20 ` pinskia at gcc dot gnu.org
2023-07-06 21:41 ` pinskia at gcc dot gnu.org
2023-07-06 21:45 ` pinskia at gcc dot gnu.org
2023-07-06 22:03 ` pinskia at gcc dot gnu.org
2023-07-06 22:44 ` pinskia at gcc dot gnu.org
2023-07-08  0:33 ` pinskia at gcc dot gnu.org
2023-07-11 23:13 ` pinskia at gcc dot gnu.org
2023-07-12  7:18 ` pinskia at gcc dot gnu.org
2023-07-12 17:32 ` pinskia at gcc dot gnu.org
2023-07-13 14:55 ` cvs-commit at gcc dot gnu.org
2023-07-13 14:55 ` 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-110539-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).