From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 39A283858C2C; Mon, 29 Nov 2021 03:31:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39A283858C2C From: "luoxhu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102239] powerpc suboptimal boolean test of contiguous bits Date: Mon, 29 Nov 2021 03:31:42 +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: luoxhu 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: Mon, 29 Nov 2021 03:31:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102239 --- Comment #6 from luoxhu at gcc dot gnu.org --- (In reply to Segher Boessenkool from comment #5) > (In reply to luoxhu from comment #4) > > Simply adjust the sequence of dot instruction could produce expected co= de, > > is this correct? >=20 > No it isn't. Sorry. Sorry I don't understand what is wrong... >=20 > > foo: > > .LFB0: > > .cfi_startproc > > rldicr. 3,3,29,1 > > beq 0,.L2 >=20 > This is fine, but only because it tests the EQ bit (not the LT or GT bits= ). > So the generated RTL for this insn (the 2insn one) is not correct. The generated RTL in pr102239.c.300r.split2 is: (insn 32 8 33 2 (parallel [ (set (reg:CC 100 0 [123]) (compare:CC (and:DI (ashift:DI (reg:DI 3 3 [124]) (const_int 29 [0x1d])) (const_int -4611686018427387904 [0xc000000000000000= ])) (const_int 0 [0]))) (clobber (reg:DI 3 3 [125])) ]) "pr102239.c":4:6 238 {*rotldi3_mask_dot} (nil)) (insn 33 32 10 2 (set (reg:DI 3 3 [125]) (lshiftrt:DI (reg:DI 3 3 [125]) (const_int 29 [0x1d]))) "pr102239.c":4:6 278 {lshrdi3} (nil)) (jump_insn 10 33 11 2 (set (pc) (if_then_else (eq (reg:CC 100 0 [123]) (const_int 0 [0])) (label_ref 15) (pc))) "pr102239.c":4:6 868 {*cbranch} (int_list:REG_BR_PROB 536870916 (nil)) -> 15) rotldi3_mask_dot is what you mentioned in c#1, it is a shifted result and n= ot matter for comparing to 0: > *rotl3_mask_dot cannot do this either; the base and the dot2 of that > cannot be done, they return a shifted result, but that doesn't matter for > comparing it to 0. So we should add a specialised version. What specialized version to add?=