From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3E2813858D20; Wed, 1 May 2024 05:12:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E2813858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714540334; bh=iRmHoDAwlPA9O+PnbfWItCVwOlA50nZYfRJHL8ZfcWs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qhyMjL7EzVikFTKC3d5NfhVvB1fX6tzJmoTez9dkAe3+wQeZ2S5UDp8jCPu7BzLa3 gH5W+fzmgmsbUf0+rgZ+9vs43GzEQ7IPgjBdH99i4kx5ZdnsTypmrvlwxkRujH7lem BEE7t3jIcScGq6eIYr1ZtSc6ko9HRQnhQB9vYvjQ= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114902] [14/15 Regression] wrong code at -O3 with "-fno-tree-vrp -fno-expensive-optimizations -fno-tree-dominator-opts" on x86_64-linux-gnu Date: Wed, 01 May 2024 05:12:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: unknown X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 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=3D114902 --- Comment #4 from Andrew Pinski --- here is a reduced testcase: ``` [[gnu::noipa]] int f(int b) { int tt1 =3D ~b; int t =3D 1 & tt1; int e =3D -t; int tt =3D e >=3D -1; if (tt) return 0; __builtin_trap(); } int main() { for(int i =3D -1;i < 2; i++) f(i); } ``` Note ` -O1 -fno-tree-fre -fno-tree-forwprop -fno-tree-ccp=20 -fno-tree-dominator-opts` is needed to reproduce it with this one. The gene= rate gimple is the same between GCC 13 and 14 here. But the first difference is in combine: ``` Trying 7 -> 8: 7: {r106:SI=3Dr105:SI&0x1;clobber flags:CC;} REG_DEAD r105:SI REG_UNUSED flags:CC 8: {r107:SI=3D-r106:SI;clobber flags:CC;} REG_DEAD r106:SI REG_UNUSED flags:CC Successfully matched this instruction: (parallel [ (set (reg:SI 107 [ e_5 ]) (sign_extract:SI (reg:SI 105 [ tt1_3 ]) (const_int 1 [0x1]) (const_int 0 [0]))) (clobber (reg:CC 17 flags)) ]) allowing combination of insns 7 and 8 original costs 4 + 4 =3D 8 replacement cost 4 deferring deletion of insn with uid =3D 7. modifying insn i3 8: {r107:SI=3Dsign_extract(r105:SI,0x1,0);clobber flags:CC;} REG_DEAD r105:SI ``` This is correct but it goes down hill after like as I mentioned in comment = #2. So it does look like a latent bug after all. If someone does a bisect of this testcase, I am 99% sure you find r14-4810-ge28869670c9879 is where the failure was introduced. For the origi= nal testcase and the one in comment #1 might find a different commit due to gim= ple level being different.=