Message ID | 20231211032604.3299841-2-guojiufu@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B01E385C40C for <patchwork@sourceware.org>; Mon, 11 Dec 2023 03:26:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 375AB385DC38; Mon, 11 Dec 2023 03:26:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 375AB385DC38 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 375AB385DC38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702265196; cv=none; b=bt9oOAjRGYhEODmPEQgk0oe30vPNIoVShcC1+3bj1Qdcy0aDA4U1Ok5Lq6Y/Xz8FBf6xqJE2WnBI1a6QKuWhZknNXlSgMJNA7FvLWg5zI3lrMt2ZCDl7VId5S/EkVvTGqT15Iymc5bMlPd4EY2sCf/035qWwbcb0+uUc4otteek= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702265196; c=relaxed/simple; bh=tuD7VFHDGNMmXRLpxJ7AWrAXgRK+N0QoDs4j9ldhdXo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=JEvGb0bhsycfXAhc6ajdb+G25dDG/rg5V3vkMNhLR4nCkQkXaaI8/YsvacovlFt5gPvLPmGjHX/k+IdHdo7bEGsaKdoCH+D7BVQ2AbVrnCfstC1fHgfcNkv2z3EN/0QPIw1NhLgtp/zRrl94khdMdYsvl7up158eBVtFZZ0GeLo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BAN5CDf005442; Mon, 11 Dec 2023 03:26:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=pTkgTMetD85MO9KuHwFyRnMsjNFWTbyWpggg2dUTjvY=; b=MC1nlcpw2hG9rdTmA+Awe+cNJFT4iFYuoW25XeLRBw4fZktwrEH6HOGni9N85I+FMlHM 45PahGudoL4mQWO0IUkql/AxYjVAbVfs6JJERW8DgqBMIHMuu/A+5r/25cx1LSXj9YeJ eHQqKwuWsk963GSweiij432P0TQC+QnW1nj5oKHOd1/hbRymEyOciRjZpT62Rxy0z5EF 8XRLoBtAWzZKd+MOtudkLUDAZc/9TiRYJPhBpFJjsvs5dbafQGcPTR6I2viQ9H260hWw tt9K21bMWqPOcXyFlqdbWCC5csVRRj/5281X+mjVcyydGHFGdb6HDH0U/kZrvF6U6shh Jg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uvtck532m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 03:26:33 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BB3N7A4000411; Mon, 11 Dec 2023 03:26:33 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uvtck52yb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 03:26:33 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BAGjDsA014872; Mon, 11 Dec 2023 03:26:11 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uw42k9mgq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2023 03:26:11 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BB3Q8B915073830 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Dec 2023 03:26:08 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C0BD20043; Mon, 11 Dec 2023 03:26:08 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D74A20040; Mon, 11 Dec 2023 03:26:07 +0000 (GMT) Received: from genoa.aus.stglabs.ibm.com (unknown [9.40.192.157]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 11 Dec 2023 03:26:06 +0000 (GMT) From: Jiufu Guo <guojiufu@linux.ibm.com> To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, bergner@linux.ibm.com, guojiufu@linux.ibm.com Subject: [PATCH V4 2/3] Using pli for constant splitting Date: Mon, 11 Dec 2023 11:26:04 +0800 Message-Id: <20231211032604.3299841-2-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231211032604.3299841-1-guojiufu@linux.ibm.com> References: <20231211032604.3299841-1-guojiufu@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: svL9bwhY19Kl7m7A9zFJtTTBKDfY-6oq X-Proofpoint-GUID: YplHZpQFjL0m1f6VomwHPouJpgGcQEJC Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-10_16,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 clxscore=1015 suspectscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312110028 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org |
Series |
[V4,1/3] rs6000: accurate num_insns_constant_gpr
|
|
Commit Message
Jiufu Guo
Dec. 11, 2023, 3:26 a.m. UTC
Hi, For constant building e.g. r120=0x66666666, which does not fit 'li or lis', 'pli' is used to build this constant via 'emit_move_insn'. While for a complicated constant, e.g. 0x6666666666666666ULL, when using 'rs6000_emit_set_long_const' to split the constant recursively, it fails to use 'pli' to build the half part constant: 0x66666666. 'rs6000_emit_set_long_const' could be updated to use 'pli' to build half part of the constant when necessary. For example: 0x6666666666666666ULL, "pli 3,1717986918; rldimi 3,3,32,0" can be used. Compare with previous: https://gcc.gnu.org/pipermail/gcc-patches/2023-December/639492.html This verion is refreshed and updated testcase name. Bootstrap®test pass on ppc64{,le}. Is this ok for trunk? BR, Jeff (Jiufu Guo) gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Add code to use pli for 34bit constant. gcc/testsuite/ChangeLog: * gcc.target/powerpc/const-build-1.c: New test. --- gcc/config/rs6000/rs6000.cc | 9 ++++++++- gcc/testsuite/gcc.target/powerpc/const-build-1.c | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/const-build-1.c
Comments
Hi, on 2023/12/11 11:26, Jiufu Guo wrote: > Hi, > > For constant building e.g. r120=0x66666666, which does not fit 'li or lis', > 'pli' is used to build this constant via 'emit_move_insn'. > > While for a complicated constant, e.g. 0x6666666666666666ULL, when using > 'rs6000_emit_set_long_const' to split the constant recursively, it fails to > use 'pli' to build the half part constant: 0x66666666. > > 'rs6000_emit_set_long_const' could be updated to use 'pli' to build half > part of the constant when necessary. For example: 0x6666666666666666ULL, > "pli 3,1717986918; rldimi 3,3,32,0" can be used. > > Compare with previous: > https://gcc.gnu.org/pipermail/gcc-patches/2023-December/639492.html > This verion is refreshed and updated testcase name. > > Bootstrap®test pass on ppc64{,le}. > Is this ok for trunk? OK for trunk, thanks! BR, Kewen > > BR, > Jeff (Jiufu Guo) > > gcc/ChangeLog: > > * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Add code to use > pli for 34bit constant. > > gcc/testsuite/ChangeLog: > > * gcc.target/powerpc/const-build-1.c: New test. > > --- > gcc/config/rs6000/rs6000.cc | 9 ++++++++- > gcc/testsuite/gcc.target/powerpc/const-build-1.c | 9 +++++++++ > 2 files changed, 17 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/powerpc/const-build-1.c > > diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc > index 017000a4e02..531c40488b4 100644 > --- a/gcc/config/rs6000/rs6000.cc > +++ b/gcc/config/rs6000/rs6000.cc > @@ -10511,7 +10511,14 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c, int *num_insns) > emit_insn (dest_or_insn); > }; > > - if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000)) > + if (TARGET_PREFIXED && SIGNED_INTEGER_34BIT_P (c)) > + { > + /* li/lis/pli */ > + count_or_emit_insn (dest, GEN_INT (c)); > + return; > + } > + > + if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000)) > || (ud4 == 0 && ud3 == 0 && ud2 == 0 && !(ud1 & 0x8000))) > { > /* li */ > diff --git a/gcc/testsuite/gcc.target/powerpc/const-build-1.c b/gcc/testsuite/gcc.target/powerpc/const-build-1.c > new file mode 100644 > index 00000000000..7e35f8c507f > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/const-build-1.c > @@ -0,0 +1,9 @@ > +/* { dg-do compile { target lp64 } } */ > +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ > +/* { dg-require-effective-target power10_ok } */ > + > +unsigned long long msk66() { return 0x6666666666666666ULL; } > + > +/* { dg-final { scan-assembler-times {\mpli\M} 1 } } */ > +/* { dg-final { scan-assembler-not {\mli\M} } } */ > +/* { dg-final { scan-assembler-not {\mlis\M} } } */
Hi, "Kewen.Lin" <linkw@linux.ibm.com> writes: > Hi, > > on 2023/12/11 11:26, Jiufu Guo wrote: >> Hi, >> >> For constant building e.g. r120=0x66666666, which does not fit 'li or lis', >> 'pli' is used to build this constant via 'emit_move_insn'. >> >> While for a complicated constant, e.g. 0x6666666666666666ULL, when using >> 'rs6000_emit_set_long_const' to split the constant recursively, it fails to >> use 'pli' to build the half part constant: 0x66666666. >> >> 'rs6000_emit_set_long_const' could be updated to use 'pli' to build half >> part of the constant when necessary. For example: 0x6666666666666666ULL, >> "pli 3,1717986918; rldimi 3,3,32,0" can be used. >> >> Compare with previous: >> https://gcc.gnu.org/pipermail/gcc-patches/2023-December/639492.html >> This verion is refreshed and updated testcase name. >> >> Bootstrap®test pass on ppc64{,le}. >> Is this ok for trunk? > > OK for trunk, thanks! Committed via r14-6475. Thanks for your kind review and great comments! BR, Jeff (Jiufu Guo) > > BR, > Kewen > >> >> BR, >> Jeff (Jiufu Guo) >> >> gcc/ChangeLog: >> >> * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Add code to use >> pli for 34bit constant. >> >> gcc/testsuite/ChangeLog: >> >> * gcc.target/powerpc/const-build-1.c: New test. >> >> --- >> gcc/config/rs6000/rs6000.cc | 9 ++++++++- >> gcc/testsuite/gcc.target/powerpc/const-build-1.c | 9 +++++++++ >> 2 files changed, 17 insertions(+), 1 deletion(-) >> create mode 100644 gcc/testsuite/gcc.target/powerpc/const-build-1.c >> >> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc >> index 017000a4e02..531c40488b4 100644 >> --- a/gcc/config/rs6000/rs6000.cc >> +++ b/gcc/config/rs6000/rs6000.cc >> @@ -10511,7 +10511,14 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c, int *num_insns) >> emit_insn (dest_or_insn); >> }; >> >> - if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000)) >> + if (TARGET_PREFIXED && SIGNED_INTEGER_34BIT_P (c)) >> + { >> + /* li/lis/pli */ >> + count_or_emit_insn (dest, GEN_INT (c)); >> + return; >> + } >> + >> + if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000)) >> || (ud4 == 0 && ud3 == 0 && ud2 == 0 && !(ud1 & 0x8000))) >> { >> /* li */ >> diff --git a/gcc/testsuite/gcc.target/powerpc/const-build-1.c b/gcc/testsuite/gcc.target/powerpc/const-build-1.c >> new file mode 100644 >> index 00000000000..7e35f8c507f >> --- /dev/null >> +++ b/gcc/testsuite/gcc.target/powerpc/const-build-1.c >> @@ -0,0 +1,9 @@ >> +/* { dg-do compile { target lp64 } } */ >> +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ >> +/* { dg-require-effective-target power10_ok } */ >> + >> +unsigned long long msk66() { return 0x6666666666666666ULL; } >> + >> +/* { dg-final { scan-assembler-times {\mpli\M} 1 } } */ >> +/* { dg-final { scan-assembler-not {\mli\M} } } */ >> +/* { dg-final { scan-assembler-not {\mlis\M} } } */
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 017000a4e02..531c40488b4 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -10511,7 +10511,14 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c, int *num_insns) emit_insn (dest_or_insn); }; - if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000)) + if (TARGET_PREFIXED && SIGNED_INTEGER_34BIT_P (c)) + { + /* li/lis/pli */ + count_or_emit_insn (dest, GEN_INT (c)); + return; + } + + if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000)) || (ud4 == 0 && ud3 == 0 && ud2 == 0 && !(ud1 & 0x8000))) { /* li */ diff --git a/gcc/testsuite/gcc.target/powerpc/const-build-1.c b/gcc/testsuite/gcc.target/powerpc/const-build-1.c new file mode 100644 index 00000000000..7e35f8c507f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/const-build-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ +/* { dg-require-effective-target power10_ok } */ + +unsigned long long msk66() { return 0x6666666666666666ULL; } + +/* { dg-final { scan-assembler-times {\mpli\M} 1 } } */ +/* { dg-final { scan-assembler-not {\mli\M} } } */ +/* { dg-final { scan-assembler-not {\mlis\M} } } */