public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112542] New: [14 Regression] Dead Code Elimination Regression since r14-4280-gc3c6f30496d
@ 2023-11-15  9:42 theodort at inf dot ethz.ch
  2023-11-15 11:59 ` [Bug tree-optimization/112542] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-11-15  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15  9:42 [Bug tree-optimization/112542] New: [14 Regression] Dead Code Elimination Regression since r14-4280-gc3c6f30496d theodort at inf dot ethz.ch
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

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