From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 62ACB3858D37; Wed, 20 Jul 2022 09:01:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62ACB3858D37 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106365] Miss to handle ifn .LEN_STORE in FRE Date: Wed, 20 Jul 2022 09:01:52 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: --- 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2022 09:01:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106365 --- Comment #4 from Richard Biener --- int __attribute__((noinline,noclone)) foo (int *out) { int mask[] =3D { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }; int i; for (i =3D 0; i < 32; ++i) { if (mask[i]) out[i] =3D i; } return out[7]; } testcase for x86_64 and .MASK_STORE, could be optimized to return 1. FRE sees .MASK_STORE (out_41(D), 32B, mask__7.9_47, { 0, 1, 2, 3, 4, 5, 6, 7 }); _10 =3D &mask[8] + 32; MEM [(int *)_10] =3D { 0, 1, 0, 1, 0, 1, 0, 1 }; and 'mask' having address taken makes it clobbered by .MASK_STORE. There's also the older issue that when mask is incoming but marked __restrict that isn't good enough because __restrict and calls doesn't work. The IL with .LEN_STORE might suffer similar issues at the point FRE gets to see it. We might be able to improve BB SLP to not code-gen _10 =3D &mask[8] + 32; MEM [(int *)_10] =3D { 0, 1, 0, 1, 0, 1, 0, 1 }; here, making 'mask' addressable again. I have a patch for this in testing.=