From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 37335385801E; Thu, 17 Mar 2022 12:07:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37335385801E From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/104952] [nvptx][OpenMP] wrong code with OR / AND reduction ('reduction(||:' and '&&') with SIMT Date: Thu, 17 Mar 2022 12:07:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: openmp, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: vries 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: Thu, 17 Mar 2022 12:07:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104952 --- Comment #2 from Tom de Vries --- I think the problem can be seen already at omp-lower, in the body of the butterfly loop. Let's first look at what we have if we use reduction op '|': ... D.2173 =3D .GOMP_SIMT_VF (); D.2164 =3D 1; D.2161 =3D 0; goto ; : D.2165 =3D D.2163; D.2165 =3D D.2163; D.2166 =3D .GOMP_SIMT_XCHG_BFLY (D.2165, D.2164); D.2167 =3D D.2165 | D.2166; D.2163 =3D D.2167; D.2164 =3D D.2164 << 1; : if (D.2164 < D.2173) goto ; else goto ; : ... Fairly straightforward, we have a loop, runs a couple of times, first a shu= ffle (GOMP_SIMT_XCHG_BFLY), then an update (D.2167 =3D D.2165 | D.2166). Now compare that with reduction op '||': ... D.2183 =3D .GOMP_SIMT_VF (); D.2164 =3D 1; D.2161 =3D 0; goto ; : D.2169 =3D D.2163; D.2170 =3D (_Bool) D.2169; if (D.2170 !=3D 0) goto ; else goto ; : D.2169 =3D D.2163; D.2172 =3D .GOMP_SIMT_XCHG_BFLY (D.2169, D.2164); D.2173 =3D (_Bool) D.2172; if (D.2173 !=3D 0) goto ; else goto ; : iftmp.5 =3D 1; goto ; : iftmp.5 =3D 0; : D.2163 =3D iftmp.5; D.2164 =3D D.2164 << 1; : if (D.2164 < D.2183) goto ; else goto ; : ... The shuffle is now conditional. I think the shuffle is inserted too late, = in the middle of the update rather than before.=