public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110539] New: [14 Regression] Dead Code Elimination Regression at since r14-338-g1dd154f6407
@ 2023-07-04  9:38 theodort at inf dot ethz.ch
  2023-07-05  6:44 ` [Bug tree-optimization/110539] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-07-04  9:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110539
           Summary: [14 Regression] Dead Code Elimination Regression at
                    since r14-338-g1dd154f6407
           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/h9vrrj5je

Given the following code:

void foo(void);
static int a, c = 1;
static short b;
static int *d = &c, *e = &a;
static int **f = &d;
void __assert_fail() __attribute__((__noreturn__));
static void g(short h) {
    if (*d)
        ;
    else {
        if (e) __assert_fail();
        if (a) {
            __builtin_unreachable();
        } else
            __assert_fail();
    }
    if ((((0, 0) || h) == h) + b) *f = 0;
}
int main() {
    int i = 0 != 10 & a;
    g(i);
    *e = 9;
    e = 0;
    if (d == 0)
        ;
    else
        foo();
    ;
}

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

main:
        subq    $8, %rsp
        movq    d(%rip), %rax
        movq    e(%rip), %rdx
        movl    (%rax), %edi
        testl   %edi, %edi
        jne     .L2
        xorl    %eax, %eax
        call    __assert_fail
.L2:
        xorl    %ecx, %ecx
        xorl    %esi, %esi
        movq    %rcx, d(%rip)
        cmpq    $0, d(%rip)
        movl    $9, (%rdx)
        movq    %rsi, e(%rip)
        je      .L3
        call    foo
.L3:
        xorl    %eax, %eax
        popq    %rdx
        ret

gcc-13.1.0 -O2 eliminates the call to foo:

main:
        movq    d(%rip), %rax
        movq    e(%rip), %rdx
        movl    (%rax), %esi
        testl   %esi, %esi
        jne     .L2
        pushq   %rcx
        xorl    %eax, %eax
        call    __assert_fail
.L2:
        xorl    %eax, %eax
        movq    %rax, d(%rip)
        xorl    %eax, %eax
        movl    $9, (%rdx)
        xorl    %edx, %edx
        movq    %rdx, e(%rip)
        ret

Bisects to r14-338-g1dd154f6407

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

end of thread, other threads:[~2023-07-13 14:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04  9:38 [Bug tree-optimization/110539] New: [14 Regression] Dead Code Elimination Regression at since r14-338-g1dd154f6407 theodort at inf dot ethz.ch
2023-07-05  6:44 ` [Bug tree-optimization/110539] " rguenth at gcc dot gnu.org
2023-07-06 21:20 ` pinskia at gcc dot gnu.org
2023-07-06 21:41 ` pinskia at gcc dot gnu.org
2023-07-06 21:45 ` pinskia at gcc dot gnu.org
2023-07-06 22:03 ` pinskia at gcc dot gnu.org
2023-07-06 22:44 ` pinskia at gcc dot gnu.org
2023-07-08  0:33 ` pinskia at gcc dot gnu.org
2023-07-11 23:13 ` pinskia at gcc dot gnu.org
2023-07-12  7:18 ` pinskia at gcc dot gnu.org
2023-07-12 17:32 ` pinskia at gcc dot gnu.org
2023-07-13 14:55 ` cvs-commit at gcc dot gnu.org
2023-07-13 14:55 ` pinskia 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).