From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 81901383236B; Wed, 14 Dec 2022 10:28:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 81901383236B 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 (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BE9wjnn005612; Wed, 14 Dec 2022 10:28:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=ZXQf7LPl1qbomkMTNqfctMSt5WE7Jk8MogMa4ja3FIs=; b=Eu02O6O7IAHhyVLFe03TcvIAdCqYuIbuxac3NrICssvEe4yDDqasLR7peb+e/xucopxA pCAp33KeUihp0o0nW15a2H0w8JJNgyVcSgsnTBs3adGLsrvuxYBwIyeEIfUOsUbCElmZ p0m5N3YMgB6Hg9pgBjpIgjta8F2C1c4adusMh+N1pfK/VCompJ3rrgrcIKuuOzJVpbtT Mhtcgx/Rk3eXsYyn2OAw0FOyAj7foVv8McJcg8jyF/d5sqvCvhfIMBjbiS3fsbm89E9U 8Esv6u7qjxzxMiteRIRvz/aciGsYwNe6XffpdAw+Sj4fZ9GoTs3yV5d9G3n7Rxnt2MJq 2g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mfcb4grn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 10:28:06 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2BEA034d010232; Wed, 14 Dec 2022 10:28:06 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mfcb4grm3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 10:28:05 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2BDJbvBX014010; Wed, 14 Dec 2022 10:28:03 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3meyqgrnvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 10:28:03 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2BEAS0ZC47841654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Dec 2022 10:28:01 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC62020063; Wed, 14 Dec 2022 10:28:00 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E348520065; Wed, 14 Dec 2022 10:27:58 +0000 (GMT) Received: from [9.197.253.236] (unknown [9.197.253.236]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 14 Dec 2022 10:27:58 +0000 (GMT) Message-ID: <7fe25875-8301-2ebd-cbd2-4eb496b6c4ae@linux.ibm.com> Date: Wed, 14 Dec 2022 18:27:57 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH V4 1/2] rs6000: use li;x?oris to build constant Content-Language: en-US To: Jiufu Guo Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, gcc-patches@gcc.gnu.org References: <20221212013829.111739-1-guojiufu@linux.ibm.com> From: "Kewen.Lin" In-Reply-To: <20221212013829.111739-1-guojiufu@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: OBffYUyiiIR-4Zw5Q54w6rkShhJo9MLz X-Proofpoint-ORIG-GUID: 0SKgiGIZ-2PsW52ZIbzFwf2F3mWez6cg Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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-14_04,2022-12-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 impostorscore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212140080 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,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 Jeff, on 2022/12/12 09:38, Jiufu Guo via Gcc-patches wrote: > Hi, > > For constant C: > If '(c & 0xFFFFFFFF00008000ULL) == 0xFFFFFFFF00008000ULL' or say: > 32(1) || 16(x) || 1(1) || 15(x), using "li; xoris" would be ok. > > If '(c & 0xFFFFFFFF80008000ULL) == 0x80000000ULL' or say: > 32(0) || 1(1) || 15(x) || 1(0) || 15(x), we could use "li; oris" to > build constant 'C'. > > Here N(M) means N continuous bit M, x for M means it is ok for either > 1 or 0; '||' means concatenation. > > This patch update rs6000_emit_set_long_const to support those constants. > > Compare with previous version, this patch fixes conflicts with trunk. > and put li;x?oris as the first patch (lis;xoris as the second patch). > Previous version: > https://gcc.gnu.org/pipermail/gcc-patches/2022-December/607618.html > > Bootstrap and regtest pass on ppc64{,le}. > > Is this ok for trunk? > > BR, > Jeff (Jiufu) > > > PR target/106708 > > gcc/ChangeLog: > > * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Add using > "li; x?oris" to build constant. > > gcc/testsuite/ChangeLog: > > * gcc.target/powerpc/pr106708.c: New test. > > --- > gcc/config/rs6000/rs6000.cc | 36 +++++++++++++++--- > gcc/testsuite/gcc.target/powerpc/pr106708.c | 41 +++++++++++++++++++++ > 2 files changed, 71 insertions(+), 6 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708.c > > diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc > index b3a609f3aa3..8c1192a10c8 100644 > --- a/gcc/config/rs6000/rs6000.cc > +++ b/gcc/config/rs6000/rs6000.cc > @@ -10251,17 +10251,41 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c) > if (ud1 != 0) > emit_move_insn (dest, gen_rtx_IOR (DImode, temp, GEN_INT (ud1))); > } > + else if (ud4 == 0xffff && ud3 == 0xffff && (ud1 & 0x8000)) > + { > + /* li; xoris */ > + temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode); > + emit_move_insn (temp, GEN_INT (sext_hwi (ud1, 16))); > + emit_move_insn (dest, gen_rtx_XOR (DImode, temp, > + GEN_INT ((ud2 ^ 0xffff) << 16))); > + } > else if (ud3 == 0 && ud4 == 0) > { > temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode); > > gcc_assert (ud2 & 0x8000); > - emit_move_insn (temp, GEN_INT (sext_hwi (ud2 << 16, 32))); > - if (ud1 != 0) > - emit_move_insn (temp, gen_rtx_IOR (DImode, temp, GEN_INT (ud1))); > - emit_move_insn (dest, > - gen_rtx_ZERO_EXTEND (DImode, > - gen_lowpart (SImode,temp))); > + > + if (ud1 == 0) > + { > + /* lis; rldicl */ > + emit_move_insn (temp, GEN_INT (sext_hwi (ud2 << 16, 32))); > + emit_move_insn (dest, > + gen_rtx_AND (DImode, temp, GEN_INT (0xffffffff))); > + } > + else if (!(ud1 & 0x8000)) > + { > + /* li; oris */ > + emit_move_insn (temp, GEN_INT (ud1)); > + emit_move_insn (dest, > + gen_rtx_IOR (DImode, temp, GEN_INT (ud2 << 16))); > + } > + else > + { Nit: Add "/* lis; ori; rldicl */" like the other arms? > + emit_move_insn (temp, GEN_INT (sext_hwi (ud2 << 16, 32))); > + emit_move_insn (temp, gen_rtx_IOR (DImode, temp, GEN_INT (ud1))); > + emit_move_insn (dest, > + gen_rtx_AND (DImode, temp, GEN_INT (0xffffffff))); > + } > } > else if (ud1 == ud3 && ud2 == ud4) > { > diff --git a/gcc/testsuite/gcc.target/powerpc/pr106708.c b/gcc/testsuite/gcc.target/powerpc/pr106708.c > new file mode 100644 > index 00000000000..dc9ceda8367 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr106708.c > @@ -0,0 +1,41 @@ > +/* PR target/106708 */ > +/* { dg-do run } */ > +/* { dg-options "-O2 -mno-prefixed -save-temps" } */ > +/* { dg-require-effective-target has_arch_ppc64 } */ > + > +long long arr[] > + = {0xffffffff7cdeab55LL, 0x98765432LL, 0xabcd0000LL}; > + > +void __attribute__ ((__noipa__)) lixoris (long long *arg) Nit: Adding separator "_" to make the name like "li_xoris" or even "test_li_xoris" seems better to read. Also applied for the other function names "lioris" and "lisrldicl". The others look good to me. Thanks! BR, Kewen