public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110269] New: 13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-4607-g2dc5d6b1e7e
@ 2023-06-15 16:22 theodort at inf dot ethz.ch
  2023-06-15 16:45 ` [Bug tree-optimization/110269] [13/14 " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-06-15 16:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110269
           Summary: 13/14 Regression] Missed Dead Code Elimination when
                    using __builtin_unreachable since
                    r13-4607-g2dc5d6b1e7e
           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/5qqPMsxEh

Given the following code:

void foo(void);
static int a = 1, c;
static int *b = &a;
static int **d = &b;
static int ***e = &d;
void __assert_fail() __attribute__((__noreturn__));
static int f() {
    if (a) return a;
    for (; c;) *e = 0;
    if (b) __assert_fail();
    return 6;
}
int main() {
    if (f()) {
        *d = 0;
        if (b == 0)
            ;
        else {
            __builtin_unreachable();
            __assert_fail();
        }
    }
    if (b == 0)
        ;
    else
        foo();
    ;
}

gcc-trunk -O3 generates:

main:
        subq    $8, %rsp
        movl    a(%rip), %eax
        testl   %eax, %eax
        jne     .L2
        cmpq    $0, b(%rip)
        jne     .L6
.L2:
        movq    d(%rip), %rax
        movq    $0, (%rax)
        cmpq    $0, b(%rip)
        je      .L3
        call    foo
.L3:
        xorl    %eax, %eax
        addq    $8, %rsp
        ret
.L6:
        xorl    %eax, %eax
        call    __assert_fail

gcc-12.3.0 -O3 generates:

main:
        movl    a(%rip), %edx
        testl   %edx, %edx
        jne     .L2
        cmpq    $0, b(%rip)
        jne     .L7
.L2:
        movq    d(%rip), %rax
        movq    $0, (%rax)
        xorl    %eax, %eax
        ret
.L7:
        pushq   %rax
        xorl    %eax, %eax
        call    __assert_fail

Bisects to r13-4607-g2dc5d6b1e7e

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

end of thread, other threads:[~2024-05-21  9:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-15 16:22 [Bug tree-optimization/110269] New: 13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-4607-g2dc5d6b1e7e theodort at inf dot ethz.ch
2023-06-15 16:45 ` [Bug tree-optimization/110269] [13/14 " pinskia at gcc dot gnu.org
2023-06-15 17:04 ` pinskia at gcc dot gnu.org
2023-06-16  6:49 ` rguenth at gcc dot gnu.org
2023-06-16  8:26 ` cvs-commit at gcc dot gnu.org
2023-06-16 11:46 ` [Bug tree-optimization/110269] [13 " rguenth at gcc dot gnu.org
2023-07-27  9:26 ` rguenth at gcc dot gnu.org
2024-05-13 11:33 ` rguenth at gcc dot gnu.org
2024-05-21  9:15 ` jakub 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).