From patchwork Fri Apr 19 21:17:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 88770 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 E39493849AF7 for ; Fri, 19 Apr 2024 21:18:53 +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 94ABA384770C for ; Fri, 19 Apr 2024 21:17:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94ABA384770C 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 94ABA384770C 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=1713561454; cv=none; b=mPl3HF7ioDeCuaa1BJzM50Rg6HTzNtN2mrbiz1iFqyBeDEKmg9An4W/DgWHQFT3QX8ylzb7KhXmhFs/AU0xXvFeIlzHt7dq6mfQmv/WoEjDNlnSP0OG7rr2cwHxAZhCttKrqa2jFt+KoN3nPQKB6CSOdPjvpFjlyOF0Vmk914ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713561454; c=relaxed/simple; bh=49c7/yUNBV55Xr723dkad1uMDdoyYGU2mCfaLYqX+gI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=eRBrsj6Za2Ev95hEjuj0SWHR1vFHYaYu24o8DTG4daYpBLmnH3Q10v0/0D/ATbJQX0XcUuE2cCTJ+lsZNMK/kbAKbUtOsVcn6EWxHV4DZa0cDa+KvAeEAZXuv9R31gSiGUmJUPlNVcSbYWbzf1Zj44Z9ESRZBiI6c/FKAH+WC2s= 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 1rxvbs-0001hr-Bn for gcc-patches@gcc.gnu.org; Fri, 19 Apr 2024 17:17:30 -0400 Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JLCXiN005472; Fri, 19 Apr 2024 21:17:27 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=t3nul5opNWNhKHvbnH7uZdkhK+yqzPrFdTTsrCT67x0=; b=BhTZV2nxOx1ttnjm5as942+Bz3En5v6fcNdziNsHFnpooKrHrHK/KPsuPaMbkggp/bO6 oo4rw8NFUbbpXheWN4FT4Zsif1m0JoiOg3pbDM+qut4FwRn0ERZN58UWpmHPwbn7ni6F 9UPn9qejqyAmvV4rQPHqidUnlMlNI+2e2JvvK52ECn5FT0J2TWZA246uW7AKgx9JCW96 VVsT7r2JlgqnUNC1tpa21I1rDjwrb8ZBj+GK0RH/CUprN+3qulM45lHijGfJ0xQ6Hxou jPsp1ZQpOw90zPFVIiADE2eO38b9S2VEHhafttauauw67v6v8ByNkEQpYSM8d8yd8RcY ug== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xm0ap008h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Apr 2024 21:17:26 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43JL4UER007855; Fri, 19 Apr 2024 21:17:25 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3xkbmcx46w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Apr 2024 21:17:25 +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 43JLHMak15991314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 21:17:24 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 31BF658050; Fri, 19 Apr 2024 21:17:22 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7B04758045; Fri, 19 Apr 2024 21:17:21 +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:21 +0000 (GMT) Message-ID: Date: Fri, 19 Apr 2024 14:17:21 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/13] rs6000, fix error in unsigned vector float to unsigned int built-in definitions 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: HZ3xVYeCgdVwdHyCLLBuOUv6TMJyDLdK X-Proofpoint-ORIG-GUID: HZ3xVYeCgdVwdHyCLLBuOUv6TMJyDLdK 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 priorityscore=1501 lowpriorityscore=0 suspectscore=0 mlxscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 adultscore=0 phishscore=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.0 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+patchwork=sourceware.org@gcc.gnu.org rs6000, fix error in unsigned vector float to unsigned int built-in definitions The built-ins __builtin_vsx_vunsigned_v2df and__builtin_vsx_vunsigned_v4sf are supposed to take a vector of floats and return a vector of unsigned long long ints. The definitions are using the signed version of the instructions not the unsigned version of the instruction. The results should also be unsigned. The builtins are used by the overloaded vec_unsigned builtin which has an unsigned result. Similarly the built-ins __builtin_vsx_vunsignede_v2df and __builtin_vsx_vunsignedo_v2df are supposed to retun an unsigned result. If the floating point argument is negative, the unsigned result is zero. The built-ins are used in the overloaded built-in vec_unsignede and vec_unsignedo respectively. Add a test cases for a negative floating point arguments for each of the above built-ins. gcc/ChangeLog: * config/rs6000/rs6000-builtins.def (__builtin_vsx_vunsigned_v2df, __builtin_vsx_vunsigned_v4sf, __builtin_vsx_vunsignede_v2df, __builtin_vsx_vunsignedo_v2df): Change the result type to unsigned. gcc/testsuite/ChangeLog: * gcc.target/powerpc/builtins-3-runnable.c: Add tests for vec_unsignede and vec_unsignedo with negative arguments. --- gcc/config/rs6000/rs6000-builtins.def | 12 +++++----- .../gcc.target/powerpc/builtins-3-runnable.c | 23 ++++++++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index c6d2ea1bc39..bf9a0ae22fc 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -1580,16 +1580,16 @@ const vsi __builtin_vsx_vsignedo_v2df (vd); VEC_VSIGNEDO_V2DF vsignedo_v2df {} - const vsll __builtin_vsx_vunsigned_v2df (vd); - VEC_VUNSIGNED_V2DF vsx_xvcvdpsxds {} + const vull __builtin_vsx_vunsigned_v2df (vd); + VEC_VUNSIGNED_V2DF vsx_xvcvdpuxds {} - const vsi __builtin_vsx_vunsigned_v4sf (vf); - VEC_VUNSIGNED_V4SF vsx_xvcvspsxws {} + const vui __builtin_vsx_vunsigned_v4sf (vf); + VEC_VUNSIGNED_V4SF vsx_xvcvspuxws {} - const vsi __builtin_vsx_vunsignede_v2df (vd); + const vui __builtin_vsx_vunsignede_v2df (vd); VEC_VUNSIGNEDE_V2DF vunsignede_v2df {} - const vsi __builtin_vsx_vunsignedo_v2df (vd); + const vui __builtin_vsx_vunsignedo_v2df (vd); VEC_VUNSIGNEDO_V2DF vunsignedo_v2df {} const vf __builtin_vsx_xscvdpsp (double); diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-3-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtins-3-runnable.c index 0231a1fd086..6d4fe84c8a1 100644 --- a/gcc/testsuite/gcc.target/powerpc/builtins-3-runnable.c +++ b/gcc/testsuite/gcc.target/powerpc/builtins-3-runnable.c @@ -313,6 +313,15 @@ int main() test_unsigned_int_result (ALL, vec_uns_int_result, vec_uns_int_expected); + /* Convert single precision float to unsigned int. Negative + arguments + */ + vec_flt0 = (vector float){-14.930, -834.49, -3.3, -5.4}; + vec_uns_int_expected = (vector unsigned int){0, 0, 0, 0}; + vec_uns_int_result = vec_unsigned (vec_flt0); + test_unsigned_int_result (ALL, vec_uns_int_result, + vec_uns_int_expected); + /* Convert double precision float to long long unsigned int */ vec_dble0 = (vector double){124.930, 8134.49}; vec_ll_uns_int_expected = (vector long long unsigned int){124, 8134}; @@ -321,9 +330,9 @@ int main() vec_ll_uns_int_expected); /* Convert double precision vector float to vector unsigned int, - even words */ - vec_dble0 = (vector double){3124.930, 8234.49}; - vec_uns_int_expected = (vector unsigned int){3124, 0, 8234, 0}; + even words. Negative arguments */ + vec_dble0 = (vector double){-124.930, -234.49}; + vec_uns_int_expected = (vector unsigned int){0, 0, 0, 0}; vec_uns_int_result = vec_unsignede (vec_dble0); test_unsigned_int_result (EVEN, vec_uns_int_result, vec_uns_int_expected); @@ -335,5 +344,13 @@ int main() vec_uns_int_result = vec_unsignedo (vec_dble0); test_unsigned_int_result (ODD, vec_uns_int_result, vec_uns_int_expected); + + /* Convert double precision vector float to vector unsigned int, + odd words. Negative arguments. */ + vec_dble0 = (vector double){-924.930, -1234.49}; + vec_uns_int_expected = (vector unsigned int){0, 0, 0, 0}; + vec_uns_int_result = vec_unsignedo (vec_dble0); + test_unsigned_int_result (ODD, vec_uns_int_result, + vec_uns_int_expected); }