From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 23A9D3858C31; Tue, 5 Sep 2023 15:01:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23A9D3858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693926071; bh=wzwXB/qHmX7bvsd5VuDMc3FdiulFUcqNzJzqA/9HF9k=; h=From:To:Subject:Date:From; b=Yl5aQNdB4Cp8bI2cBTRn8JdmpIbIxeRipY8Z5XJyWXmSabCgFlSOPHs5l4UWAJjz1 cqRAJ6wzqVXrFIvNn2P480Ner3eq+KV6iSaerlIX1tlAkBpmcyQYGXfxqo0u0v5HFw 5fGHrXoZZdRGK1OzfvT7rFs9W0O+0g/GvyjZv5go= From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111293] New: [14 Regression] Missed Dead Code Elimination since r14-3414-g0cfc9c953d0 Date: Tue, 05 Sep 2023 15:01:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: theodort at inf dot ethz.ch X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111293 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 =3D=3D 0 ? b : b / c; } static char g(char h) { char i =3D 1; int j =3D 8; e =3D 3; for (; d; ++d) { if (f(0 =3D=3D j, e)) return a; for (; i; i--) { if (j) { if (e) ; else if (a) continue; else foo(); j =3D -h; break; } __builtin_unreachable(); break; } } return 1; } int main() { g(-1); a =3D 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=