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 202353945C3C; Fri, 25 Nov 2022 08:11:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 202353945C3C 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 (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AP7E1HT002312; Fri, 25 Nov 2022 08:11:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=2FkaNzNfFBjS/Eueu9tL8QPoP9Q5OFYlIGDeZoBhNFM=; b=K7HmA9h8nnZKaYai0tnFLLFHMQzPmgAI+QiX54cP0GxEZjAWPV435pE438I6gE8CMpE3 6ZQM4OaSof64tW+h3Q9NcPEx5MFjoJ5GImoBqeoW3/GP47lPjJuYDFLSt+HWh7AD8YYX 9HddnI4XXdiQNBgGIrPQiJp/i6w0LzVa6m0VvGvbdwrkXOmWkME1zssO2hO9kafp3vZm Xpm2siNB+rXS0y0zFwNMcx1B6sd9QaNi/wBmNNonGKQsB7i/bdS9S3veZl3pxjc+3S90 rZpVwUUU1/Z1p0NWDcMHSvReic9SXtx3vxAwyiutQl4RyG5T6ZACEvXAOy/BcxqTmmTg /g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m2p2fd5xg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Nov 2022 08:11:58 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AP7QITN003527; Fri, 25 Nov 2022 08:11:57 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m2p2fd5ws-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Nov 2022 08:11:57 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AP85bRW028601; Fri, 25 Nov 2022 08:11:56 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04ams.nl.ibm.com with ESMTP id 3kxps9183p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Nov 2022 08:11:55 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AP8Brwm4850382 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Nov 2022 08:11:53 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6EAEB42049; Fri, 25 Nov 2022 08:11:53 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 585BB42042; Fri, 25 Nov 2022 08:11:51 +0000 (GMT) Received: from [9.197.245.251] (unknown [9.197.245.251]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 25 Nov 2022 08:11:50 +0000 (GMT) Message-ID: <9331dba8-f346-37e5-3340-055f2c4d9245@linux.ibm.com> Date: Fri, 25 Nov 2022 16:11:49 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH V2] rs6000: Support to build constants by li/lis+oris/xoris 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: <20221026114052.17713-1-guojiufu@linux.ibm.com> From: "Kewen.Lin" In-Reply-To: <20221026114052.17713-1-guojiufu@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: MFNPRBPrkMkpa0urQ5pO6KJWU8VW6rx_ X-Proofpoint-ORIG-GUID: TPc-GSVPTdPRQWwh284yETlsinoCjceq 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-11-25_02,2022-11-24_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 phishscore=0 clxscore=1011 impostorscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211250065 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,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, Sorry for the late reply. on 2022/10/26 19:40, Jiufu Guo wrote: > Hi, > > PR106708 constaint some constants which can be support by li/lis + oris/xoris. ~~~~~~~~ typo? for "li/lis + oris/xoris", I interpreted it into four combinations: li + oris, lis + oris, li + xoris, lis + xoris. not sure just me interpreting like that, but the actual combinations which this patch adopts are: li + oris, li + xoris, lis + xoris. It's a bit off, but not a big deal, up to you to reword it or not. :) > > 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'. > Here N(M) means N continuous bit M, x for M means it is ok for either > 1 or 0; '||' means concatenation. > > 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? This updated version looks good to me, but I'd leave it to Segher for the final say. Thanks! BR, Kewen > > BR, > Jeff(Jiufu) > > > PR target/106708 > > gcc/ChangeLog: > > * config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Support > constants which can be built with li + oris or li/lis + xoris. > > gcc/testsuite/ChangeLog: > > * gcc.target/powerpc/pr106708-run.c: New test. > * gcc.target/powerpc/pr106708.c: New test. > * gcc.target/powerpc/pr106708.h: New file. > > --- > gcc/config/rs6000/rs6000.cc | 41 ++++++++++++++----- > .../gcc.target/powerpc/pr106708-run.c | 17 ++++++++ > gcc/testsuite/gcc.target/powerpc/pr106708.c | 12 ++++++ > gcc/testsuite/gcc.target/powerpc/pr106708.h | 9 ++++ > 4 files changed, 69 insertions(+), 10 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708-run.c > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708.c > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708.h > > diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc > index d2743f7bce6..9b7a51f052d 100644 > --- a/gcc/config/rs6000/rs6000.cc > +++ b/gcc/config/rs6000/rs6000.cc > @@ -10228,6 +10228,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; > @@ -10253,21 +10254,41 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c) > gen_rtx_IOR (DImode, copy_rtx (temp), > GEN_INT (ud1))); > } > + 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 (temp, GEN_INT (imm)); > + emit_move_insn (dest, gen_rtx_XOR (DImode, temp, > + GEN_INT (orig_c ^ imm))); > + } > else if (ud3 == 0 && ud4 == 0) > { > temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode); > > gcc_assert (ud2 & 0x8000); > - emit_move_insn (copy_rtx (temp), > - GEN_INT (((ud2 << 16) ^ 0x80000000) - 0x80000000)); > - if (ud1 != 0) > - emit_move_insn (copy_rtx (temp), > - gen_rtx_IOR (DImode, copy_rtx (temp), > - GEN_INT (ud1))); > - emit_move_insn (dest, > - gen_rtx_ZERO_EXTEND (DImode, > - gen_lowpart (SImode, > - copy_rtx (temp)))); > + > + 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 (((ud2 << 16) ^ 0x80000000) - 0x80000000)); > + 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))); > + } > } > else if (ud1 == ud3 && ud2 == ud4) > { > diff --git a/gcc/testsuite/gcc.target/powerpc/pr106708-run.c b/gcc/testsuite/gcc.target/powerpc/pr106708-run.c > new file mode 100644 > index 00000000000..df65c321f6b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr106708-run.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; > +} > diff --git a/gcc/testsuite/gcc.target/powerpc/pr106708.c b/gcc/testsuite/gcc.target/powerpc/pr106708.c > new file mode 100644 > index 00000000000..ebd9ea88993 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr106708.c > @@ -0,0 +1,12 @@ > +/* PR target/106708 */ > +/* { dg-do compile } } */ > +/* { dg-options "-O2 -mdejagnu-cpu=power8" } */ > +/* { dg-require-effective-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..42526a70892 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr106708.h > @@ -0,0 +1,9 @@ > +/* Test constants which can be built by li/lis + oris/xoris */ > +void __attribute__ ((__noinline__, __noclone__)) foo (long long *arg) > +{ > + *arg++ = 0x98765432ULL; > + *arg++ = 0xffffffff7cdeab55ULL; > + *arg++ = 0xffffffff65430000ULL; > +} > + > +