From patchwork Tue Feb 20 17:58:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 1901613 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=AwsdV5hU; 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 4TfS2Y4P9xz20RF for ; Wed, 21 Feb 2024 05:03:49 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 676D6385C6E8 for ; Tue, 20 Feb 2024 18:03:47 +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 B88403858D20 for ; Tue, 20 Feb 2024 17:58:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B88403858D20 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 B88403858D20 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=1708451898; cv=none; b=TMqcr6efcy0k0mXYDbpq0+HdXgch/Rt4LSGxWYEu4aAgeP8ChtFIskScvIMjWHPKXb0TsvfkKFcgckeUQ3GgEWpMKKTLnuHBxLu4eRwzAlGqtzHyyp5DzC+ZT+DX3vd/YW2umIBgtH2+3lpySVUYoHSj4WF3m5S/w8CQ+eqwX/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708451898; c=relaxed/simple; bh=lt2haQ9HKkd/d49f0nRjuFJJxFfHS8n2XGrLaTfA+E0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=BmQFYk95WeQoPtzPV/zj+mkZJSRdaICP1KzvgpYbDnSQBz38/ToBW8rzMObDaZxeLOvWgAMiiJtJ8TchI07vIEPXNIxxViceYEzlF44ZuqTnPXj7Z5YOPRywXeIgt6ajFzl/FLkAplWGkYHBGhbD2H2J17c2RyGtHoO1jkSnXBU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41KHG1QW008092; Tue, 20 Feb 2024 17:58: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=3s5clqLnXyBYScI+szxemGrCzejB3FkJ2/fEGlzKats=; b=AwsdV5hU7jwdAAZH/V+eerVcl92rNkj22c953TQ8Xr+Ba4X/bG1qM7oZrdvFmaP3hcF5 7Xl1ZUbQ3ttpGRG3deR+/NbpD1NEeI4BtWHeY16izPoBABvb7/rF1P8RgV+1q/waYkHv vnB5WtmZiKJffNvwHRHvufe3NVpZMH0e5JfFvi09nIHgbqzT9upoNREhxSVJWIk/dLnw d9XL5d6ldwBjwC6wlNAe/T4hj2rfB33MsWsapdWTwUDmmYnUkuH47+uyXUczILxdJPeA tYdo9xcArdAlnVYxYsyrhpUxl5l9jATUKsUrqIEKoQljjVp42UZXniSKnR2UDrianm4g OQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wcxhvcrwr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Feb 2024 17:58:09 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41KGIEPG031135; Tue, 20 Feb 2024 17:58:09 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wb9bkscsb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Feb 2024 17:58:08 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41KHw5th21889732 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Feb 2024 17:58:07 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79E805805E; Tue, 20 Feb 2024 17:58:05 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B90CB58050; Tue, 20 Feb 2024 17:58:04 +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:58:04 +0000 (GMT) Message-ID: <0ab9ee8c-0bae-4a64-848e-bb05c9698d31@linux.ibm.com> Date: Tue, 20 Feb 2024 09:58:04 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: PATCH 10/11] rs6000, add test cases for __builtin_vec_init* and, __builtin_vec_set* 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: XB8FjRRXVH7v7m5f3M3IYfnFay9CrvVe X-Proofpoint-GUID: XB8FjRRXVH7v7m5f3M3IYfnFay9CrvVe 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 suspectscore=0 bulkscore=0 impostorscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402200129 X-Spam-Status: No, score=-10.0 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 test cases for the __builtin_vec_init* and __builtin_vec_set* 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, add test cases for __builtin_vec_init* and __builtin_vec_set* Add test cases for the following built-ins: __builtin_vec_init_v1ti __builtin_vec_init_v2df __builtin_vec_init_v2di __builtin_vec_set_v1ti __builtin_vec_set_v2df __builtin_vec_set_v2di Note, the above built-ins are documented in extend.texi. gcc/testsuite/ChangeLog: * gcc.target/powerpc/vsx-builtin-21.c: New test file. --- .../gcc.target/powerpc/vsx-builtin-21.c | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-builtin-21.c diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-21.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-21.c new file mode 100644 index 00000000000..b7e1201f37e --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-21.c @@ -0,0 +1,181 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#define DEBUG 0 + +#include + +#if DEBUG +#include +#include + +void print_i128 (__int128_t val) +{ + printf(" %lld %llu (0x%llx %llx)", + (signed long long)(val >> 64), + (unsigned long long)(val & 0xFFFFFFFFFFFFFFFF), + (unsigned long long)(val >> 64), + (unsigned long long)(val & 0xFFFFFFFFFFFFFFFF)); +} +#endif + +void abort (void); + +void test_vec_init_v1ti (__int128_t ti_arg, + vector __int128_t v1ti_expected_result) +{ + vector __int128_t v1ti_result; + + v1ti_result = __builtin_vec_init_v1ti (ti_arg); + if (v1ti_result[0] != v1ti_expected_result[0]) + { +#if DEBUG + printf ("test_vec_init_v1ti: v1ti_result[0] = "); + print_i128 (v1ti_result[0]); + printf( "vf_expected_result[0] = "); + print_i128 (v1ti_expected_result[0]); + printf("\n"); +#else + abort(); +#endif + } +} + +void test_vec_init_v2df (double d_arg1, double d_arg2, + vector double v2df_expected_result) +{ + vector double v2df_result; + int i; + + v2df_result = __builtin_vec_init_v2df (d_arg1, d_arg2); + + for ( i= 0; i < 2; i++) + if (v2df_result[i] != v2df_expected_result[i]) +#if DEBUG + printf ("test_vec_init_v2df: v2df_result[%d] = %f, v2df_expected_result[%d] = %f\n", + i, v2df_result[i], i, v2df_expected_result[i]); +#else + abort(); +#endif +} + +void test_vec_init_v2di (signed long long sl_arg1, signed long long sl_arg2, + vector signed long long v2di_expected_result) +{ + vector signed long long v2di_result; + int i; + + v2di_result = __builtin_vec_init_v2di (sl_arg1, sl_arg2); + + for ( i= 0; i < 2; i++) + if (v2di_result[i] != v2di_expected_result[i]) +#if DEBUG + printf ("test_vec_init_v2di: v2di_result[%d] = %lld, v2df_expected_result[%d] = %lld\n", + i, v2di_result[i], i, v2di_expected_result[i]); +#else + abort(); +#endif +} + +void test_vec_set_v1ti (vector __int128_t v1ti_arg, __int128_t ti_arg, + vector __int128_t v1ti_expected_result) +{ + vector __int128_t v1ti_result; + + v1ti_result = __builtin_vec_set_v1ti (v1ti_arg, ti_arg, 0); + if (v1ti_result[0] != v1ti_expected_result[0]) + { +#if DEBUG + printf ("test_vec_set_v1ti: v1ti_result[0] = "); + print_i128 (v1ti_result[0]); + printf( "vf_expected_result[0] = "); + print_i128 (v1ti_expected_result[0]); + printf("\n"); +#else + abort(); +#endif + } +} + +void test_vec_set_v2df (vector double v2df_arg, double d_arg, + vector double v2df_expected_result) +{ + vector double v2df_result; + int i; + + v2df_result = __builtin_vec_set_v2df (v2df_arg, d_arg, 0); + + for ( i= 0; i < 2; i++) + if (v2df_result[i] != v2df_expected_result[i]) +#if DEBUG + printf ("test_vec_set_v2df: v2df_result[%d] = %f, v2df_expected_result[%d] = %f\n", + i, v2df_result[i], i, v2df_expected_result[i]); +#else + abort(); +#endif +} + +void test_vec_set_v2di (vector signed long long v2di_arg, signed long long sl_arg, + vector signed long long v2di_expected_result) +{ + vector signed long long v2di_result; + int i; + + v2di_result = __builtin_vec_set_v2di (v2di_arg, sl_arg, 1); + + for ( i= 0; i < 2; i++) + if (v2di_result[i] != v2di_expected_result[i]) +#if DEBUG + printf ("test_vec_set_v2di: v2di_result[%d] = %lld, v2df_expected_result[%d] = %lld\n", + i, v2di_result[i], i, v2di_expected_result[i]); +#else + abort(); +#endif +} + +int main () +{ + __int128_t ti_arg1; + vector __int128_t v1ti_arg1, v1ti_expected_result; + double d_arg1, d_arg2; + vector double v2df_arg1, v2df_expected_result; + signed long long sl_arg1, sl_arg2; + vector signed long long v2di_arg1, v2di_expected_result; + + ti_arg1 = 123456789123456789; + ti_arg1 = (ti_arg1 << 64) | 123456789123456789; + v1ti_expected_result = (vector __int128_t) ti_arg1; + test_vec_init_v1ti (ti_arg1, v1ti_expected_result); + + d_arg1 = 123456.2; + d_arg2 = 987654.4; + v2df_expected_result = (vector double) {123456.2, 987654.4}; + test_vec_init_v2df (d_arg1, d_arg2, v2df_expected_result); + + sl_arg1 = 1234560; + sl_arg2 = 9876540; + v2di_expected_result = (vector signed long long) {1234560, 9876540}; + test_vec_init_v2di (sl_arg1, sl_arg2, v2di_expected_result); + + v1ti_arg1 = (vector __int128_t) {987654321987654321}; + ti_arg1 = 12345678; + v1ti_expected_result = (vector __int128_t) {12345678}; + test_vec_set_v1ti (v1ti_arg1, ti_arg1, v1ti_expected_result); + + d_arg1 = 123.123; + v2df_arg1 = (vector double) {12345678.2, 987654.4}; + v2df_expected_result = (vector double) {123.123, 987654.4}; + test_vec_set_v2df (v2df_arg1, d_arg1, v2df_expected_result); + + sl_arg1 = 1234560; + v2di_arg1 = (vector signed long long) {123, 456}; + v2di_expected_result = (vector signed long long) {123, 1234560}; + test_vec_set_v2di (v2di_arg1, sl_arg1, v2di_expected_result); + + return 0; +}