From patchwork Tue Feb 20 17:57:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 1901610 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=IixWiqXS; 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 4TfS100nc5z20RF for ; Wed, 21 Feb 2024 05:02:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E588B3857C43 for ; Tue, 20 Feb 2024 18:02:25 +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 373813858424 for ; Tue, 20 Feb 2024 17:58:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 373813858424 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 373813858424 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=1708451887; cv=none; b=wUnDOzYnUzYVqxtjy8jiLftbk/q+POZRZFEbTsScmXDhgh79GNpOkm2d005Bvsdh+iqLDU43+lE6NorPYyn7pjbx4vhGdNEiSGfRfSDRdqvyqvEVO8IOt6Oj21WNxic/yWkmHHlyVwpHWHpYh9kaJqbRtTABjD+roTFF5arlG1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708451887; c=relaxed/simple; bh=XuvaN6im9poTeMdYIZVBx49TwwN69ZDN0d7rkgb3shc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ZdVLOFD8/5AqGLW7GzwDZLr9pg1siJz8Go5IAEQgJa3nmYWwpZTsQt1vxsdNy+H8XN6peeHVsDhwxU4fX2y1mH2rwoSlvYaSb6kYagiwXBA6cgBf/W6OgqOlD5IP5/XK3ZJwjZstDzVFxXsdd/xh2Wv5s+HxMeZiCaT3C1JzpQM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41KGwAar019133; Tue, 20 Feb 2024 17:58:03 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=M4vwXMN8b9leyyAPmn0a65eZYcXSDdJ0Uj7/ZgiZ9aU=; b=IixWiqXSq17SOJ8PojYAo5u1BMXJzeLuxvVwgwI2MYKWpiXwHb3Er66EVeJBbOv/4H5l NX71RmN41MUhfdzuiY64L39CbX2VZavcvA0Kf4dB8Scp3pogDF2ltd0KwGAphLh5VrKY LjkXhcfzAKWcYNFcTekCfURht4LCyPYB97EcfAvZ1DPkuuAPlcLTa+fs55a7GZBe1P+5 JROapp7lkbTcSUF20ZValcH+xxY75kWv4cur5h3M1D8agrQT2EdRHcLWAHe5Z/cpa+Aw bvyDtXIqikzyGSbi0mJNP0MQ0k7zXjZbHwEWy093oU69+io4wbCcE4jy3HhjezD58Ocz 4w== 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 3wd02j1j0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Feb 2024 17:58:03 +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 41KGkPdX013463; Tue, 20 Feb 2024 17:58:02 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wb7h0a1ua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Feb 2024 17:58:02 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41KHvxY815008354 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Feb 2024 17:58:01 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA83F5805F; Tue, 20 Feb 2024 17:57:57 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 26E3A58061; Tue, 20 Feb 2024 17:57:57 +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:57:56 +0000 (GMT) Message-ID: Date: Tue, 20 Feb 2024 09:57:56 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 09/11] rs6000, add test cases for the vec_cmpne built-ins 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-GUID: X2ii6WA30GQIYhaEoSDDp4SyBgqaSrak X-Proofpoint-ORIG-GUID: X2ii6WA30GQIYhaEoSDDp4SyBgqaSrak 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 priorityscore=1501 mlxlogscore=877 lowpriorityscore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 impostorscore=0 clxscore=1015 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 vec_cmpne of 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 the vec_cmpne built-ins Add test cases for the signed int, unsigned it, signed short, unsigned short, signed char and unsigned char built-ins. Note, the built-ins are documented in the Power Vector Instrinsic Programing reference manual. gcc/testsuite/ChangeLog: * gcc.target/powerpc/vec-cmple.c: New test case. * gcc.target/powerpc/vec-cmple.h: New test case include file. --- gcc/testsuite/gcc.target/powerpc/vec-cmple.c | 35 ++++++++ gcc/testsuite/gcc.target/powerpc/vec-cmple.h | 84 ++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/vec-cmple.c create mode 100644 gcc/testsuite/gcc.target/powerpc/vec-cmple.h diff --git a/gcc/testsuite/gcc.target/powerpc/vec-cmple.c b/gcc/testsuite/gcc.target/powerpc/vec-cmple.c new file mode 100644 index 00000000000..766a1c770e2 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vec-cmple.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec -O2" } */ + +/* Test that the vec_cmpne builtin generates the expected Altivec + instructions. */ + +#include "vec-cmple.h" + +int main () +{ + /* Note macro expansions for "signed long long int" and + "unsigned long long int" do not work for the vec_vsx_ld builtin. */ + define_test_functions (int, signed int, signed int, si); + define_test_functions (int, unsigned int, unsigned int, ui); + define_test_functions (short, signed short, signed short, ss); + define_test_functions (short, unsigned short, unsigned short, us); + define_test_functions (char, signed char, signed char, sc); + define_test_functions (char, unsigned char, unsigned char, uc); + + define_init_verify_functions (int, signed int, signed int, si); + define_init_verify_functions (int, unsigned int, unsigned int, ui); + define_init_verify_functions (short, signed short, signed short, ss); + define_init_verify_functions (short, unsigned short, unsigned short, us); + define_init_verify_functions (char, signed char, signed char, sc); + define_init_verify_functions (char, unsigned char, unsigned char, uc); + + execute_test_functions (int, signed int, signed int, si); + execute_test_functions (int, unsigned int, unsigned int, ui); + execute_test_functions (short, signed short, signed short, ss); + execute_test_functions (short, unsigned short, unsigned short, us); + execute_test_functions (char, signed char, signed char, sc); + execute_test_functions (char, unsigned char, unsigned char, uc); + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vec-cmple.h b/gcc/testsuite/gcc.target/powerpc/vec-cmple.h new file mode 100644 index 00000000000..4126706b99a --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vec-cmple.h @@ -0,0 +1,84 @@ +#include "altivec.h" + +#define N 4096 + +#include +void abort (); + +#define PRAGMA(X) _Pragma (#X) +#define UNROLL0 PRAGMA (GCC unroll 0) + +#define define_test_functions(VBTYPE, RTYPE, STYPE, NAME) \ +\ +RTYPE result_le_##NAME[N] __attribute__((aligned(16))); \ +STYPE operand1_##NAME[N] __attribute__((aligned(16))); \ +STYPE operand2_##NAME[N] __attribute__((aligned(16))); \ +RTYPE expected_##NAME[N] __attribute__((aligned(16))); \ +\ +__attribute__((noinline)) void vector_tests_##NAME () \ +{ \ + vector STYPE v1_##NAME, v2_##NAME; \ + vector bool VBTYPE tmp_##NAME; \ + int i; \ + UNROLL0 \ + for (i = 0; i < N; i+=16/sizeof (STYPE)) \ + { \ + /* result_le = operand1!=operand2. */ \ + v1_##NAME = vec_vsx_ld (0, (const vector STYPE*)&operand1_##NAME[i]); \ + v2_##NAME = vec_vsx_ld (0, (const vector STYPE*)&operand2_##NAME[i]); \ +\ + tmp_##NAME = vec_cmple (v1_##NAME, v2_##NAME); \ + vec_vsx_st (tmp_##NAME, 0, &result_le_##NAME[i]); \ + } \ +} + +#define define_init_verify_functions(VBTYPE, RTYPE, STYPE, NAME) \ +__attribute__((noinline)) void init_##NAME () \ +{ \ + int i; \ + for (i = 0; i < N; ++i) \ + { \ + result_le_##NAME[i] = 7; \ + if (i%3 == 0) \ + { \ + /* op1 < op2. */ \ + operand1_##NAME[i] = 1; \ + operand2_##NAME[i] = 2; \ + } \ + else if (i%3 == 1) \ + { \ + /* op1 > op2. */ \ + operand1_##NAME[i] = 2; \ + operand2_##NAME[i] = 1; \ + } \ + else if (i%3 == 2) \ + { \ + /* op1 == op2. */ \ + operand1_##NAME[i] = 3; \ + operand2_##NAME[i] = 3; \ + } \ + /* For vector comparisons: "For each element of the result_le, the \ + value of each bit is 1 if the corresponding elements of ARG1 and \ + ARG2 are equal." {or whatever the comparison is} "Otherwise, the \ + value of each bit is 0." */ \ + expected_##NAME[i] = -1 * (RTYPE)(operand1_##NAME[i] <= operand2_##NAME[i]); \ + } \ +} \ +\ +__attribute__((noinline)) void verify_results_##NAME () \ +{ \ + int i; \ + for (i = 0; i < N; ++i) \ + { \ + if ( (result_le_##NAME[i] != expected_##NAME[i]) ) \ + abort(); \ + } \ +} + +#define execute_test_functions(VBTYPE, RTYPE, STYPE, NAME) \ +{ \ + init_##NAME (); \ + vector_tests_##NAME (); \ + verify_results_##NAME (); \ +} +