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

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

            Bug ID: 110538
           Summary: [14 Regression] Dead Code Elimination Regression since
                     r14-368-ge1366a7e4ce
           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/53Ys78do1

Given the following code:

void foo(void);
static int b, d, f;
static int *c, *e = &d;
static unsigned g;
void a();
int main() {
    g = -19;
    for (; g; ++g) {
        int h = g;
        int *i = &b;
        int **j = &i;
        if (d) {
            int **k = &i;
            j = &c;
            *k = &f;
        } else
            *e = 0;
        if (!(((h) >= -19) && ((h) <= -1))) {
            __builtin_unreachable();
        }
        if (i)
            ;
        else
            a();
        if (j == &i || j == &c)
            ;
        else
            foo();
        ;
    }
}

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

main:
        subq    $24, %rsp
        movl    $-19, g(%rip)
        .p2align 4,,10
        .p2align 3
.L4:
        movl    d(%rip), %edx
        movl    $c, %eax
        testl   %edx, %edx
        jne     .L2
        leaq    8(%rsp), %rax
.L2:
        cmpq    $c, %rax
        je      .L5
        leaq    8(%rsp), %rdx
        cmpq    %rdx, %rax
        je      .L5
        call    foo
.L5:
        addl    $1, g(%rip)
        jne     .L4
        xorl    %eax, %eax
        addq    $24, %rsp
        ret

gcc-13.1.0 -O2 eliminates the call to foo:

main:
        movl    $-19, g(%rip)
        .p2align 4,,10
        .p2align 3
.L2:
        movl    g(%rip), %eax
        addl    $1, %eax
        movl    %eax, g(%rip)
        jne     .L2
        ret

Bisects to r14-368-ge1366a7e4ce

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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04  9:20 [Bug tree-optimization/110538] New: [14 Regression] Dead Code Elimination Regression since r14-368-ge1366a7e4ce theodort at inf dot ethz.ch
2023-07-05  6:43 ` [Bug tree-optimization/110538] " rguenth at gcc dot gnu.org
2023-07-07  0:27 ` pinskia at gcc dot gnu.org
2023-07-07  0:39 ` pinskia at gcc dot gnu.org
2024-03-08 15:28 ` law at gcc dot gnu.org
2024-03-09  7:13 ` law at gcc dot gnu.org
2024-05-07  7:41 ` [Bug tree-optimization/110538] [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).