From patchwork Tue Nov 16 18:56:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 47784 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 495293858401 for ; Tue, 16 Nov 2021 18:57:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 495293858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637089046; bh=SpKUVTPct1T0aFLnJf+yQp2+Pc2XhN5qJH5C5ww/iCU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=U3FYPGfMScmqM7Zqg2+YC3++MF9UUI7HRtBFCn8GsdjVIXLLBRROOak0frZ9WCfmc b3pfuGyonLHylnnvWa/kyw17DrkC77Yzqbf4TOTn1CFWcwu9TS96z8DIJxvJWM/wGi OpHxoI4sNh6Fl2x+p99PCZof3pSxBmek3LK/ksuo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 4C74A3858401 for ; Tue, 16 Nov 2021 18:56:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C74A3858401 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AGITS8O019418; Tue, 16 Nov 2021 18:56:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3cchyh8f4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Nov 2021 18:56:55 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1AGIm6Mi016623; Tue, 16 Nov 2021 18:56:55 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0b-001b2d01.pphosted.com with ESMTP id 3cchyh8f44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Nov 2021 18:56:55 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1AGIlcsf020731; Tue, 16 Nov 2021 18:56:54 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma02wdc.us.ibm.com with ESMTP id 3ca50b30kf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Nov 2021 18:56:54 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1AGIurAY53936536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Nov 2021 18:56:53 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C2A878068; Tue, 16 Nov 2021 18:56:53 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 595017805E; Tue, 16 Nov 2021 18:56:53 +0000 (GMT) Received: from [9.211.84.243] (unknown [9.211.84.243]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 16 Nov 2021 18:56:53 +0000 (GMT) Message-ID: <3e1478d2-481c-feba-dd37-78dbeaadaaf2@linux.ibm.com> Date: Tue, 16 Nov 2021 12:56:52 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 To: GCC Patches Subject: [PATCH v2] rs6000: Fix a handful of 32-bit built-in function problems X-TM-AS-GCONF: 00 X-Proofpoint-GUID: iBUGjqP3x_tj8KxqtlcVfBOMXrpKg0Iq X-Proofpoint-ORIG-GUID: D6MEqkxOafmXEIt2N5Fq9NVzK8eMpAc9 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.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-16_04,2021-11-16_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 phishscore=0 impostorscore=0 bulkscore=0 malwarescore=0 clxscore=1015 adultscore=0 priorityscore=1501 mlxlogscore=999 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111160088 X-Spam-Status: No, score=-12.3 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Bill Schmidt via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: wschmidt@linux.ibm.com Cc: David Edelsohn , Segher Boessenkool Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! I previously posted [1] to correct some problems with the new builtins support targeting 32-bit code gen. Based on the discussion, I've made some adjustments and would like to submit this for consideration. We eventually agreed that the strange behavior for -m32 -mpowerpc64 for certain HTM builtins should be removed. All of the registers TEXASR, TEXASRU, TFHAR, and TFIAR are now accessed using the unsigned long data type in all configurations. Segher didn't like the change in the error message for the cmpb-3.c test case, but I think this should be fine. The test case just tests for the error message, but there is also a "note" message that provides additional information. The diagnostics that the user sees will look like this: cmpb-3.c:11:3: error: '__builtin_p6_cmpb' requires the '-mcpu=power6' option and either the '-m64' or '-mpowerpc64' option cmpb-3.c:11:3: note: builtin '__builtin_cmpb' requires builtin '__builtin_p6_cmpb' So it's clear to the user that their use of __builtin_cmpb at line 11 triggered the error. Bootstrapped and tested on powerpc64le-linux-gnu, and on powerpc64-linux-gnu using -m32/-m64. Is this okay for trunk? Thanks! Bill [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583905.html 2021-11-16 Bill Schmidt gcc/ * config/rs6000/rs6000-builtin-new.def (CMPB): Flag as no32bit. (BPERMD): Flag as 32bit (needing special handling for 32-bit). (UNPACK_TD): Return unsigned long long instead of unsigned long. (GET_TEXASR): Return unsigned long instead of unsigned long long. (GET_TEXASRU): Likewise. (GET_TFHAR): Likewise. (GET_TFIAR): Likewise. (SET_TEXASR): Pass unsigned long instead of unsigned long long. (SET_TEXASRU): Likewise. (SET_TFHAR): Likewise. (SET_TFIAR): Likewise. (TABORTDC): Likewise. (TABORTDCI): Likewise. * config/rs6000/rs6000-call.c (rs6000_expand_new_builtin): Fix error handling for no32bit. Add 32bit handling for RS6000_BIF_BPERMD. gcc/testsuite/ * gcc.target/powerpc/cmpb-3.c: Adjust error message. --- gcc/config/rs6000/rs6000-builtin-new.def | 30 +++++++++++------------ gcc/config/rs6000/rs6000-call.c | 9 ++++--- gcc/testsuite/gcc.target/powerpc/cmpb-3.c | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/gcc/config/rs6000/rs6000-builtin-new.def b/gcc/config/rs6000/rs6000-builtin-new.def index 58dfce1ca37..30556e5c7f2 100644 --- a/gcc/config/rs6000/rs6000-builtin-new.def +++ b/gcc/config/rs6000/rs6000-builtin-new.def @@ -273,7 +273,7 @@ ; Power6 builtins requiring 64-bit GPRs (even with 32-bit addressing). [power6-64] const signed long __builtin_p6_cmpb (signed long, signed long); - CMPB cmpbdi3 {} + CMPB cmpbdi3 {no32bit} ; AltiVec builtins. @@ -2018,7 +2018,7 @@ ADDG6S addg6s {} const signed long __builtin_bpermd (signed long, signed long); - BPERMD bpermd_di {} + BPERMD bpermd_di {32bit} const unsigned int __builtin_cbcdtd (unsigned int); CBCDTD cbcdtd {} @@ -2971,7 +2971,7 @@ void __builtin_set_fpscr_drn (const int[0,7]); SET_FPSCR_DRN rs6000_set_fpscr_drn {} - const unsigned long __builtin_unpack_dec128 (_Decimal128, const int<1>); + const unsigned long long __builtin_unpack_dec128 (_Decimal128, const int<1>); UNPACK_TD unpacktd {} @@ -3014,39 +3014,39 @@ [htm] - unsigned long long __builtin_get_texasr (); + unsigned long __builtin_get_texasr (); GET_TEXASR nothing {htm,htmspr} - unsigned long long __builtin_get_texasru (); + unsigned long __builtin_get_texasru (); GET_TEXASRU nothing {htm,htmspr} - unsigned long long __builtin_get_tfhar (); + unsigned long __builtin_get_tfhar (); GET_TFHAR nothing {htm,htmspr} - unsigned long long __builtin_get_tfiar (); + unsigned long __builtin_get_tfiar (); GET_TFIAR nothing {htm,htmspr} - void __builtin_set_texasr (unsigned long long); + void __builtin_set_texasr (unsigned long); SET_TEXASR nothing {htm,htmspr} - void __builtin_set_texasru (unsigned long long); + void __builtin_set_texasru (unsigned long); SET_TEXASRU nothing {htm,htmspr} - void __builtin_set_tfhar (unsigned long long); + void __builtin_set_tfhar (unsigned long); SET_TFHAR nothing {htm,htmspr} - void __builtin_set_tfiar (unsigned long long); + void __builtin_set_tfiar (unsigned long); SET_TFIAR nothing {htm,htmspr} unsigned int __builtin_tabort (unsigned int); TABORT tabort {htm,htmcr} - unsigned int __builtin_tabortdc (unsigned long long, unsigned long long, \ - unsigned long long); + unsigned int __builtin_tabortdc (unsigned long, unsigned long, \ + unsigned long); TABORTDC tabortdc {htm,htmcr} - unsigned int __builtin_tabortdci (unsigned long long, unsigned long long, \ - unsigned long long); + unsigned int __builtin_tabortdci (unsigned long, unsigned long, \ + unsigned long); TABORTDCI tabortdci {htm,htmcr} unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int); diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index 822a9736591..85fec80c6d7 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -15740,9 +15740,10 @@ rs6000_expand_new_builtin (tree exp, rtx target, } if (bif_is_no32bit (*bifaddr) && TARGET_32BIT) - fatal_error (input_location, - "%<%s%> is not supported in 32-bit mode", - bifaddr->bifname); + { + error ("%<%s%> is not supported in 32-bit mode", bifaddr->bifname); + return const0_rtx; + } if (bif_is_cpu (*bifaddr)) return new_cpu_expand_builtin (fcode, exp, target); @@ -15766,6 +15767,8 @@ rs6000_expand_new_builtin (tree exp, rtx target, { if (fcode == RS6000_BIF_MFTB) icode = CODE_FOR_rs6000_mftb_si; + else if (fcode == RS6000_BIF_BPERMD) + icode = CODE_FOR_bpermd_si; else gcc_unreachable (); } diff --git a/gcc/testsuite/gcc.target/powerpc/cmpb-3.c b/gcc/testsuite/gcc.target/powerpc/cmpb-3.c index de111a80144..75641bdb22c 100644 --- a/gcc/testsuite/gcc.target/powerpc/cmpb-3.c +++ b/gcc/testsuite/gcc.target/powerpc/cmpb-3.c @@ -8,7 +8,7 @@ void abort (); long long int do_compare (long long int a, long long int b) { - return __builtin_cmpb (a, b); /* { dg-error "'__builtin_cmpb' is not supported in this compiler configuration" } */ + return __builtin_cmpb (a, b); /* { dg-error "'__builtin_p6_cmpb' requires the '-mcpu=power6' option and either the '-m64' or '-mpowerpc64' option" } */ } void expect (long long int pattern, long long int value)