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/110131] New: [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r12-6924-gc2b610e7c6c
Date: Mon, 05 Jun 2023 18:35:14 +0000	[thread overview]
Message-ID: <bug-110131-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110131
           Summary: [13/14 Regression] Missed Dead Code Elimination when
                    using __builtin_unreachable since
                    r12-6924-gc2b610e7c6c
           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/xr8Ka91rr

Given:

void foo(void);
static int a, d, g, m, *h = &a, *i = &a;
static char j, l, *n = &j;
static short k;
static short o(short b, short c) { return c == 0 || b && c == 1 ?: b / c; }
static char p(unsigned char e, char f) {
    if (!(((e) >= 1) && ((e) <= 255))) {
        __builtin_unreachable();
    }
    return e + f;
}
int main() {
    g = *h;
    *n = 0;
    int q = *i;
    l = p((k >= 0 ^ q >= k) - 1, 3);
    if (o(l >= j, g) + (unsigned)4294967291)
        o(0, d);
    else
        foo();
    p(&m != 0, 0);
}

gcc-11.4 -O2 generates:

main:
        movb    $0, j(%rip)
        xorl    %eax, %eax
        ret

but gcc-trunk -O2 generates:


main:
        movl    a(%rip), %eax
        movb    $0, j(%rip)
        cmpw    $1, %ax
        ja      .L8
.L4:
        xorl    %eax, %eax
        ret
.L8:
        cwtl
        leal    1(%rax), %edx
        cmpl    $2, %edx
        movl    $0, %edx
        cmova   %edx, %eax
        cmpl    $5, %eax
        jne     .L4
        pushq   %rax
        call    foo
        xorl    %eax, %eax
        popq    %rdx
        ret

(12 and 13 generate similar code)

Started with r12-6924-gc2b610e7c6c

             reply	other threads:[~2023-06-05 18:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05 18:35 theodort at inf dot ethz.ch [this message]
2023-06-05 18:47 ` [Bug tree-optimization/110131] [12/13/14 " pinskia at gcc dot gnu.org
2023-06-05 18:58 ` pinskia at gcc dot gnu.org
2023-06-05 19:15 ` pinskia at gcc dot gnu.org
2023-06-05 22:54 ` pinskia at gcc dot gnu.org
2023-06-06  8:33 ` rguenth at gcc dot gnu.org
2023-08-09  5:39 ` pinskia at gcc dot gnu.org
2023-08-09  6:21 ` pinskia at gcc dot gnu.org
2023-08-09 13:30 ` amacleod at redhat dot com
2023-08-10 21:56 ` pinskia at gcc dot gnu.org
2023-09-02 17:42 ` pinskia at gcc dot gnu.org
2023-09-02 17:43 ` pinskia at gcc dot gnu.org
2023-09-15 19:51 ` pinskia at gcc dot gnu.org
2024-05-07  7:40 ` [Bug tree-optimization/110131] [12/13/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-110131-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).