public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111864] New: [14 Regression] Dead Code Elimination Regression since r14-4038-gb975c0dc3be
@ 2023-10-18 14:10 theodort at inf dot ethz.ch
  2023-10-18 15:09 ` [Bug tree-optimization/111864] " 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-10-18 14:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111864
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-4038-gb975c0dc3be
           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/PoYvWMG7T

Given the following code:

void foo(void);
static int d, g = 4, k;
static int *h, *j, *s;
static int **i = &h, **t = &s;
static int ***l = &i;
static unsigned short *m, *n;
static unsigned short **o = &n, **u = &m;
void __assert_fail() __attribute__((__noreturn__));
static short(a)(short b, int c) { return b << c; }
static int(e)(int f) {
    if (!(((f) >= 0) && ((f) <= 0))) {
        __builtin_unreachable();
    }
    return d;
}
static int ***p(int **q) {
    j = *q;
    return &i;
}
static int *r() {
    short v = a((g && p(t)) <= 0, 5);
    e(v);
    if (s) o = u;
    if (o == &m || o == &n)
        ;
    else
        __assert_fail();
    return &k;
}
int main() {
    **l = r();
    if (h)
        ;
    else
        __assert_fail();
    if (j == &g == 0)
        ;
    else
        __assert_fail();
    if (o == &m || o == &n)
        ;
    else
        foo();
    ;
}

gcc-trunk -O2 does not eliminate the call to foo:

main:
        subq    $8, %rsp
        movq    s(%rip), %rax
        movq    i(%rip), %rdx
        movq    %rax, j(%rip)
        testq   %rax, %rax
        je      .L17
        movq    $k, (%rdx)
        cmpq    $0, h(%rip)
        movq    $m, o(%rip)
        je      .L5
        cmpq    $g, %rax
        je      .L5
        movl    $m, %eax
.L10:
        cmpq    $n, %rax
        je      .L12
        cmpq    $m, %rax
        je      .L12
        call    foo
.L12:
        xorl    %eax, %eax
        addq    $8, %rsp
        ret
.L17:
        movq    o(%rip), %rax
        cmpq    $m, %rax
        je      .L18
        cmpq    $n, %rax
        jne     .L5
        movq    $k, (%rdx)
        cmpq    $0, h(%rip)
        jne     .L10
.L5:
        xorl    %eax, %eax
        call    __assert_fail
.L18:
        movq    $k, (%rdx)
        cmpq    $0, h(%rip)
        jne     .L12
        jmp     .L5

gcc-13.2.0 -O2 eliminates the call to foo:

main:
        movq    s(%rip), %rax
        movq    i(%rip), %rdx
        movq    %rax, j(%rip)
        testq   %rax, %rax
        je      .L2
        movq    $k, (%rdx)
        cmpq    $0, h(%rip)
        movq    $m, o(%rip)
        je      .L4
        cmpq    $g, %rax
        je      .L4
.L8:
        xorl    %eax, %eax
        ret
.L2:
        movq    o(%rip), %rax
        cmpq    $m, %rax
        je      .L5
        cmpq    $n, %rax
        jne     .L4
.L5:
        movq    $k, (%rdx)
        cmpq    $0, h(%rip)
        jne     .L8
.L4:
        pushq   %rax
        xorl    %eax, %eax
        call    __assert_fail

Bisects to r14-4038-gb975c0dc3be

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

end of thread, other threads:[~2024-03-15 13:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18 14:10 [Bug tree-optimization/111864] New: [14 Regression] Dead Code Elimination Regression since r14-4038-gb975c0dc3be theodort at inf dot ethz.ch
2023-10-18 15:09 ` [Bug tree-optimization/111864] " pinskia at gcc dot gnu.org
2023-10-18 16:15 ` [Bug tree-optimization/111864] [12/13/14 Regression] Dead Code Elimination Regression pinskia at gcc dot gnu.org
2024-03-07 21:04 ` law at gcc dot gnu.org
2024-03-09  5:31 ` law at gcc dot gnu.org
2024-03-15 13:25 ` aldyh 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).