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/112542] New: [14 Regression] Dead Code Elimination Regression since r14-4280-gc3c6f30496d
Date: Wed, 15 Nov 2023 09:42:59 +0000	[thread overview]
Message-ID: <bug-112542-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 112542
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-4280-gc3c6f30496d
           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/3vj8x1bPK

Given the following code:

void foo(void);
static short b = -1;
static int c, e;
static int *f = &c;
static char g;
static char(a)(char h, int i) {
    if (!(((i) >= -1) && ((i) <= 0))) {
        __builtin_unreachable();
    }
    return h || i ? h : h < 0;
}
static void(d)(unsigned h) {
    if (!(((h) >= 0) && ((h) <= 4095017279))) {
        foo();
    }
}
int main() {
    *f = b == 0;
    g = a(c, c);
    d(g);
    d(4095017279);
    if (e) b = 0;
    a(0, b);
}

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

main:
        xorl    %eax, %eax
        cmpw    $0, b(%rip)
        sete    %al
        movl    %eax, c(%rip)
        jne     .L4
        pushq   %rax
        call    foo
        xorl    %eax, %eax
        popq    %rdx
        ret
.L4:
        xorl    %eax, %eax
        ret

gcc-13.2.0 -O3 eliminates the call to foo:

main:
        xorl    %eax, %eax
        cmpw    $0, b(%rip)
        sete    %al
        movl    %eax, c(%rip)
        xorl    %eax, %eax
        ret

Bisects to r14-4280-gc3c6f30496d

             reply	other threads:[~2023-11-15  9:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-15  9:42 theodort at inf dot ethz.ch [this message]
2023-11-15 11:59 ` [Bug tree-optimization/112542] " rguenth at gcc dot gnu.org
2023-11-15 16:48 ` pinskia at gcc dot gnu.org
2024-03-07 21:02 ` law at gcc dot gnu.org
2024-05-07  7:42 ` [Bug tree-optimization/112542] [14/15 " 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-112542-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).