From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id E16CB3858D28; Wed, 7 Sep 2022 07:36:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E16CB3858D28 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 (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28778A9F013884; Wed, 7 Sep 2022 07:36:52 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 : content-type : mime-version; s=pp1; bh=ZBR00ECqs0BjRsT0wk+wH5Zop++IWDe36Q4E+YaV/jU=; b=Tkza3XlkFjH4w6ieXgNYhurclJ5NW0k0Zj/BoB0IRWvr11k7m6/SXzonbF7Airve0f7d e/R/FuKe1qjzF+jy8j1NoxErvTCb2Gg2hs7LSxLtY8FQ9SMwBb1sJ40zmzD5D7kl7pEl ZVymEktHhurXpJetkBKLmA+tRpvQOIxJNM8qzG2ei3mwmFJQMWEHGxXCebMUDyG236Pw C5hRDhvxs3C1RGsBNceRPhZmTeOn2A/FMMYUVesZGV2DYwRJtht5eK38RmY3sGpyQX8o mOKxDyn81UmuIbaDtTXCjfCZeroOm+1pfya3LRCynKp/XhYDaA9z7nEECm2wJ5AvNCK9 uA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jenhv2vjd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Sep 2022 07:36:52 +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 28778SB3015994; Wed, 7 Sep 2022 07:36:51 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jenhv2vhs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Sep 2022 07:36:51 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2877ZbGY023721; Wed, 7 Sep 2022 07:36:51 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma04wdc.us.ibm.com with ESMTP id 3jbxj9rffr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Sep 2022 07:36:51 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2877aoaH44958034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 7 Sep 2022 07:36:50 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A41EDC6059; Wed, 7 Sep 2022 07:36:49 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A5A9C605F; Wed, 7 Sep 2022 07:36:49 +0000 (GMT) Received: from pike (unknown [9.5.12.127]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTPS; Wed, 7 Sep 2022 07:36:49 +0000 (GMT) From: Jiufu Guo To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org Subject: Ping [PATCH] rs6000: using li/lis+oris/xoris to build constants In-Reply-To: <20220824081344.70468-1-guojiufu@linux.ibm.com> (Jiufu Guo's message of "Wed, 24 Aug 2022 16:13:44 +0800") References: <20220824081344.70468-1-guojiufu@linux.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Date: Wed, 07 Sep 2022 15:36:47 +0800 Message-ID: <7eczc7tz3k.fsf@pike.rch.stglabs.ibm.com> Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: utaHWV12n0rRrMpLeJuAQfiPUJaAX25Y X-Proofpoint-GUID: EbfNkqFkQKY3obqtuRvSF5H3udFWftnm 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.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-07_04,2022-09-06_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209070031 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,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: Jiufu Guo writes: Gentle ping: https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600189.html BR, Jeff(Jiufu) > Hi, > > PR106708 constaint some constants which can be support by li/lis + oris/xoris. > > For constant C: > 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'. > > if ((c & 0xFFFFFFFF00008000ULL) == 0xFFFFFFFF00008000ULL) or say: > 32(1)+16(x)+1(1)+15(x), using li+xoris would be ok. > > if ((c & 0xFFFFFFFF0000FFFFULL) == 0xFFFFFFFF00000000) or say: > 32(1)+1(0)+15(x)+16(0), using lis+xoris would be ok. > > This patch update rs6000_emit_set_long_const to support these forms. > Bootstrap and regtest pass on ppc64 and ppc64le. > > Is this ok for trunk? > > BR, > Jeff(Jiufu) > > > PR target/106708 > > gcc/ChangeLog: > > * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Using li/lis + > oris/xoris to build constants. > > gcc/testsuite/ChangeLog: > > * gcc.target/powerpc/pr106708.c: New test. > * gcc.target/powerpc/pr106708.h: New file. > * gcc.target/powerpc/pr106708_1.c: New test. > > --- > gcc/config/rs6000/rs6000.cc | 22 +++++++++++++++++++ > gcc/testsuite/gcc.target/powerpc/pr106708.c | 10 +++++++++ > gcc/testsuite/gcc.target/powerpc/pr106708.h | 9 ++++++++ > gcc/testsuite/gcc.target/powerpc/pr106708_1.c | 17 ++++++++++++++ > 4 files changed, 58 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708.c > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708.h > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708_1.c > > diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc > index df491bee2ea..243247fb838 100644 > --- a/gcc/config/rs6000/rs6000.cc > +++ b/gcc/config/rs6000/rs6000.cc > @@ -10112,6 +10112,7 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c) > { > rtx temp; > HOST_WIDE_INT ud1, ud2, ud3, ud4; > + HOST_WIDE_INT orig_c = c; > > ud1 = c & 0xffff; > c = c >> 16; > @@ -10137,6 +10138,27 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c) > gen_rtx_IOR (DImode, copy_rtx (temp), > GEN_INT (ud1))); > } > + else if (ud4 == 0 && ud3 == 0 && (ud2 & 0x8000) && !(ud1 & 0x8000)) > + { > + temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode); > + > + /* li+oris */ > + emit_move_insn (copy_rtx (temp), GEN_INT (ud1)); > + emit_move_insn (dest, gen_rtx_IOR (DImode, copy_rtx (temp), > + GEN_INT (ud2 << 16))); > + } > + else if ((ud4 == 0xffff && ud3 == 0xffff) > + && ((ud1 & 0x8000) || (ud1 == 0 && !(ud2 & 0x8000)))) > + { > + temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode); > + > + HOST_WIDE_INT imm = (ud1 & 0x8000) ? ((ud1 ^ 0x8000) - 0x8000) > + : ((ud2 << 16) - 0x80000000); > + /* li/lis + xoris */ > + emit_move_insn (copy_rtx (temp), GEN_INT (imm)); > + emit_move_insn (dest, gen_rtx_XOR (DImode, copy_rtx (temp), > + GEN_INT (orig_c ^ imm))); > + } > 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..6445fa47747 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr106708.c > @@ -0,0 +1,10 @@ > +/* PR target/106708 */ > +/* { dg-options "-O2 -mdejagnu-cpu=power8" } */ > +/* { dg-do compile { target has_arch_ppc64 } } */ > + > +#include "pr106708.h" > + > +/* { dg-final { scan-assembler-times {\mli\M} 2 } } */ > +/* { dg-final { scan-assembler-times {\mlis\M} 1 } } */ > +/* { dg-final { scan-assembler-times {\moris\M} 1 } } */ > +/* { dg-final { scan-assembler-times {\mxoris\M} 2 } } */ > diff --git a/gcc/testsuite/gcc.target/powerpc/pr106708.h b/gcc/testsuite/gcc.target/powerpc/pr106708.h > new file mode 100644 > index 00000000000..ad07eb30547 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr106708.h > @@ -0,0 +1,9 @@ > +/* li/lis + oris/xoris */ > +void __attribute__ ((__noinline__, __noclone__)) foo (long long *arg) > +{ > + *arg++ = 0x98765432ULL; > + *arg++ = 0xffffffff7cdeab55ULL; > + *arg++ = 0xffffffff65430000ULL; > +} > + > + > diff --git a/gcc/testsuite/gcc.target/powerpc/pr106708_1.c b/gcc/testsuite/gcc.target/powerpc/pr106708_1.c > new file mode 100644 > index 00000000000..df65c321f6b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr106708_1.c > @@ -0,0 +1,17 @@ > +/* PR target/106708 */ > +/* { dg-do run } */ > +/* { dg-options "-O2" } */ > + > +#include "pr106708.h" > + > +long long arr[] = {0x98765432ULL, 0xffffffff7cdeab55ULL, 0xffffffff65430000ULL}; > +int > +main () > +{ > + long long a[3]; > + > + foo (a); > + if (__builtin_memcmp (a, arr, sizeof (arr)) != 0) > + __builtin_abort (); > + return 0; > +}