From patchwork Thu Dec 1 08:47:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiufu Guo X-Patchwork-Id: 61301 Return-Path: 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 1BF80385B190 for ; Thu, 1 Dec 2022 08:48:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BF80385B190 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669884514; bh=rABRYzNg+gK3N20mnwIuxMuRZBsHVLCirLTAG9o9p38=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=PGN6KQXjHDPROdEQkfNCnqKlYHBh0tMw6/Dnl5AjAjX8FJA0Uaa7vZm37OtDFsYRl MFx61YVOcUzgM1pihre2lfAJzWDaN8ZdcBG2RvE2Y7NhauFZNa7RZyOhlhOgW4fjt+ NQwBYh2CI94O8G9qT7/DqUCVWxIN0MWJjKCU1rFQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 8D6DF3858CDA; Thu, 1 Dec 2022 08:48:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D6DF3858CDA Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B18l0rc012699; Thu, 1 Dec 2022 08:48:01 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m6s2fg0fm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Dec 2022 08:48:00 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2B18lBQJ012923; Thu, 1 Dec 2022 08:48:00 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m6s2fg0f5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Dec 2022 08:48:00 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2B18axc7031625; Thu, 1 Dec 2022 08:47:58 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06fra.de.ibm.com with ESMTP id 3m3a2hw3rd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Dec 2022 08:47:58 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B18luDQ59638218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 1 Dec 2022 08:47:56 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 155DEA404D; Thu, 1 Dec 2022 08:47:56 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A760A4040; Thu, 1 Dec 2022 08:47:55 +0000 (GMT) Received: from pike.rch.stglabs.ibm.com (unknown [9.5.12.127]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 1 Dec 2022 08:47:55 +0000 (GMT) To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, guojiufu@linux.ibm.com Subject: [PATCH 1/2] rs6000: use lis;xoris to build constant Date: Thu, 1 Dec 2022 16:47:53 +0800 Message-Id: <20221201084754.12959-1-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _UOa02l8iit6ndSLEbHHPT_M8nFtNoC_ X-Proofpoint-ORIG-GUID: cLUBM7bvCrQZjZi4R90lHKFLkUwD0rSR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-01_04,2022-11-30_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=727 clxscore=1015 priorityscore=1501 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212010057 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jiufu Guo via Gcc-patches From: Jiufu Guo Reply-To: Jiufu Guo Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, For constant C: If '(c & 0xFFFFFFFF0000FFFFULL) == 0xFFFFFFFF00000000' or say: 32(1) || 1(0) || 15(x) || 16(0), we could use "lis; xoris" to build. 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. 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 to build constants through "lis; xoris". gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr106708.c: New test. --- gcc/config/rs6000/rs6000.cc | 7 +++++++ gcc/testsuite/gcc.target/powerpc/pr106708.c | 23 +++++++++++++++++++++ 2 files changed, 30 insertions(+) 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 1a51b79ebfe..7efed94a0bc 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -10251,6 +10251,13 @@ 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 && !(ud2 & 0x8000) && ud1 == 0) + { + /* lis; xoris */ + temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode); + emit_move_insn (temp, GEN_INT (sext_hwi ((ud2 | 0x8000) << 16, 32))); + emit_move_insn (dest, gen_rtx_XOR (DImode, temp, GEN_INT (0x80000000))); + } else if (ud3 == 0 && ud4 == 0) { temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode); diff --git a/gcc/testsuite/gcc.target/powerpc/pr106708.c b/gcc/testsuite/gcc.target/powerpc/pr106708.c new file mode 100644 index 00000000000..dd0386c109c --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr106708.c @@ -0,0 +1,23 @@ +/* PR target/106708 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mno-prefixed -save-temps" } */ +/* { dg-require-effective-target has_arch_ppc64 } */ + +long long arr[] = {0xffffffff65430000LL}; +void __attribute__ ((__noipa__)) lisxoris (long long *arg) +{ + *arg = 0xffffffff65430000LL; +} +/* { dg-final { scan-assembler-times {\mlis .*,0xe543\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mxoris .*0x8000\M} 1 } } */ + +int +main () +{ + long long a[sizeof (arr) / sizeof (arr[0])]; + + lisxoris (a); + if (__builtin_memcmp (a, arr, sizeof (arr)) != 0) + __builtin_abort (); + return 0; +} From patchwork Thu Dec 1 08:47:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiufu Guo X-Patchwork-Id: 61302 Return-Path: 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 23A313858434 for ; Thu, 1 Dec 2022 08:48:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23A313858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669884517; bh=/ShRv4JKUuMnxz6hg6xMS2Ga/nkGQvzbQs+EM5vDCRY=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=aYSbrTTd/OfBYs5H1E9vlyWb0FKnFWEdHGyHcliic1GgdQZ8dgvInCJFW79hdfdcZ Sz+V/HlN6qBfA862t2xteijD/j9EY/GzlYV84It97cxY4bAxDlAIURZxohChFiU9Sl PWtMrGIZmdrmMEvAONQKTmD24jzeN4fHvtuVCZGo= 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 93C4C3858C52; Thu, 1 Dec 2022 08:48:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 93C4C3858C52 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B18g5iv019753; Thu, 1 Dec 2022 08:48:02 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m6ryx0543-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Dec 2022 08:48:02 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2B18gPDm021067; Thu, 1 Dec 2022 08:48:01 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m6ryx0534-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Dec 2022 08:48:01 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2B18YooW025205; Thu, 1 Dec 2022 08:47:59 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma01fra.de.ibm.com with ESMTP id 3m3ae9547n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Dec 2022 08:47:59 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B18lvTE37159176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 1 Dec 2022 08:47:57 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1362BA404D; Thu, 1 Dec 2022 08:47:57 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49376A4040; Thu, 1 Dec 2022 08:47:56 +0000 (GMT) Received: from pike.rch.stglabs.ibm.com (unknown [9.5.12.127]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 1 Dec 2022 08:47:56 +0000 (GMT) To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, guojiufu@linux.ibm.com Subject: [PATCH 2/2] rs6000: use li;x?oris to build constant Date: Thu, 1 Dec 2022 16:47:54 +0800 Message-Id: <20221201084754.12959-2-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221201084754.12959-1-guojiufu@linux.ibm.com> References: <20221201084754.12959-1-guojiufu@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: hIc_IR5cKAGyHdyrouOueV9Hfe5nc6QI X-Proofpoint-ORIG-GUID: SvGo7AL0oOV8yx_S5xa6qnbf9dMRImLG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-01_04,2022-11-30_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=710 priorityscore=1501 clxscore=1015 spamscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212010057 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jiufu Guo via Gcc-patches From: Jiufu Guo Reply-To: Jiufu Guo Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. 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 building constants through "li; x?oris". gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr106708.c: Add test functions. --- gcc/config/rs6000/rs6000.cc | 34 ++++++++++++++++++--- gcc/testsuite/gcc.target/powerpc/pr106708.c | 27 +++++++++++++++- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 7efed94a0bc..316ee97c53d 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -10251,6 +10251,14 @@ 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 (ud4 == 0xffff && ud3 == 0xffff && !(ud2 & 0x8000) && ud1 == 0) { /* lis; xoris */ @@ -10263,10 +10271,28 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c) 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_AND (DImode, temp, GEN_INT (0xffffffff))); + + 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 + { + 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 index dd0386c109c..fd1e1cab8fc 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr106708.c +++ b/gcc/testsuite/gcc.target/powerpc/pr106708.c @@ -3,7 +3,8 @@ /* { dg-options "-O2 -mno-prefixed -save-temps" } */ /* { dg-require-effective-target has_arch_ppc64 } */ -long long arr[] = {0xffffffff65430000LL}; +long long arr[] + = {0xffffffff65430000LL, 0xffffffff7cdeab55LL, 0x98765432LL, 0xabcd0000LL}; void __attribute__ ((__noipa__)) lisxoris (long long *arg) { *arg = 0xffffffff65430000LL; @@ -11,12 +12,36 @@ void __attribute__ ((__noipa__)) lisxoris (long long *arg) /* { dg-final { scan-assembler-times {\mlis .*,0xe543\M} 1 } } */ /* { dg-final { scan-assembler-times {\mxoris .*0x8000\M} 1 } } */ +void __attribute__ ((__noipa__)) lixoris (long long *arg) +{ + *arg = 0xffffffff7cdeab55LL; +} +/* { dg-final { scan-assembler-times {\mli .*,-21675\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mxoris .*0x8321\M} 1 } } */ + +void __attribute__ ((__noipa__)) lioris (long long *arg) +{ + *arg = 0x98765432LL; +} +/* { dg-final { scan-assembler-times {\mli .*,21554\M} 1 } } */ +/* { dg-final { scan-assembler-times {\moris .*0x9876\M} 1 } } */ + +void __attribute__ ((__noipa__)) lisrldicl (long long *arg) +{ + *arg = 0xabcd0000LL; +} +/* { dg-final { scan-assembler-times {\mlis .*,0xabcd\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mrldicl .*,0,32\M} 1 } } */ + int main () { long long a[sizeof (arr) / sizeof (arr[0])]; lisxoris (a); + lixoris (a + 1); + lioris (a + 2); + lisrldicl (a + 3); if (__builtin_memcmp (a, arr, sizeof (arr)) != 0) __builtin_abort (); return 0;