From patchwork Wed Apr 17 09:30:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 88579 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 EB2513858CDA for ; Wed, 17 Apr 2024 09:31:27 +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 070D83858D39 for ; Wed, 17 Apr 2024 09:30:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 070D83858D39 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 070D83858D39 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=1713346247; cv=none; b=oH25xRgUv6RywLbcwFqvZy8oj1lBjTAbbsFLy1h9egpITMV9m/7TJU0W0zw/zi9Mry3g5VFDkwqDo58lg/zdfHa3mKO+4n+mZefYNu/H1KMg3tswlc5CtTE6IgxYpy5MhiDHyBHrlcO5NHCqJAMWrcpavWmzybm/LPzc3Yop+A8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713346247; c=relaxed/simple; bh=GL87YA7wvlg9eTXDVQ5oO7P8mH8O8QMq4Q0c7dsWxLE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=vJBmv3+IOnb0f4Ivgw1iHoxBCOWCnjDOm9pTYVfEuOW3/A63PuQE92iL8q3bvqwBeQTrGd9COifQu5+RWObdo5KkJ6vovobf/8MVRtSv1Tw4zcZiXwe56q72Xqz23jMGqyvbpXdFd56xEo3gq3mxz+9YszKFXE2/g4FSqhUGplU= 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 1rx1co-0002xi-OT for gcc-patches@gcc.gnu.org; Wed, 17 Apr 2024 05:30:44 -0400 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 43H97pUx019792; Wed, 17 Apr 2024 09:30:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : to : cc : from : subject : content-type : content-transfer-encoding; s=pp1; bh=fsUpr8DJQN7Sspu8FAjnkr0LefLI/JT/zWf0z5ZdTss=; b=jEwTmnzbwtNd46kmy0+C1Lh3viJEcOxVsKPQIuRtcob5GiBlU3pVSEAMBcIxFsr+5fGv Ouahz5eqnaCCyL+3RXutnUARvIak/Im1gVz89gbtaG6b1KtuW6VDflCjnDFVr/ARADan TvlVA/uObJKFabceW41QiUono0OInVdP8hXVQd58QyotTLKGl1hvbOo/N5c3uQbTlLGU FyXD1vwCMF7I21eHoT8DicfuZk/ZCyDakXxKodEaClZHbWI83H/pNnd7zKieMwbiuLzz Zuzwf1oiPHrx4IzbgL1bonh5msC3gKf6xdKzeiHnlZmisFVPb1f48xDF2v5RVO49wfmP uw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xjbgvr1jc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Apr 2024 09:30:39 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 43H9UdNE024217; Wed, 17 Apr 2024 09:30:39 GMT 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 3xjbgvr1j9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Apr 2024 09:30: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 43H89LR9027304; Wed, 17 Apr 2024 09:30:37 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xg4s03msm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Apr 2024 09:30:37 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43H9UWHv50921834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Apr 2024 09:30:34 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D87820040; Wed, 17 Apr 2024 09:30:32 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28D152004F; Wed, 17 Apr 2024 09:30:30 +0000 (GMT) Received: from [9.197.232.96] (unknown [9.197.232.96]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 17 Apr 2024 09:30:29 +0000 (GMT) Message-ID: Date: Wed, 17 Apr 2024 17:30:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: GCC Patches Cc: Segher Boessenkool , David Edelsohn , Peter Bergner , Carl Love From: "Kewen.Lin" Subject: [PATCH] testsuite, rs6000: Fix builtins-6-p9-runnable.c for BE [PR114744] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: TsaGIbj20N8gbijTSVlteKBhDl27-PVL X-Proofpoint-ORIG-GUID: yx3Q1UuBZ3kfTOO8tTMNuBP9Sfmu5AHR 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-04-17_08,2024-04-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 bulkscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404170065 Received-SPF: pass client-ip=148.163.156.1; envelope-from=linkw@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=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_LINEPADDING, 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 Hi, Test case builtins-6-p9-runnable.c doesn't work well on BE due to two problems: - When applying vec_xl_len onto data_128 and data_u128 with length 8, it expects to load 1280000[01] from the memory, but unfortunately assigning 1280000[01] to a {vector} {u,}int128 type variable, the value isn't guaranteed to be at the beginning of storage (in the low part of memory), which means the loaded value can be unexpected (as shown on BE). So this patch is to introduce getU128 which can ensure the given value shows up as expected and also update some dumping code for debugging. - When applying vec_xl_len_r with length 16, on BE it's just like the normal vector load, so the expected data should not be reversed from the original. Tested well on both powerpc64{,le}-linux-gnu, I'm going to push this soon. BR, Kewen ----- PR testsuite/114744 gcc/testsuite/ChangeLog: * gcc.target/powerpc/builtins-6-p9-runnable.c: Adjust for BE by fixing data_{u,}128, their uses and vec_uc_expected1, also adjust some formats. --- .../powerpc/builtins-6-p9-runnable.c | 119 ++++++++++-------- 1 file changed, 64 insertions(+), 55 deletions(-) -- 2.43.0 diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-6-p9-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtins-6-p9-runnable.c index 20fdd3bb4ec..36101c2b861 100644 --- a/gcc/testsuite/gcc.target/powerpc/builtins-6-p9-runnable.c +++ b/gcc/testsuite/gcc.target/powerpc/builtins-6-p9-runnable.c @@ -337,6 +337,30 @@ void print_f (vector float vec_expected, } #endif +typedef union +{ + vector __int128_t i1; + __int128_t i2; + vector __uint128_t u1; + __uint128_t u2; + struct + { + long long d1; + long long d2; + }; +} U128; + +/* For a given long long VALUE, ensure it's stored from the beginning + of {u,}int128 memory storage (the low address), it avoids to load + unexpected data without the whole vector length. */ + +static inline void +getU128 (U128 *pu, unsigned long long value) +{ + pu->d1 = value; + pu->d2 = 0; +} + int main() { int i, j; size_t len; @@ -835,21 +859,24 @@ int main() { #endif } + U128 u_temp; /* vec_xl_len() tests */ for (i = 0; i < 100; i++) { - data_c[i] = i; - data_uc[i] = i+1; - data_ssi[i] = i+10; - data_usi[i] = i+11; - data_si[i] = i+100; - data_ui[i] = i+101; - data_sll[i] = i+1000; - data_ull[i] = i+1001; - data_f[i] = i+100000.0; - data_d[i] = i+1000000.0; - data_128[i] = i + 12800000; - data_u128[i] = i + 12800001; + data_c[i] = i; + data_uc[i] = i + 1; + data_ssi[i] = i + 10; + data_usi[i] = i + 11; + data_si[i] = i + 100; + data_ui[i] = i + 101; + data_sll[i] = i + 1000; + data_ull[i] = i + 1001; + data_f[i] = i + 100000.0; + data_d[i] = i + 1000000.0; + getU128 (&u_temp, i + 12800000); + data_128[i] = u_temp.i2; + getU128 (&u_temp, i + 12800001); + data_u128[i] = u_temp.u2; } len = 16; @@ -1160,34 +1187,38 @@ int main() { #endif } - vec_s128_expected1 = (vector __int128_t){12800000}; + getU128 (&u_temp, 12800000); + vec_s128_expected1 = u_temp.i1; vec_s128_result1 = vec_xl_len (data_128, len); if (vec_s128_expected1[0] != vec_s128_result1[0]) { #ifdef DEBUG - printf("Error: vec_xl_len(), len = %d, vec_s128_result1[0] = %lld %llu; ", - len, vec_s128_result1[0] >> 64, - vec_s128_result1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF); - printf("vec_s128_expected1[0] = %lld %llu\n", - vec_s128_expected1[0] >> 64, - vec_s128_expected1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF); + U128 u1, u2; + u1.i1 = vec_s128_result1; + u2.i1 = vec_s128_expected1; + printf ("Error: vec_xl_len(), len = %d," + "vec_s128_result1[0] = %llx %llx; ", + len, u1.d1, u1.d2); + printf ("vec_s128_expected1[0] = %llx %llx\n", u2.d1, u2.d2); #else abort (); #endif } vec_u128_result1 = vec_xl_len (data_u128, len); - vec_u128_expected1 = (vector __uint128_t){12800001}; + getU128 (&u_temp, 12800001); + vec_u128_expected1 = u_temp.u1; if (vec_u128_expected1[0] != vec_u128_result1[0]) #ifdef DEBUG { - printf("Error: vec_xl_len(), len = %d, vec_u128_result1[0] = %lld; ", - len, vec_u128_result1[0] >> 64, - vec_u128_result1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF); - printf("vec_u128_expected1[0] = %lld\n", - vec_u128_expected1[0] >> 64, - vec_u128_expected1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF); + U128 u1, u2; + u1.u1 = vec_u128_result1; + u2.u1 = vec_u128_expected1; + printf ("Error: vec_xl_len(), len = %d," + "vec_u128_result1[0] = %llx %llx; ", + len, u1.d1, u1.d2); + printf ("vec_u128_expected1[0] = %llx %llx\n", u2.d1, u2.d2); } #else abort (); @@ -1421,8 +1452,13 @@ int main() { and post data initialization is done. */ len = 16; - vec_uc_expected1 = (vector unsigned char){ 16,15, 14, 13, 12, 11, 10, 9, - 8, 7, 6, 5, 4, 3, 2, 1 }; +#if __LITTLE_ENDIAN__ + vec_uc_expected1 = (vector unsigned char){16, 15, 14, 13, 12, 11, 10, 9, + 8, 7, 6, 5, 4, 3, 2, 1}; +#else + vec_uc_expected1 = (vector unsigned char){1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16}; +#endif input_uc = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; vec_uc_result1 = vec_xl_len_r (&input_uc[0], len); @@ -1441,30 +1477,3 @@ int main() { } } - - - - - - - - - - - - - - - - - - - - - - - - - - -