From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id D27263858D20 for ; Wed, 29 May 2024 16:03:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D27263858D20 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 D27263858D20 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=1716998633; cv=none; b=hZkv9dzM1srv7FchMVzyqAvf4s4p0KoNcvsBZykHJw7BM9csvk2SEn8f2ouwXMTlNerNHlOzKO4OAef+hsuRgsTiCXBXyFsgLDX5C3BjU1w4pqcmYaJWUNNQqfMI+Y13Tnm+h26lDZWHiD62RZ/l+lfCwFg3V8eWgR+LYCxRNhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716998633; c=relaxed/simple; bh=NfPI/AycL+1br+teeB60MH2TbJPb/AH/MnrQVhbkFCU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=sZK7P4k3hkVzlRy1kawuexkzLZ5fAL+3tSsS1KpstAIptI8aFNjoScQEPr2nuki5ttmWlLE8+Yow6AnlN97svXVCajPhtYUemYyq8s1/oyPc5cvvAnND8wwI7kHCO1FC1DtgrVhKbWZ2Dq/y4BWjLbpbkmSLGEbhQq4QWmFWNZM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44TFvbdj016765; Wed, 29 May 2024 16:03:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=content-transfer-encoding : content-type : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=/EwKPS7yhLBO8IaXKMB6rARRIwx/qyLJvqEaeX8DuzM=; b=MbOui1AQ62mnVB1K38JGmaFZNm3QXP/UYq1Z4bWNiLvcmzQsWdJ4H2/ar8J1A6XJmwuI 0Bng+HR5aVBs/FvqAeWON6uwPDa2775yco8Mqr8xvKXfklBMTnmgCv1QbYdXCS7cSTeq YrT1vIFrO4MmumgAUygkoCH9N7qpqvaCAnvBRVse8eB20xYauECZj6JhpX3l09vrh7sm d7GGPNVOWCYTfRHA2XEsKIwJ7Z6HqYWcvE75WElwLLKLjIlPCT7D6eYhgz34N4xqKBOA EiOBLeX1pJGGhyIBusv0PWd5PurhQ+GwRnriCnQDHS6NgIAbeG57D6LjaPK5lhKehRNa 4A== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ye7ey80p8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 16:03:49 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 44TFFv4Q024752; Wed, 29 May 2024 16:03:48 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ydphqmkjs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 May 2024 16:03:48 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 44TG3jLe31261104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 May 2024 16:03:47 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2EEC58065; Wed, 29 May 2024 16:03:44 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7450B58083; Wed, 29 May 2024 16:03:44 +0000 (GMT) Received: from [9.67.70.111] (unknown [9.67.70.111]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 May 2024 16:03:44 +0000 (GMT) Message-ID: <27b97e93-462d-47b9-ad1c-344b1dec28ba@linux.ibm.com> Date: Wed, 29 May 2024 09:03:43 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 7/13 ver 3] rs6000, add overloaded vec_sel with int128 arguments To: gcc-patches@gcc.gnu.org, Segher Boessenkool , "Kewen.Lin" , "bergner@linux.ibm.com" References: <59db7e45-e780-4d20-a364-526f9e45800b@linux.ibm.com> Content-Language: en-US From: Carl Love In-Reply-To: <59db7e45-e780-4d20-a364-526f9e45800b@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3SRKjlIDoWR_jTzd5LBu6enjAKrOYIPg X-Proofpoint-ORIG-GUID: 3SRKjlIDoWR_jTzd5LBu6enjAKrOYIPg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-29_12,2024-05-28_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 spamscore=0 suspectscore=0 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405290111 X-Spam-Status: No, score=-9.7 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 List-Id: This was patch 6 in the previous series. Updated the documentation file per the comments. No functional changes to the patch. Carl ------------------------------------------------------------ rs6000, add overloaded vec_sel with int128 arguments Extend the vec_sel built-in to take three signed/unsigned int128 arguments and return a signed/unsigned int128 result. Extending the vec_sel built-in makes the existing buit-ins __builtin_vsx_xxsel_1ti and __builtin_vsx_xxsel_1ti_uns obsolete. The patch removes these built-ins. The patch adds documentation and test cases for the new overloaded vec_sel built-ins. gcc/ChangeLog: * config/rs6000/rs6000-builtins.def (__builtin_vsx_xxsel_1ti, __builtin_vsx_xxsel_1ti_uns): Remove built-in definitions. * config/rs6000/rs6000-overload.def (vec_sel): Add new overloaded definitions. * doc/extend.texi: Add documentation for new vec_sel instances. gcc/testsuite/ChangeLog: * gcc.target/powerpc/vec-sel-runnable-i128.c: New test file. --- gcc/config/rs6000/rs6000-builtins.def | 6 - gcc/config/rs6000/rs6000-overload.def | 4 + gcc/doc/extend.texi | 12 ++ .../powerpc/vec-sel-runnable-i128.c | 129 ++++++++++++++++++ 4 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/vec-sel-runnable-i128.c diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index 13e36df008d..ea0da77f13e 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -1904,12 +1904,6 @@ const vuc __builtin_vsx_xxsel_16qi_uns (vuc, vuc, vuc); XXSEL_16QI_UNS vector_select_v16qi_uns {} - const vsq __builtin_vsx_xxsel_1ti (vsq, vsq, vsq); - XXSEL_1TI vector_select_v1ti {} - - const vsq __builtin_vsx_xxsel_1ti_uns (vsq, vsq, vsq); - XXSEL_1TI_UNS vector_select_v1ti_uns {} - const vd __builtin_vsx_xxsel_2df (vd, vd, vd); XXSEL_2DF vector_select_v2df {} diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def index 4d857bb1af3..a210c5ad10d 100644 --- a/gcc/config/rs6000/rs6000-overload.def +++ b/gcc/config/rs6000/rs6000-overload.def @@ -3274,6 +3274,10 @@ VSEL_2DF VSEL_2DF_B vd __builtin_vec_sel (vd, vd, vull); VSEL_2DF VSEL_2DF_U + vsq __builtin_vec_sel (vsq, vsq, vsq); + VSEL_1TI VSEL_1TI_S + vuq __builtin_vec_sel (vuq, vuq, vuq); + VSEL_1TI_UNS VSEL_1TI_U ; The following variants are deprecated. vsll __builtin_vec_sel (vsll, vsll, vsll); VSEL_2DI_B VSEL_2DI_S diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index b88e61641a2..0756230b19e 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -21372,6 +21372,18 @@ Additional built-in functions are available for the 64-bit PowerPC family of processors, for efficient use of 128-bit floating point (@code{__float128}) values. +Vector select + +@smallexample +vector signed __int128 vec_sel (vector signed __int128, + vector signed __int128, vector signed __int128); +vector unsigned __int128 vec_sel (vector unsigned __int128, + vector unsigned __int128, vector unsigned __int128); +@end smallexample + +The instance is an extension of the exiting overloaded built-in @code{vec_sel} +that is documented in the PVIPR. + @node Basic PowerPC Built-in Functions Available on ISA 2.06 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06 diff --git a/gcc/testsuite/gcc.target/powerpc/vec-sel-runnable-i128.c b/gcc/testsuite/gcc.target/powerpc/vec-sel-runnable-i128.c new file mode 100644 index 00000000000..d82225cc847 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vec-sel-runnable-i128.c @@ -0,0 +1,129 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-save-temps" } */ +/* { dg-final { scan-assembler-times "xxsel" 2 } } */ + +#include + +#define DEBUG 0 + +#if DEBUG +#include +void print_i128 (unsigned __int128 val) +{ + printf(" 0x%016llx%016llx", + (unsigned long long)(val >> 64), + (unsigned long long)(val & 0xFFFFFFFFFFFFFFFF)); +} +#endif + +extern void abort (void); + +union convert_union { + vector signed __int128 s128; + vector unsigned __int128 u128; + char val[16]; +} convert; + +int check_u128_result(vector unsigned __int128 vresult_u128, + vector unsigned __int128 expected_vresult_u128) +{ + /* Use a for loop to check each byte manually so the test case will run + with ISA 2.06. + + Return 1 if they match, 0 otherwise. */ + + int i; + + union convert_union result; + union convert_union expected; + + result.u128 = vresult_u128; + expected.u128 = expected_vresult_u128; + + /* Check if each byte of the result and expected match. */ + for (i = 0; i < 16; i++) + { + if (result.val[i] != expected.val[i]) + return 0; + } + return 1; +} + +int check_s128_result(vector signed __int128 vresult_s128, + vector signed __int128 expected_vresult_s128) +{ + /* Convert the arguments to unsigned, then check equality. */ + union convert_union result; + union convert_union expected; + + result.s128 = vresult_s128; + expected.s128 = expected_vresult_s128; + + return check_u128_result (result.u128, expected.u128); +} + + +int +main (int argc, char *argv []) +{ + int i; + + vector signed __int128 src_va_s128; + vector signed __int128 src_vb_s128; + vector signed __int128 src_vc_s128; + vector signed __int128 vresult_s128; + vector signed __int128 expected_vresult_s128; + + vector unsigned __int128 src_va_u128; + vector unsigned __int128 src_vb_u128; + vector unsigned __int128 src_vc_u128; + vector unsigned __int128 vresult_u128; + vector unsigned __int128 expected_vresult_u128; + + src_va_s128 = (vector signed __int128) {0x123456789ABCDEF0}; + src_vb_s128 = (vector signed __int128) {0xFEDCBA9876543210}; + src_vc_s128 = (vector signed __int128) {0x3333333333333333}; + expected_vresult_s128 = (vector signed __int128) {0x32147658ba9cfed0}; + + /* Signed arguments. */ + vresult_s128 = vec_sel (src_va_s128, src_vb_s128, src_vc_s128); + + if (!check_s128_result (vresult_s128, expected_vresult_s128)) +#if DEBUG + { + printf ("ERROR, vec_sel (src_va_s128, src_vb_s128, src_vc_s128) result does not match expected output.\n"); + printf (" Result: "); + print_i128 ((unsigned __int128) vresult_s128); + printf ("\n Expected result: "); + print_i128 ((unsigned __int128) expected_vresult_s128); + printf ("\n"); + } +#else + abort (); +#endif + + src_va_u128 = (vector unsigned __int128) {0x13579ACE02468BDF}; + src_vb_u128 = (vector unsigned __int128) {0xA987654FEDCB3210}; + src_vc_u128 = (vector unsigned __int128) {0x5555555555555555}; + expected_vresult_u128 = (vector unsigned __int128) {0x0307CFCF47439A9A}; + + /* Unigned arguments. */ + vresult_u128 = vec_sel (src_va_u128, src_vb_u128, src_vc_u128); + + if (!check_u128_result (vresult_u128, expected_vresult_u128)) +#if DEBUG + { + printf ("ERROR, vec_sel (src_va_u128, src_vb_u128, src_vc_u128) result does not match expected output.\n"); + printf (" Result: "); + print_i128 ((unsigned __int128) vresult_u128); + printf ("\n Expected result: "); + print_i128 ((unsigned __int128) expected_vresult_u128); + printf ("\n"); + } +#else + abort (); +#endif + + return 0; +} -- 2.45.0