public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109893] New: [14 Regression]  Missed Dead Code Elimination when using __builtin_unreachable since  r14-160-gf828503eeb79ad1f1ada6db7deccc5abcc2f3ca3
@ 2023-05-17 15:15 theodort at inf dot ethz.ch
  2023-05-17 15:29 ` [Bug tree-optimization/109893] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-05-17 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109893
           Summary: [14 Regression]  Missed Dead Code Elimination when
                    using __builtin_unreachable since
                    r14-160-gf828503eeb79ad1f1ada6db7deccc5abcc2f3ca3
           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: ---

void foo(void);
void bar(void);
static char a;
static int b, e, f;
static int *c = &b, *g;
int main() {
    int *j = 0;
    if (a) {
        g = 0;
        if (c)
            bar();
    } else {
        j = &e;
        c = 0;
    }
    if (c == &f == b || c == &e)
        ;
    else
        __builtin_unreachable();
    if (g || e) {
        if (j == &e || j == 0)
            ;
        else
            foo();
    }
    a = 4;
}

gcc -O3: 

main:
        cmpb    $0, a(%rip)
        je      .L2
        xorl    %esi, %esi
        cmpq    $0, c(%rip)
        movq    %rsi, g(%rip)
        je      .L7
        pushq   %rdx
        call    bar
        movb    $4, a(%rip)
        xorl    %eax, %eax
        popq    %rcx
        ret
.L2:
        xorl    %eax, %eax
        movq    %rax, c(%rip)
.L7:
        movb    $4, a(%rip)
        xorl    %eax, %eax
        ret
c:
        .quad   b

gcc-trunk -O3 

main:
        subq    $8, %rsp
        cmpb    $0, a(%rip)
        je      .L2
        xorl    %edx, %edx
        cmpq    $0, c(%rip)
        movq    %rdx, g(%rip)
        je      .L6
        call    bar
        xorl    %eax, %eax
.L4:
        cmpq    $0, g(%rip)
        je      .L9
.L6:
        movb    $4, a(%rip)
        xorl    %eax, %eax
        addq    $8, %rsp
        ret
.L2:
        xorl    %eax, %eax
        movq    %rax, c(%rip)
        movl    $e, %eax
        jmp     .L4
.L9:
        cmpl    $0, e(%rip)
        je      .L6
        testq   %rax, %rax
        je      .L6
        cmpq    $e, %rax
        je      .L6
        call    foo
        jmp     .L6
c:
        .quad   b

Bisects to:
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=f828503eeb79ad1f1ada6db7deccc5abcc2f3ca3

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 15:15 [Bug tree-optimization/109893] New: [14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r14-160-gf828503eeb79ad1f1ada6db7deccc5abcc2f3ca3 theodort at inf dot ethz.ch
2023-05-17 15:29 ` [Bug tree-optimization/109893] " pinskia at gcc dot gnu.org
2023-08-09  6:33 ` pinskia at gcc dot gnu.org
2024-01-12 12:53 ` rguenth at gcc dot gnu.org
2024-03-08 15:36 ` law at gcc dot gnu.org
2024-05-07  7:40 ` [Bug tree-optimization/109893] [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).