From patchwork Thu Jul 29 07:37:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 1511107 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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=w4yMyLaq; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gb2X53bTSz9sT6 for ; Thu, 29 Jul 2021 17:41:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 327EE3938C35 for ; Thu, 29 Jul 2021 07:41:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 327EE3938C35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627544467; bh=X4RYjL9fi2jKTYN8Ns/nBAOfvIe9Ti1HJMEiztKjQ5s=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=w4yMyLaqcT5RSef90S+aYjKMewWscyD16qAR66tLSMfjz6otNoAzaOL/VTCXtm/hV JwLPS/8DXDcZ9SmmoGF94rrV8v4dxUFIbq6t2ul9unzLiYCx2wigedI9D0sP2dKZ2b 94apCaRmtYFmaIPs04b0gC2tQOYwo6M7aiCng5fU= 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 083C33938C33 for ; Thu, 29 Jul 2021 07:37:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 083C33938C33 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16T7YEVq082700 for ; Thu, 29 Jul 2021 03:37:44 -0400 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 3a3n4tcu47-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 29 Jul 2021 03:37:41 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16T7MxH6021506 for ; Thu, 29 Jul 2021 07:37:35 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma02fra.de.ibm.com with ESMTP id 3a235xs0rk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 29 Jul 2021 07:37:35 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16T7bV7i13959590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jul 2021 07:37:31 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A88842042; Thu, 29 Jul 2021 07:37:31 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 56F8B42052; Thu, 29 Jul 2021 07:37:31 +0000 (GMT) Received: from li-23497a81-5215-11cb-9bae-a81330ecc14b.fritz.box (unknown [9.145.33.167]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 29 Jul 2021 07:37:31 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/5] IBM Z: Get rid of vpdi unspec Date: Thu, 29 Jul 2021 09:37:27 +0200 Message-Id: <20210729073730.23208-3-krebbel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210729073730.23208-1-krebbel@linux.ibm.com> References: <20210729073730.23208-1-krebbel@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sBoljcb8OtOXVw5E7u-qnhOA9LC7VOTK X-Proofpoint-ORIG-GUID: sBoljcb8OtOXVw5E7u-qnhOA9LC7VOTK X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-29_06:2021-07-27, 2021-07-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 suspectscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107290049 X-Spam-Status: No, score=-11.3 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Andreas Krebbel via Gcc-patches From: Andreas Krebbel Reply-To: Andreas Krebbel Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The patch gets rid of the unspec used for the vector permute double immediate instruction and replaces it with generic rtx. gcc/ChangeLog: * config/s390/s390.md (UNSPEC_VEC_PERMI): Remove constant definition. * config/s390/vector.md (*vpdi1, *vpdi4): New pattern definitions. * config/s390/vx-builtins.md (*vec_permi): Emit generic rtx instead of an unspec. gcc/testsuite/ChangeLog: * gcc.target/s390/zvector/vec-permi.c: Removed. * gcc.target/s390/zvector/vec_permi.c: New test. --- gcc/config/s390/s390.md | 1 - gcc/config/s390/vector.md | 26 ++++++++ gcc/config/s390/vx-builtins.md | 26 +++----- .../gcc.target/s390/zvector/vec-permi.c | 54 --------------- .../gcc.target/s390/zvector/vec_permi.c | 66 +++++++++++++++++++ 5 files changed, 102 insertions(+), 71 deletions(-) delete mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec-permi.c create mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec_permi.c diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index d896faee0fb..1b894a926ce 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -166,7 +166,6 @@ (define_c_enum "unspec" [ UNSPEC_VEC_PACK_UNSIGNED_SATURATE_CC UNSPEC_VEC_PACK_UNSIGNED_SATURATE_GENCC UNSPEC_VEC_PERM - UNSPEC_VEC_PERMI UNSPEC_VEC_EXTEND UNSPEC_VEC_STORE_LEN UNSPEC_VEC_STORE_LEN_R diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md index 7507aec1c8e..6a6370b5275 100644 --- a/gcc/config/s390/vector.md +++ b/gcc/config/s390/vector.md @@ -767,6 +767,32 @@ (define_insn "*vec_perm" "vperm\t%v0,%v1,%v2,%v3" [(set_attr "op_type" "VRR")]) + +; First DW of op1 and second DW of op2 +(define_insn "*vpdi1" + [(set (match_operand:V_HW_2 0 "register_operand" "=v") + (vec_select:V_HW_2 + (vec_concat: + (match_operand:V_HW_2 1 "register_operand" "v") + (match_operand:V_HW_2 2 "register_operand" "v")) + (parallel [(const_int 0) (const_int 3)])))] + "TARGET_VX" + "vpdi\t%v0,%v1,%v2,1" + [(set_attr "op_type" "VRR")]) + +; Second DW of op1 and first of op2 +(define_insn "*vpdi4" + [(set (match_operand:V_HW_2 0 "register_operand" "=v") + (vec_select:V_HW_2 + (vec_concat: + (match_operand:V_HW_2 1 "register_operand" "v") + (match_operand:V_HW_2 2 "register_operand" "v")) + (parallel [(const_int 1) (const_int 2)])))] + "TARGET_VX" + "vpdi\t%v0,%v1,%v2,4" + [(set_attr "op_type" "VRR")]) + + (define_insn "*vmrhb" [(set (match_operand:V16QI 0 "register_operand" "=v") (vec_select:V16QI diff --git a/gcc/config/s390/vx-builtins.md b/gcc/config/s390/vx-builtins.md index 5abe43b9e53..3799e833187 100644 --- a/gcc/config/s390/vx-builtins.md +++ b/gcc/config/s390/vx-builtins.md @@ -403,28 +403,22 @@ (define_insn "vec_zperm" "vperm\t%v0,%v1,%v2,%v3" [(set_attr "op_type" "VRR")]) +; Incoming op3 is in vec_permi format and will we turned into a +; permute vector consisting of op3 and op4. (define_expand "vec_permi" - [(set (match_operand:V_HW_64 0 "register_operand" "") - (unspec:V_HW_64 [(match_operand:V_HW_64 1 "register_operand" "") - (match_operand:V_HW_64 2 "register_operand" "") - (match_operand:QI 3 "const_mask_operand" "")] - UNSPEC_VEC_PERMI))] + [(set (match_operand:V_HW_2 0 "register_operand" "") + (vec_select:V_HW_2 + (vec_concat: + (match_operand:V_HW_2 1 "register_operand" "") + (match_operand:V_HW_2 2 "register_operand" "")) + (parallel [(match_operand:QI 3 "const_mask_operand" "") (match_dup 4)])))] "TARGET_VX" { HOST_WIDE_INT val = INTVAL (operands[3]); - operands[3] = GEN_INT ((val & 1) | (val & 2) << 1); + operands[3] = GEN_INT ((val & 2) >> 1); + operands[4] = GEN_INT ((val & 1) + 2); }) -(define_insn "*vec_permi" - [(set (match_operand:V_HW_64 0 "register_operand" "=v") - (unspec:V_HW_64 [(match_operand:V_HW_64 1 "register_operand" "v") - (match_operand:V_HW_64 2 "register_operand" "v") - (match_operand:QI 3 "const_mask_operand" "C")] - UNSPEC_VEC_PERMI))] - "TARGET_VX && (UINTVAL (operands[3]) & 10) == 0" - "vpdi\t%v0,%v1,%v2,%b3" - [(set_attr "op_type" "VRR")]) - ; Vector replicate diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec-permi.c b/gcc/testsuite/gcc.target/s390/zvector/vec-permi.c deleted file mode 100644 index c0a852b9703..00000000000 --- a/gcc/testsuite/gcc.target/s390/zvector/vec-permi.c +++ /dev/null @@ -1,54 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O3 -march=z13 -mzarch --save-temps" } */ -/* { dg-do run { target { s390_z13_hw } } } */ - -/* - * The vector intrinsic vec_permi(a, b, c) chooses one of the two eight-byte - * vector elements in each of a and b, depending on the value of c. The valid - * values for c differ from the encoding for the M4 field in assembly and in the - * binary instruction. - * - * selection | c | encoding in assembly - * a[0] b[0] | 0 | 0 - * a[0] b[1] | 1 | 1 - * a[1] b[0] | 2 | 4 - * a[1] b[1] | 3 | 5 - * - * (i.e., indices a[i] b[j] are encoded for c as (i<<1) | j, yet for the - * M4 field as (i<<2) | j. - */ -#include -#include - -typedef unsigned long long uv2di __attribute__((vector_size(16))); - -__attribute__ ((noipa)) static uv2di -do_vec_permi(uv2di a, uv2di b, int c) -{ - switch(c) { - case 0: return vec_permi(a, b, 0); - case 1: return vec_permi(a, b, 1); - case 2: return vec_permi(a, b, 2); - case 3: return vec_permi(a, b, 3); - default: assert(0); - } -} - -/* { dg-final { scan-assembler-times {\n\tvpdi\t%v\d+,%v\d+,%v\d+,0\n} 1 } } */ -/* { dg-final { scan-assembler-times {\n\tvpdi\t%v\d+,%v\d+,%v\d+,1\n} 1 } } */ -/* { dg-final { scan-assembler-times {\n\tvpdi\t%v\d+,%v\d+,%v\d+,4\n} 1 } } */ -/* { dg-final { scan-assembler-times {\n\tvpdi\t%v\d+,%v\d+,%v\d+,5\n} 1 } } */ - -int -main (void) -{ - uv2di a = { 0xa0, 0xa1 }; - uv2di b = { 0xb0, 0xb1 }; - - for (int i = 0; i < 2; i++) - for (int j = 0; j < 2; j++) { - uv2di res = do_vec_permi(a, b, (i<<1)|j); - assert(res[0] == a[i]); - assert(res[1] == b[j]); - } -} diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec_permi.c b/gcc/testsuite/gcc.target/s390/zvector/vec_permi.c new file mode 100644 index 00000000000..b66fa905dd0 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/zvector/vec_permi.c @@ -0,0 +1,66 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -mzarch -march=z13 -mzvector --save-temps" } */ +/* { dg-do run { target { s390_z13_hw } } } */ + +/* + * The vector intrinsic vec_permi(a, b, c) chooses one of the two eight-byte + * vector elements in each of a and b, depending on the value of c. The valid + * values for c differ from the encoding for the M4 field in assembly and in the + * binary instruction. + * + * selection | c | encoding in assembly + * a[0] b[0] | 0 | 0 -> vmrhg + * a[0] b[1] | 1 | 1 + * a[1] b[0] | 2 | 4 + * a[1] b[1] | 3 | 5 -> vmrlg + * + * (i.e., indices a[i] b[j] are encoded for c as (i<<1) | j, yet for the + * M4 field as (i<<2) | j. + */ + +/* { dg-final { scan-assembler-times "\tvmrhg\t" 3 } } */ +/* { dg-final { scan-assembler-times "\tvmrlg\t" 3 } } */ +/* { dg-final { scan-assembler-times "\tvpdi\t" 6 } } */ + +#include "vec-types.h" +#include + +#define GEN_PERMI_BITS(VEC_TYPE, BITS) \ + VEC_TYPE __attribute__((noinline)) \ + permi_##BITS##_##VEC_TYPE(VEC_TYPE a, VEC_TYPE b) { \ + return vec_permi (a, b, (BITS)); } + +#define GEN_PERMI(VEC_TYPE) \ + GEN_PERMI_BITS(VEC_TYPE, 0); \ + GEN_PERMI_BITS(VEC_TYPE, 1); \ + GEN_PERMI_BITS(VEC_TYPE, 2); \ + GEN_PERMI_BITS(VEC_TYPE, 3); + +GEN_PERMI(v2di) +GEN_PERMI(uv2di) +GEN_PERMI(v2df) + + +#define CHECK_PERMI_BITS(VEC_TYPE, BITS) \ + VEC_TYPE r##BITS = permi_##BITS##_##VEC_TYPE (a, b); \ + if (r##BITS[0] != ((BITS) & 2) >> 1 \ + || r##BITS[1] != ((BITS) & 1) + 2) \ + __builtin_abort(); + +#define CHECK_PERMI(VEC_TYPE) \ + { \ + VEC_TYPE a = GEN_SEQ_VEC (VEC_TYPE, 0); \ + VEC_TYPE b = GEN_SEQ_VEC (VEC_TYPE, 2); \ + CHECK_PERMI_BITS (VEC_TYPE, 0); \ + CHECK_PERMI_BITS (VEC_TYPE, 1); \ + CHECK_PERMI_BITS (VEC_TYPE, 2); \ + CHECK_PERMI_BITS (VEC_TYPE, 3); \ + } + +int +main () +{ + CHECK_PERMI (v2di); + CHECK_PERMI (uv2di); + CHECK_PERMI (v2df); +}