From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 94B983857033; Fri, 5 Mar 2021 08:20:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94B983857033 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/99394] s254 benchmark of TSVC is vectorized by clang and not by gcc Date: Fri, 05 Mar 2021 08:20:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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: 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: Fri, 05 Mar 2021 08:20:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99394 --- Comment #2 from Richard Biener --- This is a loop-carried data dependence which we can't handle (we avoid crea= ting those from PRE but here it appears in the source itself). I wonder how LLVM handles this (pre/post vectorization IL). Specifically 'carry around variable' is something we don't handle. Can you somehow extract a compilable testcase (with just this kernel)? Looking at the source peeling a single iteration (to get rid of the initial value) and then undoing the PRE, vectorizing for (int i =3D 1; i < LEN_1D; i++) { a[i] =3D (b[i] + b[i-1]) * (real_t).5; } would likely result in optimal code. The assembly from clang doesn't look optimal to me - llvm likely materializes 'x' as temporary array, vectorizing x[0] =3D b[LEN_1D-1]; for (int i =3D 0; i < LEN_1D; i++) { a[i] =3D (b[i] + x[i]) * (real_t).5; x[i+1] =3D b[i]; } and then somehow (like we handle OMP simd lane arrays?) uses two vectors as a sliding window over x[]. At least the standard strathegy for these kind of dependences is to get "rid" of them by making them data dependences and then hope for the best.=