public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110841] New: [14 Regression] Dead Code Elimination Regression since r14-2675-gef28aadad6e
@ 2023-07-28 10:10 theodort at inf dot ethz.ch
  2023-07-28 13:24 ` [Bug tree-optimization/110841] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-07-28 10:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110841
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-2675-gef28aadad6e
           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/YondMzhT8

Given the following code:

void foo(void);
static int b, c, d;
static char(a)(char e, char f) { return e - f; }
int main() {
    for (; b <= 4; b++)
        ;
    c = 0;
    for (; c >= -16; c = a(c, 4))
        ;
    char g = b;
    for (; d <= 0; d++) {
        if (!(((g) >= 5) && ((g) <= 5))) {
            __builtin_unreachable();
        }
        if (c) return 0;
        g = 0;
        for (;;) {
            foo();
            break;
        }
    }
}

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

main:
        cmpl    $4, b(%rip)
        jg      .L2
        movl    $5, b(%rip)
.L2:
        movl    $-20, c(%rip)
        movl    d(%rip), %ecx
        testl   %ecx, %ecx
        jg      .L10
        cmpl    $0, c(%rip)
        jne     .L10
        pushq   %rax
        jmp     .L11
        .p2align 4,,10
        .p2align 3
.L3:
        movl    c(%rip), %edx
        testl   %edx, %edx
        jne     .L5
.L11:
        call    foo
        movl    d(%rip), %eax
        addl    $1, %eax
        movl    %eax, d(%rip)
        testl   %eax, %eax
        jle     .L3
.L5:
        xorl    %eax, %eax
        addq    $8, %rsp
        ret
.L10:
        xorl    %eax, %eax
        ret

gcc-13.2.0 -O2 eliminates the call to foo:

main:
        cmpl    $4, b(%rip)
        jg      .L2
        movl    $5, b(%rip)
.L2:
        movl    $-20, c(%rip)
        xorl    %eax, %eax
        ret

Bisects to r14-2675-gef28aadad6e

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

end of thread, other threads:[~2024-03-04  4:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28 10:10 [Bug tree-optimization/110841] New: [14 Regression] Dead Code Elimination Regression since r14-2675-gef28aadad6e theodort at inf dot ethz.ch
2023-07-28 13:24 ` [Bug tree-optimization/110841] " rguenth at gcc dot gnu.org
2023-08-07  9:16 ` pinskia at gcc dot gnu.org
2023-11-24  4:09 ` pinskia at gcc dot gnu.org
2024-01-10 14:18 ` jamborm at gcc dot gnu.org
2024-01-11  1:12 ` pinskia at gcc dot gnu.org
2024-01-13  4:39 ` cvs-commit at gcc dot gnu.org
2024-03-04  4:52 ` law 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).