From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 9A16C3858D28; Thu, 25 Aug 2022 12:35:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A16C3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 27PCYiq9006802; Thu, 25 Aug 2022 07:34:45 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 27PCYiCW006800; Thu, 25 Aug 2022 07:34:44 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 25 Aug 2022 07:34:44 -0500 From: Segher Boessenkool To: Jiufu Guo Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com, linkw@gcc.gnu.org Subject: Re: [PATCH V4] rs6000: Optimize cmp on rotated 16bits constant Message-ID: <20220825123444.GD25951@gate.crashing.org> References: <20220725132922.45470-1-guojiufu@linux.ibm.com> <20220823221854.GX25951@gate.crashing.org> <7er116gjz2.fsf@pike.rch.stglabs.ibm.com> <20220824140722.GZ25951@gate.crashing.org> <7eedx4h6a4.fsf@pike.rch.stglabs.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7eedx4h6a4.fsf@pike.rch.stglabs.ibm.com> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! On Thu, Aug 25, 2022 at 08:11:31PM +0800, Jiufu Guo wrote: > Segher Boessenkool writes: > > You usually can split fine if you cannot create new pseudos, by reusing > > existing registers. > > > > FAIL will cause an ICE: the RTL instruction does match, but will fail > > when trying to generate machine code for it. > > > Previous patch is using "gen_reg_rtx (DImode)" to generate a pseudo for > the rotated result to prevent orignal one being changed accidently. > So, an 'assert (can_create_pseudo_p ())' would catch it in after RA. It sounds like you want a define_split, not a define_insn_and_split. That is much more stomachable anyway. Anything that creates conditional branches together with compars insns belongs before RA, before sched1 even. > To enable this splitter works after RA, we may need to reserve one > register (clobber would be ok). Such as below: > > [(set (pc) > (if_then_else (eqne (match_operand:DI 1 "gpc_reg_operand" "r") > (match_operand:DI 2 "const_int_operand" "n")) > (label_ref (match_operand 0 "")) > (pc))) > (clobber (match_scratch:DI 3 "=r")) > (clobber (match_scratch:CCUNS 4 "=y"))] Yes, that is one way to do it. Another way is to reuse operand 1. A clobber is probably better in this case though :-) If this is only so combine can match things, you certainly want just a define_split, and the compare+branch in one pattern is not as bad then. Segher