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 067DB3858D20; Tue, 20 Dec 2022 04:35:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 067DB3858D20 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 (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BK4V1W6029868; Tue, 20 Dec 2022 04:35:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : references : date : in-reply-to : message-id : mime-version : content-type; s=pp1; bh=6n16PK5/3jk2k9oZBwyCaIX2ctS91QpbQaR4hHrZsF8=; b=mO1KN62h4D4Inc3OXowjzhu6SdMXQbWzC4YwUd+PFf0R24EphRLsl/PNHexL0pBdz/sj JiXOZO+KJLdS0GY9qmCsrMtwJ6prkjoJ2EUdYDi4PomCWGs6i4rxIEPRK7qMI3Qe6tBX EqyYkKxSDeB50aymcsiojT3gMB6pqJlL+1kibBGK+ZVV4yH9fyiDRCOGN3mq6WvzmTWK 2yLlDdwKpUle+MhOn8RQGaC4IuCcwC+IuVvXW5bandMi55pBPmjpI5hy16P8dFsquqXV 2Cb4cOkxNCzJcqesW7nd2tPQthuE+IzxbJVbBE+R6GR9T/FFXE8PCA+hqBvOtnbR0Afz hA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3mk63g070j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Dec 2022 04:35:56 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2BK4Z3jf017158; Tue, 20 Dec 2022 04:35:51 GMT Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3mk63g0505-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Dec 2022 04:35:51 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2BK2NEdM017403; Tue, 20 Dec 2022 04:35:16 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([9.208.129.114]) by ppma01wdc.us.ibm.com (PPS) with ESMTPS id 3mh6yxj608-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Dec 2022 04:35:16 +0000 Received: from smtpav01.dal12v.mail.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2BK4ZFHj53215608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Dec 2022 04:35:15 GMT Received: from smtpav01.dal12v.mail.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5044458057; Tue, 20 Dec 2022 04:35:15 +0000 (GMT) Received: from smtpav01.dal12v.mail.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D0BF58059; Tue, 20 Dec 2022 04:35:15 +0000 (GMT) Received: from pike (unknown [9.5.12.127]) by smtpav01.dal12v.mail.com (Postfix) with ESMTPS; Tue, 20 Dec 2022 04:35:15 +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 V7] rs6000: Optimize cmp on rotated 16bits constant References: <20221219140645.34011-1-guojiufu@linux.ibm.com> <20221219163355.GO25951@gate.crashing.org> Date: Tue, 20 Dec 2022 12:35:11 +0800 In-Reply-To: <20221219163355.GO25951@gate.crashing.org> (Segher Boessenkool's message of "Mon, 19 Dec 2022 10:33:55 -0600") Message-ID: <7er0wuhev4.fsf@pike.rch.stglabs.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -2cSj6SvZeNcYWXdpx0YrMsQYS1Y29vm X-Proofpoint-ORIG-GUID: Uo7ODlruXfrZdSv2CsGo1qNOZvFqnflK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-19_05,2022-12-15_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 mlxlogscore=750 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212200038 X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP 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, Thanks for your review, and helpful comments! Segher Boessenkool writes: > Hi! > > Mostlt nitpicking left: > > On Mon, Dec 19, 2022 at 10:06:45PM +0800, Jiufu Guo wrote: >> When checking eq/ne with a constant which has only 16bits, it can be >> optimized to check the rotated data. By this, the constant building >> is optimized. >> >> As the example in PR103743: >> For "in == 0x8000000000000000LL", this patch generates: >> rotldi 3,3,1 ; cmpldi 0,3,1 >> instead of: >> li 9,-1 ; rldicr 9,9,0,0 ; cmpd 0,3,9 > > Excellent :-) > >> * config/rs6000/rs6000-protos.h (can_be_rotated_to_lowbits): New. >> (can_be_rotated_to_positive_16bits): New. >> (can_be_rotated_to_negative_15bits): New. >> * config/rs6000/rs6000.cc (can_be_rotated_to_lowbits): New definition. >> (can_be_rotated_to_positive_16bits): New definition. >> (can_be_rotated_to_negative_15bits): New definition. >> * config/rs6000/rs6000.md (*rotate_on_cmpdi): New define_insn_and_split. > > Good names. Great function comments as well. > >> +/* Check if C (as 64bit integer) can be rotated to a constant which constains >> + nonzero bits at LOWBITS only. > > "at the LOWBITS low bits only". Well it probably is clear what is > meant :-) Update. Thanks :) > >> + Return true if C can be rotated to such constant. And *ROT is written to >> + the number by which C is rotated. >> + Return false otherwise. */ > > "If so, *ROT is written" etc. Great. Updated. > >> +(define_code_iterator eqne [eq ne]) > > You should say in the changelog that "eqne" was moved. > "(eqne): Move earlier." is plenty of course. Sure, thanks! Update. > >> +(define_insn_and_split "*rotate_on_cmpdi" > >> + rtx note = find_reg_note (curr_insn, REG_BR_PROB, 0); > > Move this much later please, to just before it is used. Oh, thanks! Update. > >> + /* keep the probability info for the prediction of the branch insn. */ > > "Keep", sentences start with a capital. Update. > >> +} >> +) > > These go on one line, as just > }) Updated. > >> --- /dev/null >> +++ b/gcc/testsuite/gcc.target/powerpc/pr103743.c >> @@ -0,0 +1,52 @@ >> +/* { dg-options "-O2" } */ >> +/* { dg-do compile { target has_arch_ppc64 } } */ >> + >> +/* { dg-final { scan-assembler-times {\mcmpldi\M} 10 } } */ >> +/* { dg-final { scan-assembler-times {\mcmpdi\M} 4 } } */ >> +/* { dg-final { scan-assembler-times {\mrotldi\M} 14 } } */ >> + > > With so much going on in just one function, I am a bit worried that this > testcase will easily fail in the future. We will see. Thanks for pointing out this. I understand your concern! I would pay attention to this. > > Okay for trunk with those i's dotted. Thank you! Updated and committed via r13-4803-g1060cd2ad00b51. BR, Jeff (Jiufu) > > > Segher