From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6BEF43858D28; Tue, 20 Jun 2023 16:34:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BEF43858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687278845; bh=2XUJPjcg8P21NDGf1v5I1IvgPZKoAH/XljdTHyfq3ME=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ELhMTrEAf6J6F4XcJz5nctmpfPILCWclvc43bQ0VaDUrduTUb8X3HRuuu9A8C5NCk yAKhfYubE1zMytMidS+JhyOGtNpbkOkHli82j0KXKgQr6K1J+THs3ql9+I+enMpPqd BIjimSPFW9gUCRgA756wzXx953xQoFXH4FyxNucI= From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109943] [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-6834-g41ade3399bd Date: Tue, 20 Jun 2023 16:34:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization 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: 13.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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=3D109943 --- Comment #2 from Theodoros Theodoridis --- Not sure if it's useful but the following also started with the same commit= :=20 https://godbolt.org/z/Tqha4K976 Given the following code: void foo(void); static int d, e, h; static int *f =3D &e, *q; static int **g =3D &f; static long j, p; static short k; void __assert_fail() __attribute__((__noreturn__)); static short(a)(short b, short c) { if (!(((b) >=3D -90) && ((b) <=3D 0))) { __builtin_unreachable(); } return c =3D=3D 0 || b =3D=3D 1 && c =3D=3D 1 ?: b % c; } static int **i(); static int l(int *m, long n) { j =3D 0 >=3D d; k =3D j - 34834; if (a(-n, k)) *g =3D m; if (f =3D=3D 0 || f =3D=3D &e) ; else __assert_fail(); for (; h; ++h) ; return *m; } static int *o() { l(f, 90); g =3D i(); if (f =3D=3D 0 || f =3D=3D &e) ; else foo(); return &d; } static int **i() { a(p, h); return &q; } int main() { o(); } gcc-trunk -O2 generates: main: subq $8, %rsp movq f(%rip), %rax movq g(%rip), %rdx movq %rax, (%rdx) cmpq $e, %rax je .L7 testq %rax, %rax jne .L2 .L7: movl h(%rip), %edx testl %edx, %edx je .L5 movl $0, h(%rip) .L5: movq $q, g(%rip) cmpq $e, %rax je .L6 call foo .L6: xorl %eax, %eax addq $8, %rsp ret .L2: xorl %eax, %eax call __assert_fail gcc-12.3.0 -O2 generates: main: movq f(%rip), %rax movq g(%rip), %rdx movq %rax, (%rdx) cmpq $e, %rax je .L6 testq %rax, %rax jne .L2 .L6: movl h(%rip), %edx testl %edx, %edx je .L5 movl $0, h(%rip) .L5: movq $q, g(%rip) xorl %eax, %eax ret .L2: pushq %rax xorl %eax, %eax call __assert_fail=