From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 740B53857737; Thu, 15 Jun 2023 16:22:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 740B53857737 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686846137; bh=l4+AEBwkuJLTf3IExai+1c1BneWrO1fHT8c5oB5HFsE=; h=From:To:Subject:Date:From; b=FHlYbE8usMIJX6t/MNUZklYInTjZunrx/eHCOgfV8QeFCJt27OMJMe3ZCXnhp03Dn lA4gb832TtKcmbGEWv0rVN4HYrDJOYzbcsEID2tsDXNSZbzuWNnJb+rR6VHYkPddug IcsbVT6FtDvDUtsDdViJQCI+VCPbrK3j+gkioU0I= From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110269] New: 13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-4607-g2dc5d6b1e7e Date: Thu, 15 Jun 2023 16:22:17 +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=3D110269 Bug ID: 110269 Summary: 13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-4607-g2dc5d6b1e7e 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/5qqPMsxEh Given the following code: void foo(void); static int a =3D 1, c; static int *b =3D &a; static int **d =3D &b; static int ***e =3D &d; void __assert_fail() __attribute__((__noreturn__)); static int f() { if (a) return a; for (; c;) *e =3D 0; if (b) __assert_fail(); return 6; } int main() { if (f()) { *d =3D 0; if (b =3D=3D 0) ; else { __builtin_unreachable(); __assert_fail(); } } if (b =3D=3D 0) ; else foo(); ; } gcc-trunk -O3 generates: main: subq $8, %rsp movl a(%rip), %eax testl %eax, %eax jne .L2 cmpq $0, b(%rip) jne .L6 .L2: movq d(%rip), %rax movq $0, (%rax) cmpq $0, b(%rip) je .L3 call foo .L3: xorl %eax, %eax addq $8, %rsp ret .L6: xorl %eax, %eax call __assert_fail gcc-12.3.0 -O3 generates: main: movl a(%rip), %edx testl %edx, %edx jne .L2 cmpq $0, b(%rip) jne .L7 .L2: movq d(%rip), %rax movq $0, (%rax) xorl %eax, %eax ret .L7: pushq %rax xorl %eax, %eax call __assert_fail Bisects to r13-4607-g2dc5d6b1e7e=