From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A44523858403; Tue, 30 Nov 2021 22:59:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A44523858403 From: "segher at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102239] powerpc suboptimal boolean test of contiguous bits Date: Tue, 30 Nov 2021 22:59:10 +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: 11.2.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: segher 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: Tue, 30 Nov 2021 22:59:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102239 --- Comment #10 from Segher Boessenkool --- (In reply to luoxhu from comment #9) > > It does matter, if what you are want to see is if it is smaller than ze= ro or > > greater than zero. CCmode includes those things. There is a CCEQmode = for > > if only the EQ bit is set correctly. >=20 > Got it, thanks. As the example in c#7. If CCmode is LT, rotate data to > highest bits will get negative result and set CR0 to negative, which is > unexpected.=20 CCmode is all three (or four, for non-fast FP) comparison results at once. You can use for example both LT and EQ on the same result. In CCEQmode only the EQ bit is valid. > > Some pattern that just does this as an rldicr, as a single insn. It wi= ll > > have to be excluded by the 2insn thing (it is only a single insn itself= !), > > and it will have to have comparison mode CCEQ only. >=20 > I was motivated by the clang code, and tried to rotate the data to LSB > instead, it doesn't suffer from CCmode issue again? Will this be simpler > than the combine & new pattern solution? It is incorrect, in a similar way. It also is sub-optimal, it is better to tell GCC that this pattern will be only one machine insn, so that it can consider that when choosing the best insn patterns to use. Also note the comment right before this code: /* If it is one stretch of ones, it is DImode; shift left, mask, then shift right. This generates better code than doing the masks without shifts, or shifting first right and then left. */=