From patchwork Fri May 8 20:05:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 1286434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=lF95Mo1l; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49JhCl1Pxqz9sRf for ; Sat, 9 May 2020 06:05:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E04163897826; Fri, 8 May 2020 20:05:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E04163897826 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588968349; bh=sJnBJ1entZK9UaDO74LzOIASB9CwHjykGtwwcR1GTzo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=lF95Mo1l5smtnilL5zvkTzYV3sKANPOqkeioAy8mmLBeb360SfBERuxKjhhrohW13 UkE7CQzZG6rtaMirjZtxbY7c2FaM49h255IN+UWdWl9GlLTPJW5nuiV/YnFppmpYaI 89g1dYmz95qpDBYUEOj/SL4JZazI4npXNfEodxXM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id A9ADD3851C3F; Fri, 8 May 2020 20:05:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A9ADD3851C3F Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 048K2sED145238; Fri, 8 May 2020 16:05:36 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtsrevq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 16:05:36 -0400 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 048K5aL0158647; Fri, 8 May 2020 16:05:36 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtsrevpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 16:05:36 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 048K5JTx010311; Fri, 8 May 2020 20:05:35 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma01dal.us.ibm.com with ESMTP id 30s0g7ht8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 20:05:35 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 048K5XPI60359074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 May 2020 20:05:33 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8C3A6A051; Fri, 8 May 2020 20:05:33 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A92986A058; Fri, 8 May 2020 20:05:33 +0000 (GMT) Received: from localhost (unknown [9.40.194.84]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 8 May 2020 20:05:33 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] rs6000: Add pdepd and pextd Date: Fri, 8 May 2020 15:05:27 -0500 Message-Id: <20200508200527.33139-1-wschmidt@linux.ibm.com> X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-08_18:2020-05-08, 2020-05-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 mlxscore=0 malwarescore=0 clxscore=1015 adultscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080165 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bill Schmidt via Gcc-patches From: Bill Schmidt Reply-To: Bill Schmidt Cc: kelvin@gcc.gnu.org, dje.gcc@gmail.com, segher@kernel.crashing.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" From: Kelvin Nilsen Add scalar instructions for parallel bit deposit and extract, with built-in function support. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Is this okay for master? Thanks, Bill [gcc] 2020-05-08 Kelvin Nilsen * config/rs6000/altivec.h (vec_clrl): New #define. (vec_clrr): Likewise. * config/rs6000/altivec.md (UNSPEC_VCLRLB): New constant. (UNSPEC_VCLRRB): Likewise. (vclrlb): New insn. (vclrrb): Likewise. * config/rs6000/rs6000-builtin.def (__builtin_altivec_vclrlb): New built-in function. (__builtin_altivec_vclrrb): Likewise. (__builtin_vec_clrl): New overloaded built-in function. (__builtin_vec_clrr): Likewise. * config/rs6000/rs6000-call.c (altivec_overloaded_builtins): Define overloaded forms of __builtin_vec_clrl and __builtin_vec_clrr. * doc/extend.texi (PowerPC AltiVec Built-in Functions Available for a Future Architecture): Add descriptions of vec_clrl and vec_clrr. [gcc/testsuite] 2020-05-08 Kelvin Nilsen * gcc.target/powerpc/vec-clrl-0.c: New. * gcc.target/powerpc/vec-clrl-1.c: New. * gcc.target/powerpc/vec-clrr-0.c: New. * gcc.target/powerpc/vec-clrr-1.c: New. --- gcc/config/rs6000/rs6000-builtin.def | 2 + gcc/config/rs6000/rs6000.md | 20 +++++++++ gcc/doc/extend.texi | 16 +++++++ gcc/testsuite/gcc.target/powerpc/pdep-0.c | 48 +++++++++++++++++++++ gcc/testsuite/gcc.target/powerpc/pdep-1.c | 48 +++++++++++++++++++++ gcc/testsuite/gcc.target/powerpc/pextd-0.c | 50 ++++++++++++++++++++++ gcc/testsuite/gcc.target/powerpc/pextd-1.c | 49 +++++++++++++++++++++ 7 files changed, 233 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/pdep-0.c create mode 100644 gcc/testsuite/gcc.target/powerpc/pdep-1.c create mode 100644 gcc/testsuite/gcc.target/powerpc/pextd-0.c create mode 100644 gcc/testsuite/gcc.target/powerpc/pextd-1.c diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index 39e7da5fa50..4b06323a07f 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -2577,6 +2577,8 @@ BU_P9_OVERLOAD_2 (CMPEQB, "byte_in_set") BU_FUTURE_MISC_2 (CFUGED, "cfuged", CONST, cfuged) BU_FUTURE_MISC_2 (CNTLZDM, "cntlzdm", CONST, cntlzdm) BU_FUTURE_MISC_2 (CNTTZDM, "cnttzdm", CONST, cnttzdm) +BU_FUTURE_MISC_2 (PDEPD, "pdepd", CONST, pdepd) +BU_FUTURE_MISC_2 (PEXTD, "pextd", CONST, pextd) /* Future architecture vector built-ins. */ BU_FUTURE_V_2 (VCLRLB, "vclrlb", CONST, vclrlb) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index def48204f86..25af555a0fb 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -151,6 +151,8 @@ (define_c_enum "unspec" UNSPEC_CFUGED UNSPEC_CNTLZDM UNSPEC_CNTTZDM + UNSPEC_PDEPD + UNSPEC_PEXTD ]) ;; @@ -2483,6 +2485,24 @@ (define_insn "cnttzdm" "cnttzdm %0,%1,%2" [(set_attr "type" "integer")]) +(define_insn "pdepd" + [(set (match_operand:DI 0 "register_operand" "=r") + (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "r") + (match_operand:DI 2 "gpc_reg_operand" "r")] + UNSPEC_PDEPD))] + "TARGET_FUTURE && TARGET_POWERPC64" + "pdepd %0,%1,%2" + [(set_attr "type" "integer")]) + +(define_insn "pextd" + [(set (match_operand:DI 0 "register_operand" "=r") + (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "r") + (match_operand:DI 2 "gpc_reg_operand" "r")] + UNSPEC_PEXTD))] + "TARGET_FUTURE && TARGET_POWERPC64" + "pextd %0,%1,%2" + [(set_attr "type" "integer")]) + (define_insn "cmpb3" [(set (match_operand:GPR 0 "gpc_reg_operand" "=r") (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r") diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 104397823b0..9602a310cbb 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -17572,6 +17572,22 @@ Perform a 64-bit count trailing zeros operation under mask, as if implemented by the future @code{cnttzdm} instruction. @findex __builtin_cnttzdm +@smallexample +@exdent unsigned long long int +@exdent __builtin_pdepd (unsigned long long int, unsigned long long int) +@end smallexample +Perform a 64-bit parallel bits deposit operation, as if implemented by the +Future @code{pdepd} instruction. +@findex __builtin_pdepd + +@smallexample +@exdent unsigned long long int +@exdent __builtin_pextd (unsigned long long int, unsigned long long int) +@end smallexample +Perform a 64-bit parallel bits extract operation, as if implemented by the +Future @code{pextd} instruction. +@findex __builtin_pextd + @node PowerPC AltiVec/VSX Built-in Functions @subsection PowerPC AltiVec/VSX Built-in Functions diff --git a/gcc/testsuite/gcc.target/powerpc/pdep-0.c b/gcc/testsuite/gcc.target/powerpc/pdep-0.c new file mode 100644 index 00000000000..5c6afb33169 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pdep-0.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc64 } */ +/* { dg-options "-mcpu=future" } */ + +extern void abort (void); + +unsigned long long int +do_pdepd (unsigned long long int source, unsigned long long int mask) { + return __builtin_pdepd (source, mask); +} + +int main (int argc, char *argv []) +{ + unsigned long long int sources [4], masks [4]; + unsigned long long int results [4][4] = { + /* sources [0] with each of masks [0..3] */ + { 0x7e3c0000ll, 0x00007e3cll, 0x070e030cll, 0x70e030c0ll }, + /* sources [1] with each of masks [0..3] */ + { 0xa5f00000ll, 0x0000a5f0ll, 0x0a050f00ll, 0xa050f000ll }, + /* sources [2] with each of masks [0..3] */ + { 0xf07e0000ll, 0x0000f07ell, 0x0f00070ell, 0xf00070e0ll }, + /* sources [3] with each of masks [0..3] */ + { 0xe7c30000ll, 0x0000e7c3ll, 0x0e070c03ll, 0xe070c030ll }, + }; + + sources[0] = 0xa5f07e3cll; + sources[1] = 0x7e3ca5f0ll; + sources[2] = 0x3ca5f07ell; + sources[3] = 0x5a0fe7c3ll; + + masks[0] = 0xffff0000ll; + masks[1] = 0x0000ffffll; + masks[2] = 0x0f0f0f0fll; + masks[3] = 0xf0f0f0f0ll; + + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + { + if (do_pdepd (sources[i], masks[j]) != results [i][j]) + abort (); + } + } + + return 0; +} + +/* { dg-final { scan-assembler {\mpdepd\M} } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pdep-1.c b/gcc/testsuite/gcc.target/powerpc/pdep-1.c new file mode 100644 index 00000000000..40532ee1177 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pdep-1.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-require-effective-target powerpc_future_hw } */ +/* { dg-require-effective-target powerpc64 } */ +/* { dg-options "-mcpu=future" } */ + +extern void abort (void); + +unsigned long long int +do_pdepd (unsigned long long int source, unsigned long long int mask) { + return __builtin_pdepd (source, mask); +} + +int main (int argc, char *argv []) +{ + unsigned long long int sources [4], masks [4]; + unsigned long long int results [4][4] = { + /* sources [0] with each of masks [0..3] */ + { 0x7e3c0000ll, 0x00007e3cll, 0x070e030cll, 0x70e030c0ll }, + /* sources [1] with each of masks [0..3] */ + { 0xa5f00000ll, 0x0000a5f0ll, 0x0a050f00ll, 0xa050f000ll }, + /* sources [2] with each of masks [0..3] */ + { 0xf07e0000ll, 0x0000f07ell, 0x0f00070ell, 0xf00070e0ll }, + /* sources [3] with each of masks [0..3] */ + { 0xe7c30000ll, 0x0000e7c3ll, 0x0e070c03ll, 0xe070c030ll }, + }; + + sources[0] = 0xa5f07e3cll; + sources[1] = 0x7e3ca5f0ll; + sources[2] = 0x3ca5f07ell; + sources[3] = 0x5a0fe7c3ll; + + masks[0] = 0xffff0000ll; + masks[1] = 0x0000ffffll; + masks[2] = 0x0f0f0f0fll; + masks[3] = 0xf0f0f0f0ll; + + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + { + if (do_pdepd (sources[i], masks[j]) != results [i][j]) + abort (); + } + } + + return 0; +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pextd-0.c b/gcc/testsuite/gcc.target/powerpc/pextd-0.c new file mode 100644 index 00000000000..23a952dc2c6 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pextd-0.c @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc64 } */ +/* { dg-options "-mcpu=future" } */ + +extern void abort (void); + +unsigned long long int +do_pextd (unsigned long long int source, unsigned long long int mask) { + return __builtin_pextd (source, mask); +} + +int main (int argc, char *argv []) +{ + unsigned long long int sources [4], masks [4]; + unsigned long long int results [4][4] = { + /* sources [0] with each of masks [0..3] */ + { 0x0000a5f0ll, 0x00007e3cll, 0x000050ecll, 0x0000af73ll }, + /* sources [1] with each of masks [0..3] */ + { 0x00007e3cll, 0x0000a5f0ll, 0x0000ec50ll, 0x000073afll }, + /* sources [2] with each of masks [0..3] */ + { 0x00003ca5ll, 0x0000f07ell, 0x0000c50ell, 0x00003af7ll }, + /* sources [3] with each of masks [0..3] */ + { 0x00005a0fll, 0x0000e7c3ll, 0x0000af73ll, 0x000050ecll }, + }; + + sources[0] = 0xa5f07e3cll; + sources[1] = 0x7e3ca5f0ll; + sources[2] = 0x3ca5f07ell; + sources[3] = 0x5a0fe7c3ll; + + masks[0] = 0xffff0000ll; + masks[1] = 0x0000ffffll; + masks[2] = 0x0f0f0f0fll; + masks[3] = 0xf0f0f0f0ll; + + unsigned long long int result; + + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + { + if (do_pextd (sources[i], masks[j]) != results [i][j]) + abort (); + } + } + + return 0; +} + +/* { dg-final { scan-assembler {\mpextd\M} } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pextd-1.c b/gcc/testsuite/gcc.target/powerpc/pextd-1.c new file mode 100644 index 00000000000..814ce4325a0 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pextd-1.c @@ -0,0 +1,49 @@ +/* { dg-do run } */ +/* { dg-require-effective-target powerpc_future_hw } */ +/* { dg-require-effective-target powerpc64 } */ +/* { dg-options "-mcpu=future" } */ + +extern void abort (void); + +unsigned long long int +do_pextd (unsigned long long int source, unsigned long long int mask) { + return __builtin_pextd (source, mask); +} + +int main (int argc, char *argv []) +{ + unsigned long long int sources [4], masks [4]; + unsigned long long int results [4][4] = { + /* sources [0] with each of masks [0..3] */ + { 0x0000a5f0ll, 0x00007e3cll, 0x000050ecll, 0x0000af73ll }, + /* sources [1] with each of masks [0..3] */ + { 0x00007e3cll, 0x0000a5f0ll, 0x0000ec50ll, 0x000073afll }, + /* sources [2] with each of masks [0..3] */ + { 0x00003ca5ll, 0x0000f07ell, 0x0000c50ell, 0x00003af7ll }, + /* sources [3] with each of masks [0..3] */ + { 0x00005a0fll, 0x0000e7c3ll, 0x0000af73ll, 0x000050ecll }, + }; + + sources[0] = 0xa5f07e3cll; + sources[1] = 0x7e3ca5f0ll; + sources[2] = 0x3ca5f07ell; + sources[3] = 0x5a0fe7c3ll; + + masks[0] = 0xffff0000ll; + masks[1] = 0x0000ffffll; + masks[2] = 0x0f0f0f0fll; + masks[3] = 0xf0f0f0f0ll; + + unsigned long long int result; + + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + { + if (do_pextd (sources[i], masks[j]) != results [i][j]) + abort (); + } + } + + return 0; +}