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: 203735 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp574375dyc; Tue, 20 Feb 2024 10:04:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWJYAtqTQe65cp6JCtYhNZyAZM5VII7V5TsG0/OttS0wEqEeu4jHKQutYXshyF9oqe+WxOCAwLBNW1I3dQ3vk5t4JlTCA== X-Google-Smtp-Source: AGHT+IEpxGCC57CVw+5Hu0tby86Ey7zqByGHtjJlrcsw/4i8dOVeIJ4imukG0nkq5YLXAfFMyxsn X-Received: by 2002:ac8:5dcd:0:b0:42c:5a27:e35f with SMTP id e13-20020ac85dcd000000b0042c5a27e35fmr18879261qtx.50.1708452281279; Tue, 20 Feb 2024 10:04:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708452281; cv=pass; d=google.com; s=arc-20160816; b=usnmYrMQOX991EsOW2cZDSbyOSnu6xpPoCpDNUj+SmESERPY46mJMnqVjmaLakspAp n0izfGAvEMWtlCY5aXHARyrxxsNC+qHd1v1sfuCBGXo+ISM5gEAq1ZK9EjTHfh/yPu9G I/WMb6RexXl0qst/ISGRWPJEac0d4sp+nbS+tIvegCqsLIJVxpH6mPSn7lqcc7Y9rcv9 vgZWdoy6dE5cK2HGHaziNcGOZkIUS23Sh76ydPoYHLgdkHphnJ/97OorCy6h4TDeUEjR 8yF3ZSgBYQGWvGkqfZoDuf0zZKU5trsOFd31JQFDjB+ekh9HhgwCM5vmDOOr4iD/AuLY bIqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=3s5clqLnXyBYScI+szxemGrCzejB3FkJ2/fEGlzKats=; fh=U4Oxu8wVnBRVc+7Z2YdxYnccRaEmehXwfih2gvmyKwI=; b=pUfWP5XwBBh+SlrVR8rrQ0cgzZLmrqnPwO5/menk8hfW3o/Fuj8YlE9DYARO9kiLsr zXq4dm3MBMenOARIcd/g3mk+j2MTKa6CXGHyZIafYAPskL7YWHcgil1j4TwcCQa+CWBs cmsBGvOw8zVOCOKXbB9qUm0vG7axOoBLHkzgxPQ69LPkY+wFNnFPAVaJhQvBwj9gRu4O tGff8uCT81tN/2Ra+8Ibip17JUna/JuXTXzfCNraNa+7zYX8ihBS6CHWMeMoos527our YenDTGKU3oiKaq+W1JhsAuOIxi7uvH2w0wq+z2gwgvLjSK1f9B4z5Li5VPRvwJhgnlVG OwPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AwsdV5hU; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f20-20020ac84714000000b0042c4d1e2a60si8795194qtp.286.2024.02.20.10.04.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 10:04:41 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AwsdV5hU; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4166385802D for ; Tue, 20 Feb 2024 18:04:12 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791442058959192859 X-GMAIL-MSGID: 1791442058959192859 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; +}