public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111293] New: [14 Regression] Missed Dead Code Elimination since r14-3414-g0cfc9c953d0
@ 2023-09-05 15:01 theodort at inf dot ethz.ch
  2023-09-05 17:25 ` [Bug tree-optimization/111293] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-09-05 15:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111293
           Summary: [14 Regression] Missed Dead Code Elimination since
                    r14-3414-g0cfc9c953d0
           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/9aj7sr5d6

Given the following code:

void foo(void);
static int a, d;
static short e;
static int(f)(int b, int c) { return c == 0 ? b : b / c; }
static char g(char h) {
    char i = 1;
    int j = 8;
    e = 3;
    for (; d; ++d) {
        if (f(0 == j, e)) return a;
        for (; i; i--) {
            if (j) {
                if (e)
                    ;
                else if (a)
                    continue;
                else
                    foo();
                j = -h;
                break;
            }
            __builtin_unreachable();
            break;
        }
    }
    return 1;
}
int main() {
    g(-1);
    a = e;
}

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

main:
        subq    $8, %rsp
        movl    d(%rip), %ecx
        movl    $3, %edx
        movw    %dx, e(%rip)
        testl   %ecx, %ecx
        je      .L6
        movl    $3, %edx
        .p2align 4,,10
        .p2align 3
.L2:
        testw   %dx, %dx
        jne     .L3
        movl    a(%rip), %eax
        testl   %eax, %eax
        je      .L18
.L5:
        addl    $1, d(%rip)
        jne     .L5
.L6:
        movswl  e(%rip), %eax
        movl    %eax, a(%rip)
        xorl    %eax, %eax
        addq    $8, %rsp
        ret
        .p2align 4,,10
        .p2align 3
.L18:
        call    foo
.L3:
        addl    $1, d(%rip)
        movzwl  e(%rip), %edx
        jne     .L2
        jmp     .L6

gcc-13.2.0 -O2 eliminates the call to foo:

main:
        movl    d(%rip), %edx
        movl    $3, %eax
        movw    %ax, e(%rip)
        testl   %edx, %edx
        je      .L3
        movl    $0, d(%rip)
.L3:
        movl    $3, a(%rip)
        xorl    %eax, %eax
        ret

Bisects to r14-3414-g0cfc9c953d0

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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 15:01 [Bug tree-optimization/111293] New: [14 Regression] Missed Dead Code Elimination since r14-3414-g0cfc9c953d0 theodort at inf dot ethz.ch
2023-09-05 17:25 ` [Bug tree-optimization/111293] " pinskia at gcc dot gnu.org
2023-09-05 17:40 ` pinskia at gcc dot gnu.org
2023-09-05 17:40 ` pinskia at gcc dot gnu.org
2023-11-24 15:56 ` amacleod at redhat dot com
2024-03-07 23:21 ` law at gcc dot gnu.org
2024-04-09  9:38 ` mikael at gcc dot gnu.org
2024-04-09  9:47 ` mikael at gcc dot gnu.org
2024-05-07  7:41 ` [Bug tree-optimization/111293] [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).