From patchwork Tue Feb 20 17:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 1901609 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=rl5vzLvL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TfS0t0Bw6z20RF for ; Wed, 21 Feb 2024 05:02:22 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C92663861829 for ; Tue, 20 Feb 2024 18:02:19 +0000 (GMT) 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 81A353858430 for ; Tue, 20 Feb 2024 18:01:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81A353858430 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 81A353858430 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708452073; cv=none; b=MavHbeoZ5EweA4w/e03qrC/nKE/tgI0qa37Fn39dgR+E5+TlSk3cK119sbbfa0CPkZoJgUTrTf2n0+ARNMxBbsrag6VvkFUtKwN7Hy33JYYNk4hoT7W93CQwbnMmdJqu3s3IouWFy6JmHxe4NMVRC+hCAgr+SrW04elwBYUGAys= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708452073; c=relaxed/simple; bh=h+dEpIW5crdup0jUbX0nf/lM4iZSxw5v4yWS9ivG6Ag=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=dk4xYF29cDpgtLqQVpA0wxRmQCK7GGx4yfn7VDx0h4QtejwkJEk63gCALbaLB/e4j0bdpdJK7s0pVAUtx+ESAkIZQaBElNTohoS8A3/apQ4rVfvKTKzE1XCd/mSzPFHjBWxV+Moa5qQTysr1NCB9HJeU6TY8SyOsHMZPff1pJ+Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41KHDup1000926; Tue, 20 Feb 2024 18:01:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=dBOm/Yjg1lA2eYLY2miYgpVCDaxBg9sYakcXR99IaOk=; b=rl5vzLvLVT+5FRct3BHINjdIr3WZGObYqFEM0M4UY3UsW+JKBGwtEWv6cg5amN3dk+6w LBAogO0tr44YOlSrOgsFgZPDHIGNzWCV3w+e+QlaGSx9uEOlyfNYazOKyF5gmt5IMSle Ml6gqtQa4aIONdIgd3NjOVWcB+1uzjq5JKRH6CAgvpszUE+81Ww5ZASox87vfUA2NOXJ b5se9meAY4t3SUmkwi7txxL6K+L+tSOdf3/t0bmsZexxUp2zTtwFRMIJAHiwuTfEcDXm h1Qj+g5NrOVpWXesZ7nnqxmAfUt74SSdm0Ap8MoZWFra3LgIRBRMQ+dL5tlkjQNcIRY8 nw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wd0a012au-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Feb 2024 18:01:08 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41KFTqca017283; Tue, 20 Feb 2024 17:57:31 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wb8mm9m8v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Feb 2024 17:57:31 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41KHvSvb17629838 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Feb 2024 17:57:30 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76C2058060; Tue, 20 Feb 2024 17:57:28 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC4A858056; Tue, 20 Feb 2024 17:57:27 +0000 (GMT) Received: from [9.67.96.239] (unknown [9.67.96.239]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 20 Feb 2024 17:57:27 +0000 (GMT) Message-ID: <91b2efe8-76d6-4aa8-8d67-8c8512e1dd81@linux.ibm.com> Date: Tue, 20 Feb 2024 09:57:27 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 07/11] rs6000, __builtin_vsx_xvcmpeq[sp, dp, sp_p] add, documentation and test case Content-Language: en-US To: gcc-patches@gcc.gnu.org, "bergner@linux.ibm.com" , Segher Boessenkool , "Kewen.Lin" References: <41290fb1-e2e8-4779-b76f-2208c2dadedd@linux.ibm.com> From: Carl Love In-Reply-To: <41290fb1-e2e8-4779-b76f-2208c2dadedd@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: mSytaPFbglihn-DqYldVBDHIgUtnQhbh X-Proofpoint-GUID: mSytaPFbglihn-DqYldVBDHIgUtnQhbh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-20_06,2024-02-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 adultscore=0 priorityscore=1501 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402200129 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H3, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org GCC maintainers: The patch adds documentation and test case for the __builtin_vsx_xvcmpeq[sp, dp, sp_p] built-ins. The patch has been tested on Power 10 with no regressions. Please let me know if this patch is acceptable for mainline. Thanks. Carl ------------------------------------------------------------ rs6000, __builtin_vsx_xvcmpeq[sp, dp, sp_p] add documentation and test case Add a test case for the __builtin_vsx_xvcmpeqsp_p built-in. Add documentation for the __builtin_vsx_xvcmpeqsp_p, __builtin_vsx_xvcmpeqdp, and __builtin_vsx_xvcmpeqsp builtins. gcc/ChangeLog: * doc/extend.texi (__builtin_vsx_xvcmpeqsp_p, __builtin_vsx_xvcmpeqdp, __builtin_vsx_xvcmpeqsp): Add documentation. gcc/testsuite/ChangeLog: * gcc.target/powerpc/vsx-builtin-runnable-4.c: New test case. --- gcc/doc/extend.texi | 23 +++ .../powerpc/vsx-builtin-runnable-4.c | 135 ++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-4.c diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 22f67ebab31..87fd30bfa9e 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -22700,6 +22700,18 @@ vectors of their defined type. The corresponding result element is set to all ones if the two argument elements are less than or equal and all zeros otherwise. +@smallexample +const vf __builtin_vsx_xvcmpeqsp (vf, vf); +const vd __builtin_vsx_xvcmpeqdp (vd, vd); +@end smallexample + +The builti-ins @code{__builtin_vsx_xvcmpeqdp} and +@code{__builtin_vsx_xvcmpeqdp} compare two floating point vectors and return +a vector. If the corresponding elements are equal then the corresponding +vector element of the result is set to all ones, it is set to all zeros +otherwise. + + @node PowerPC AltiVec Built-in Functions Available on ISA 2.07 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07 @@ -23989,6 +24001,17 @@ is larger than 128 bits, the result is undefined. The result is the modulo result of dividing the first input by the second input. +@smallexample +const signed int __builtin_vsx_xvcmpeqdp_p (signed int, vd, vd); +@end smallexample + +The first argument of the builti-in @code{__builtin_vsx_xvcmpeqdp_p} is an +integer in the range of 0 to 1. The second and third arguments are floating +point vectors to be compared. The result is 1 if the first argument is a 1 +and one or more of the corresponding vector elements are equal. The result is +1 if the first argument is 0 and all of the corresponding vector elements are +not equal. The result is zero otherwise. + The following builtins perform 128-bit vector comparisons. The @code{vec_all_xx}, @code{vec_any_xx}, and @code{vec_cmpxx}, where @code{xx} is one of the operations @code{eq, ne, gt, lt, ge, le} perform pairwise diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-4.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-4.c new file mode 100644 index 00000000000..8ac07c7c807 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-4.c @@ -0,0 +1,135 @@ +/* { dg-do run { target { power10_hw } } } */ +/* { dg-do link { target { ! power10_hw } } } */ +/* { dg-options "-mdejagnu-cpu=power10 -O2 -save-temps" } */ +/* { dg-require-effective-target power10_ok } */ + +#define DEBUG 0 + +#if DEBUG +#include +#include +#endif + +void abort (void); + +int main () +{ + int i; + int result; + vector float vf_arg1, vf_arg2; + vector double d_arg1, d_arg2; + + /* Compare vectors with one equal element, check + for all elements unequal, i.e. first arg is 1. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {1.0, 3.0, 2.0, 8.0}; + result = __builtin_vsx_xvcmpeqsp_p (1, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 1) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 1: arg 1 = 1, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + /* Compare vectors with one equal element, check + for all elements unequal, i.e. first arg is 0. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {1.0, 3.0, 2.0, 8.0}; + result = __builtin_vsx_xvcmpeqsp_p (0, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 0) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 2: arg 1 = 0, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + + /* Compare vectors with all unequal elements, check + for all elements unequal, i.e. first arg is 1. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {8.0, 3.0, 2.0, 8.0}; + result = __builtin_vsx_xvcmpeqsp_p (1, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 0) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 3: arg 1 = 1, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + + /* Compare vectors with all unequal elements, check + for all elements unequal, i.e. first arg is 0. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {8.0, 3.0, 2.0, 8.0}; + result = __builtin_vsx_xvcmpeqsp_p (0, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 1) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 4: arg 1 = 0, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + + /* Compare vectors with all equal elements, check + for all elements equal, i.e. first arg is 1. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {1.0, 2.0, 3.0, 4.0}; + result = __builtin_vsx_xvcmpeqsp_p (1, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 1) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 5: arg 1 = 1, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + + /* Compare vectors with all equal elements, check + for all elements unequal, i.e. first arg is 0. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {1.0, 2.0, 3.0, 4.0}; + result = __builtin_vsx_xvcmpeqsp_p (0, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 0) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 6: arg 0 = 1, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + return 0; +}