From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id B15203858C2F; Thu, 25 Aug 2022 12:11:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B15203858C2F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27PBuGv8014149; Thu, 25 Aug 2022 12:11:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : in-reply-to : references : date : message-id : mime-version : content-type; s=pp1; bh=mAyNRHlsx9qbl9A3PE6Z+04ZNoqfUAX4RUHdAc6/8qg=; b=Gs0bzKcIAFOArSbS9xxsgosF1fONArVUtg4iYyB/8UCoLPs4AuxW3iMp8QPfOL1BCLVi oR/nT3qy0H3gHksdmDuFl00dujQVxrFUF/RN/lv9TSqj/m+XfUpPddbPiU5AuUwAQ44K QBUmG+OViALO3g2+1brIXNy1moPKN6RprfhvlEY8MEixR0kQfeDatKNIulUVxnPmEs9l h1MyYW4pqm+McutqhmP6XwxmTvPcuetCf4YFgU1J1u/vVLNv2w6r1JuEJun+U4hUNNfC OS25xUgaGl05wGyFiiC35VUR/yBxd6y/DhUGEyobevOBSbplTRNZo9lPdeI44d6tmhwh WQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3j68n68g28-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Aug 2022 12:11:36 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27PBwC1c022336; Thu, 25 Aug 2022 12:11:36 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3j68n68g1s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Aug 2022 12:11:36 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27PC6eTK017361; Thu, 25 Aug 2022 12:11:35 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma01dal.us.ibm.com with ESMTP id 3j2q8af9bq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Aug 2022 12:11:35 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27PCBY2I46006598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Aug 2022 12:11:34 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 859B6112063; Thu, 25 Aug 2022 12:11:34 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 48531112061; Thu, 25 Aug 2022 12:11:34 +0000 (GMT) Received: from pike (unknown [9.5.12.127]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTPS; Thu, 25 Aug 2022 12:11:34 +0000 (GMT) From: Jiufu Guo To: Segher Boessenkool 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 In-Reply-To: <20220824140722.GZ25951@gate.crashing.org> (Segher Boessenkool's message of "Wed, 24 Aug 2022 09:07:22 -0500") 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> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Date: Thu, 25 Aug 2022 20:11:31 +0800 Message-ID: <7eedx4h6a4.fsf@pike.rch.stglabs.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: rQUQCve_LSpzO6HEnopf_GsRmrt8M0Es X-Proofpoint-ORIG-GUID: y5g_UDJjod9u2vK5SGndQzuNec995Lrg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-25_05,2022-08-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 adultscore=0 mlxlogscore=661 lowpriorityscore=0 phishscore=0 spamscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208250047 X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham 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, Segher Boessenkool writes: > On Wed, Aug 24, 2022 at 03:48:49PM +0800, Jiufu Guo wrote: >> Segher Boessenkool writes: >> >> + "TARGET_POWERPC64 && !reload_completed && can_create_pseudo_p () >> > >> > reload_completed in splitters is almost always wrong. It isn't any >> > better if it is in the insn condition of a define_insn_and_split :-) >> > >> Thanks, 'can_create_pseudo_p' would be ok for this patch. >> Or just FAIL, if !can_create_pseudo_p()? > > 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. 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"))] "TARGET_POWERPC64 && num_insns_constant (operands[2], DImode) > 1 && compare_rotate_immediate_p (UINTVAL (operands[2]))" "#" "&& 1" [(pc)] >> >> + && num_insns_constant (operands[2], DImode) > 1 >> >> + && (rotate_from_leading_zeros_const (~UINTVAL (operands[2]), 49) > 0 >> >> + || rotate_from_leading_zeros_const (UINTVAL (operands[2]), 48) > 0)" >> > There must be a better way to describe this. >> Will update this. I'm thinking to replace this with a meaning function, >> maybe 'compare_rotate_immediate_p'. > > Thanks! > >> > Why is this doing a conditional branch at all? Unpredictable >> > conditional branches are extremely costly. >> This optimization needs to check whether the comparison code is ne/eq or >> not. To get the comparison code, we need to check the parent insn of >> the 'cmp' insn. This is why conditional branch patterns in used here. >> >> This patch should not change the information (about prediction) of the >> branch insn. I'm thinking of updating the patch to keep the 'note info >> REG_BR_PROB' for the branch instruction. > > Ah, good. Explain a bit about that? In a code comment or in the commit > message, whichever works best here. > Thanks! will add a comment for this. BR, Jeff(Jiufu) > Thanks! > > > Segher