public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110963] New: [14 Regression] Dead Code Elimination Regression since r14-2946-g46c8c225455
@ 2023-08-09 19:42 theodort at inf dot ethz.ch
  2023-08-09 19:43 ` [Bug tree-optimization/110963] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-08-09 19:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110963
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-2946-g46c8c225455
           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/devdMf1qd

Given the following code:

void foo(void);
static int c = 76, f, g;
static int *h, *j, *k = &g;
static int **i = &h;
static short a;
static char(l)(char b) {
    if (!(((b) >= 77) && ((b) <= 77))) {
        __builtin_unreachable();
    }
    return 0;
}
static short(m)(short d, short e) { return d + e; }
static short n(char) {
    j = *i;
    if (j == 0)
        ;
    else
        *i = 0;
    *k = 0;
    return 0;
}
static char o() {
    l(0);
    return 0;
}
static char p(int ad) {
    a = m(!0, ad);
    l(a);
    if (f) {
        *i &&n(o());
        *i = 0;
    } else
        n(0);
    if (h == &f || h == 0)
        ;
    else
        foo();
    return 0;
}
int main() {
    p(c);
    c = 8;
}

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

main:
        movl    f(%rip), %edi
        testl   %edi, %edi
        je      .L11
.L7:
        movl    $8, c(%rip)
        xorl    %eax, %eax
        ret
.L11:
        cmpq    $0, h(%rip)
        je      .L4
        xorl    %esi, %esi
        movq    %rsi, h(%rip)
.L4:
        movq    h(%rip), %rax
        xorl    %ecx, %ecx
        movl    %ecx, g(%rip)
        testq   %rax, %rax
        je      .L7
        cmpq    $f, %rax
        je      .L7
        pushq   %rax
        call    foo
        xorl    %eax, %eax
        movl    $8, c(%rip)
        popq    %rdx
        ret

gcc-13.2.0 -O3 eliminates the call to foo:

main:
        movl    f(%rip), %ecx
        movq    h(%rip), %rax
        testl   %ecx, %ecx
        jne     .L3
        testq   %rax, %rax
        je      .L4
        xorl    %edx, %edx
        movq    %rdx, h(%rip)
.L4:
        xorl    %eax, %eax
        movl    %eax, g(%rip)
.L3:
        movl    $8, c(%rip)
        xorl    %eax, %eax
        ret

Bisects to r14-2946-g46c8c225455

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

end of thread, other threads:[~2023-08-15  9:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-09 19:42 [Bug tree-optimization/110963] New: [14 Regression] Dead Code Elimination Regression since r14-2946-g46c8c225455 theodort at inf dot ethz.ch
2023-08-09 19:43 ` [Bug tree-optimization/110963] " pinskia at gcc dot gnu.org
2023-08-09 19:52 ` pinskia at gcc dot gnu.org
2023-08-10  6:51 ` rguenth at gcc dot gnu.org
2023-08-10 11:18 ` rguenth at gcc dot gnu.org
2023-08-10 11:47 ` rguenth at gcc dot gnu.org
2023-08-10 12:13 ` theodort at inf dot ethz.ch
2023-08-10 12:20 ` rguenther at suse dot de
2023-08-10 12:24 ` hubicka at gcc dot gnu.org
2023-08-15  9:23 ` cvs-commit at gcc dot gnu.org
2023-08-15  9:24 ` 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).