From patchwork Fri Apr 19 21:17:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 1925717 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=lz43JroD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4VLnZv3kkKz1yZP for ; Sat, 20 Apr 2024 07:19:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9CB55384477B for ; Fri, 19 Apr 2024 21:19:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 0E9D53846420 for ; Fri, 19 Apr 2024 21:17:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E9D53846420 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E9D53846420 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713561467; cv=none; b=LQR2w3Ac1FyONgGb99u5KtFKjsXnR14Y+2HkMFcKF63HCma6aOiQbBuxHhDFbvVNSZMFVo6wpnEdwoF/GT/6VNGw0IQDQHmlsVEPFMPCEjh19kpXobPPAYLNmeJHUB827wBVRmRXi9ddP/WmOonicHipnwnyF3kVXSCNuH8fIaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713561467; c=relaxed/simple; bh=lin1oG9kuO666b6fXywxEG/C9WEPT6NA9YCUUcuDqhI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=CH850yB/pcJwLQ93sPc7v/x0TUhkg5uX+ol9dnrZC8/F0eBAr82DGzG6viILFSZUMgjTNG85eTdjxKNovDza2ngMsfgKDCoPhlGXsbO+gMYz+dr2Yv7Od+ytMMPnwBl8Sauc2eZo8uld0iQgmuitXgMd/SRHDvC78Rka+zUs9pw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxvc5-0001ip-Kq for gcc-patches@gcc.gnu.org; Fri, 19 Apr 2024 17:17:44 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JLHe9Q013111; Fri, 19 Apr 2024 21:17:40 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=HxDUMjLSqP1L/cjnFvoQv9fuAx3x+2QnkHoS3DhJU9M=; b=lz43JroDCTWB7dAPk8ngMTyL6xWuI2w1A8PyrhuYngknD/oRTIKhoXw5xmBeqodLl6Z/ 8ElopEP1sgCB1u0LPLasYfWBuIP8dXE9QTRofoVNdXIzWiSn7mMdE6/tJFjLRg4ogTMz pfTPpMzR7MqZVGzVHMuATLcN2jl3xIFIOAyo2uwUWqOfd9RHFDLqhV/cdeYroUqEg+qq 9kM6CmlpteeL85fyS3q1aqYA6hHa3Lc97r4gXJ00pYXNxMtLif8P28ZU1VolFOotcv45 BhjuHGUfsJK5MrMfqCKIYYAOMxLHMOkOyinThwdPTiKMMiuWjTpHK0pkILWaGiEGuNtZ Ug== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xm0d3r008-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Apr 2024 21:17:39 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43JIRs5j020662; Fri, 19 Apr 2024 21:17:38 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xkbm9p38y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Apr 2024 21:17:38 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43JLHZgt12124740 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 21:17:37 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 93B4F58052; Fri, 19 Apr 2024 21:17:35 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB6DD58050; Fri, 19 Apr 2024 21:17:34 +0000 (GMT) Received: from [9.67.133.93] (unknown [9.67.133.93]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 19 Apr 2024 21:17:34 +0000 (GMT) Message-ID: <0519d8a3-38aa-4039-ba02-f88f408eb23f@linux.ibm.com> Date: Fri, 19 Apr 2024 14:17:34 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 4/13] rs6000, extend the current vec_{un,}signed{e,o} built-ins Content-Language: en-US To: gcc-patches@gcc.gnu.org, "bergner@linux.ibm.com" , Segher Boessenkool , "Kewen.Lin" References: <6378d560-df55-4b75-be7b-93dc6b85d81a@linux.ibm.com> From: Carl Love In-Reply-To: <6378d560-df55-4b75-be7b-93dc6b85d81a@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _HfBl6WKigYchVxH4qCbuDhGFoFJEkVg X-Proofpoint-ORIG-GUID: _HfBl6WKigYchVxH4qCbuDhGFoFJEkVg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-19_15,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404190165 Received-SPF: pass client-ip=148.163.156.1; envelope-from=cel@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_SOFTFAIL, 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 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 rs6000, extend the current vec_{un,}signed{e,o} built-ins The built-ins __builtin_vsx_xvcvspsxds and __builtin_vsx_xvcvspuxds convert a vector of floats to signed/unsigned long long ints. Extend the existing vec_{un,}signed{e,o} built-ins to handle the argument vector of floats to return the even/odd signed/unsigned integers. Add testcases and update documentation. gcc/ChangeLog: * config/rs6000/rs6000-builtins.def (__builtin_vsx_xvcvspsxds_low, __builtin_vsx_xvcvspuxds_low): New built-in definitions. * config/rs6000/rs6000-overload.def (vec_signede, vec_signedo): Add new overloaded specifications. * config/rs6000/vsx.md (vsx_xvcvspxds_low): New define_expand. * doc/extend.texi (vec_signedo, vec_signede): Add documentation. gcc/testsuite/ChangeLog: * gcc.target/powerpc/builtins-3-runnable: New tests for the added overloaded built-ins. --- gcc/config/rs6000/rs6000-builtins.def | 6 ++++++ gcc/config/rs6000/rs6000-overload.def | 8 ++++++++ gcc/config/rs6000/vsx.md | 23 +++++++++++++++++++++++ gcc/doc/extend.texi | 13 +++++++++++++ 4 files changed, 50 insertions(+) diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index bf9a0ae22fc..5b7237a2327 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -1709,9 +1709,15 @@ const vsll __builtin_vsx_xvcvspsxds (vf); XVCVSPSXDS vsx_xvcvspsxds {} + const vsll __builtin_vsx_xvcvspsxds_low (vf); + XVCVSPSXDSO vsx_xvcvspsxds_low {} + const vsll __builtin_vsx_xvcvspuxds (vf); XVCVSPUXDS vsx_xvcvspuxds {} + const vsll __builtin_vsx_xvcvspuxds_low (vf); + XVCVSPUXDSO vsx_xvcvspuxds_low {} + const vsi __builtin_vsx_xvcvspuxws (vf); XVCVSPUXWS vsx_fixuns_truncv4sfv4si2 {} diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def index 84bd9ae6554..68501c05289 100644 --- a/gcc/config/rs6000/rs6000-overload.def +++ b/gcc/config/rs6000/rs6000-overload.def @@ -3307,10 +3307,14 @@ [VEC_SIGNEDE, vec_signede, __builtin_vec_vsignede] vsi __builtin_vec_vsignede (vd); VEC_VSIGNEDE_V2DF + vsll __builtin_vec_vsignede (vf); + XVCVSPSXDS [VEC_SIGNEDO, vec_signedo, __builtin_vec_vsignedo] vsi __builtin_vec_vsignedo (vd); VEC_VSIGNEDO_V2DF + vsll __builtin_vec_vsignedo (vf); + XVCVSPSXDSO [VEC_SIGNEXTI, vec_signexti, __builtin_vec_signexti] vsi __builtin_vec_signexti (vsc); @@ -4433,10 +4437,14 @@ [VEC_UNSIGNEDE, vec_unsignede, __builtin_vec_vunsignede] vui __builtin_vec_vunsignede (vd); VEC_VUNSIGNEDE_V2DF + vull __builtin_vec_vunsignede (vf); + XVCVSPUXDS [VEC_UNSIGNEDO, vec_unsignedo, __builtin_vec_vunsignedo] vui __builtin_vec_vunsignedo (vd); VEC_VUNSIGNEDO_V2DF + vull __builtin_vec_vunsignedo (vf); + XVCVSPUXDSO [VEC_VEE, vec_extract_exp, __builtin_vec_extract_exp] vui __builtin_vec_extract_exp (vf); diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index f135fa079bd..3d39ae7995f 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -2704,6 +2704,29 @@ DONE; }) +;; Convert low vector elements of 32-bit floating point numbers to vector of +;; 64-bit signed/unsigned integers. +(define_expand "vsx_xvcvspxds_low" + [(match_operand:V2DI 0 "vsx_register_operand") + (match_operand:V4SF 1 "vsx_register_operand") + (any_fix (pc))] + "VECTOR_UNIT_VSX_P (V2DFmode)" +{ + /* Shift left one word to put even word in correct location */ + rtx rtx_tmp; + rtx rtx_val = GEN_INT (4); + rtx_tmp = gen_reg_rtx (V4SFmode); + emit_insn (gen_altivec_vsldoi_v4sf (rtx_tmp, operands[1], operands[1], + rtx_val)); + + if (BYTES_BIG_ENDIAN) + emit_insn (gen_vsx_xvcvspxds_be (operands[0], rtx_tmp)); + else + emit_insn (gen_vsx_xvcvspxds_le (operands[0], rtx_tmp)); + + DONE; +}) + ;; Generate float2 double ;; convert two double to float (define_expand "float2_v2df" diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 7b54a241a7b..64a43b55e2d 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -22552,6 +22552,19 @@ can use @var{vector long} instead of @var{vector long long}, @var{vector bool long} instead of @var{vector bool long long}, and @var{vector unsigned long} instead of @var{vector unsigned long long}. +@smallexample +vector signed signed long long vec_signedo (vector float); +vector signed signed long long vec_signede (vector float); +vector unsigned signed long long vec_signedo (vector float); +vector unsigned signed long long vec_signede (vector float); +@end smallexample + +The overloaded built-ins @code{vec_signedo} and @code{vec_signede} convert the +even/odd input vector elements to signed/unsigned long long integer values in +addition to the supported arguments and return types documented in the PVIPR. +Negative input values are returned as zero for the unsigned long long return +values. + Only functions excluded from the PVIPR are listed here. @smallexample