public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110131] New: [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r12-6924-gc2b610e7c6c
@ 2023-06-05 18:35 theodort at inf dot ethz.ch
  2023-06-05 18:47 ` [Bug tree-optimization/110131] [12/13/14 " pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-06-05 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-05-07  7:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-05 18:35 [Bug tree-optimization/110131] New: [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r12-6924-gc2b610e7c6c theodort at inf dot ethz.ch
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

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).