From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104488 invoked by alias); 27 Nov 2015 11:42:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 104424 invoked by uid 89); 27 Nov 2015 11:42:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: e06smtp13.uk.ibm.com Received: from e06smtp13.uk.ibm.com (HELO e06smtp13.uk.ibm.com) (195.75.94.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 27 Nov 2015 11:42:00 +0000 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Nov 2015 11:41:57 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 27 Nov 2015 11:41:55 -0000 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: krebbel@linux.vnet.ibm.com X-IBM-RcptTo: gcc-patches@gcc.gnu.org Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 633CC219005E for ; Fri, 27 Nov 2015 11:41:48 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tARBfsSI57344116 for ; Fri, 27 Nov 2015 11:41:54 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tARBfs32028448 for ; Fri, 27 Nov 2015 04:41:54 -0700 Received: from maggie.ibm.com (icon-9-164-144-161.megacenter.de.ibm.com [9.164.144.161]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tARBfqvn028272 (version=TLSv1/SSLv3 cipher=AES256-SHA256 bits=256 verify=NO) for ; Fri, 27 Nov 2015 04:41:54 -0700 From: Andreas Krebbel To: gcc-patches@gcc.gnu.org Subject: [PATCH 5/7] S/390: Fix vec_splat_* builtins. Date: Fri, 27 Nov 2015 11:43:00 -0000 Message-Id: <1448624512-22364-6-git-send-email-krebbel@linux.vnet.ibm.com> In-Reply-To: <1448624512-22364-1-git-send-email-krebbel@linux.vnet.ibm.com> References: <1448624512-22364-1-git-send-email-krebbel@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15112711-0013-0000-0000-000007C92C5B X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg03342.txt.bz2 This enables the vec_splat_* builtins to make use of vrepi for constant operands. gcc/testsuite/ChangeLog: 2015-11-27 Andreas Krebbel * gcc.target/s390/zvector/vec-splat-2.c: New test. gcc/ChangeLog: 2015-11-27 Andreas Krebbel * config/s390/s390-builtin-types.def: New builtin types added. * config/s390/s390-builtins.def: Add s390_vec_splat_* definitions. * config/s390/s390.c (s390_expand_builtin): Always truncate constants to the mode in the pattern. * config/s390/vecintrin.h: Let the vec_splat_* macros point to the respective builtin __builtin_s390_vec_splat_*. --- gcc/config/s390/s390-builtin-types.def | 3 ++ gcc/config/s390/s390-builtins.def | 9 +++++ gcc/config/s390/s390.c | 9 +++++ gcc/config/s390/vecintrin.h | 16 ++++----- .../gcc.target/s390/zvector/vec-splat-2.c | 42 ++++++++++++++++++++++ 5 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec-splat-2.c diff --git a/gcc/config/s390/s390-builtin-types.def b/gcc/config/s390/s390-builtin-types.def index 724e0b6..bd3d534 100644 --- a/gcc/config/s390/s390-builtin-types.def +++ b/gcc/config/s390/s390-builtin-types.def @@ -139,16 +139,19 @@ DEF_FN_TYPE_2 (BT_FN_UV16QI_USHORT, B_VX, BT_UV16QI, BT_USHORT) DEF_FN_TYPE_2 (BT_FN_UV16QI_UV16QI, B_VX, BT_UV16QI, BT_UV16QI) DEF_FN_TYPE_2 (BT_FN_UV2DI_ULONGLONG, B_VX, BT_UV2DI, BT_ULONGLONG) DEF_FN_TYPE_2 (BT_FN_UV2DI_ULONGLONGCONSTPTR, B_VX, BT_UV2DI, BT_ULONGLONGCONSTPTR) +DEF_FN_TYPE_2 (BT_FN_UV2DI_USHORT, B_VX, BT_UV2DI, BT_USHORT) DEF_FN_TYPE_2 (BT_FN_UV2DI_UV2DI, B_VX, BT_UV2DI, BT_UV2DI) DEF_FN_TYPE_2 (BT_FN_UV2DI_UV4SI, B_VX, BT_UV2DI, BT_UV4SI) DEF_FN_TYPE_2 (BT_FN_UV4SI_UINT, B_VX, BT_UV4SI, BT_UINT) DEF_FN_TYPE_2 (BT_FN_UV4SI_UINTCONSTPTR, B_VX, BT_UV4SI, BT_UINTCONSTPTR) +DEF_FN_TYPE_2 (BT_FN_UV4SI_USHORT, B_VX, BT_UV4SI, BT_USHORT) DEF_FN_TYPE_2 (BT_FN_UV4SI_UV4SI, B_VX, BT_UV4SI, BT_UV4SI) DEF_FN_TYPE_2 (BT_FN_UV4SI_UV8HI, B_VX, BT_UV4SI, BT_UV8HI) DEF_FN_TYPE_2 (BT_FN_UV8HI_USHORT, B_VX, BT_UV8HI, BT_USHORT) DEF_FN_TYPE_2 (BT_FN_UV8HI_USHORTCONSTPTR, B_VX, BT_UV8HI, BT_USHORTCONSTPTR) DEF_FN_TYPE_2 (BT_FN_UV8HI_UV16QI, B_VX, BT_UV8HI, BT_UV16QI) DEF_FN_TYPE_2 (BT_FN_UV8HI_UV8HI, B_VX, BT_UV8HI, BT_UV8HI) +DEF_FN_TYPE_2 (BT_FN_V16QI_SCHAR, B_VX, BT_V16QI, BT_SCHAR) DEF_FN_TYPE_2 (BT_FN_V16QI_UCHAR, B_VX, BT_V16QI, BT_UCHAR) DEF_FN_TYPE_2 (BT_FN_V16QI_V16QI, B_VX, BT_V16QI, BT_V16QI) DEF_FN_TYPE_2 (BT_FN_V2DF_DBL, B_VX, BT_V2DF, BT_DBL) diff --git a/gcc/config/s390/s390-builtins.def b/gcc/config/s390/s390-builtins.def index b267b04..0b6961e 100644 --- a/gcc/config/s390/s390-builtins.def +++ b/gcc/config/s390/s390-builtins.def @@ -362,6 +362,15 @@ B_DEF (s390_vrepih, vec_splatsv8hi, 0, B_DEF (s390_vrepif, vec_splatsv4si, 0, B_VX, O1_S16, BT_FN_V4SI_SHORT) B_DEF (s390_vrepig, vec_splatsv2di, 0, B_VX, O1_S16, BT_FN_V2DI_SHORT) +B_DEF (s390_vec_splat_u8, vec_splatsv16qi, 0, B_VX, O1_U8, BT_FN_UV16QI_UCHAR) +B_DEF (s390_vec_splat_s8, vec_splatsv16qi, 0, B_VX, O1_S8, BT_FN_V16QI_SCHAR) +B_DEF (s390_vec_splat_u16, vec_splatsv8hi, 0, B_VX, O1_U16, BT_FN_UV8HI_USHORT) +B_DEF (s390_vec_splat_s16, vec_splatsv8hi, 0, B_VX, O1_S16, BT_FN_V8HI_SHORT) +B_DEF (s390_vec_splat_u32, vec_splatsv4si, 0, B_VX, O1_U16, BT_FN_UV4SI_USHORT) +B_DEF (s390_vec_splat_s32, vec_splatsv4si, 0, B_VX, O1_S16, BT_FN_V4SI_SHORT) +B_DEF (s390_vec_splat_u64, vec_splatsv2di, 0, B_VX, O1_U16, BT_FN_UV2DI_USHORT) +B_DEF (s390_vec_splat_s64, vec_splatsv2di, 0, B_VX, O1_S16, BT_FN_V2DI_SHORT) + OB_DEF (s390_vec_insert, s390_vec_insert_s8, s390_vec_insert_dbl,B_VX, BT_FN_OV4SI_INT_OV4SI_INT) OB_DEF_VAR (s390_vec_insert_s8, s390_vlvgb, O3_ELEM, BT_OV_V16QI_SCHAR_V16QI_INT) OB_DEF_VAR (s390_vec_insert_u8, s390_vlvgb, O3_ELEM, BT_OV_UV16QI_UCHAR_UV16QI_INT) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index e872423..2c8bbdc 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -835,6 +835,15 @@ s390_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED, insn_op = &insn_data[icode].operand[arity + nonvoid]; op[arity] = expand_expr (arg, NULL_RTX, insn_op->mode, EXPAND_NORMAL); + /* expand_expr truncates constants to the target mode only if it + is "convenient". However, our checks below rely on this + being done. */ + if (CONST_INT_P (op[arity]) + && SCALAR_INT_MODE_P (insn_op->mode) + && GET_MODE (op[arity]) != insn_op->mode) + op[arity] = GEN_INT (trunc_int_for_mode (INTVAL (op[arity]), + insn_op->mode)); + /* Wrap the expanded RTX for pointer types into a MEM expr with the proper mode. This allows us to use e.g. (match_operand "memory_operand"..) in the insn patterns instead of (mem diff --git a/gcc/config/s390/vecintrin.h b/gcc/config/s390/vecintrin.h index 2e26e3a..c24dcb4 100644 --- a/gcc/config/s390/vecintrin.h +++ b/gcc/config/s390/vecintrin.h @@ -67,14 +67,14 @@ __lcbb(const void *ptr, int bndry) #define vec_genmasks_16 __builtin_s390_vgmh #define vec_genmasks_32 __builtin_s390_vgmf #define vec_genmasks_64 __builtin_s390_vgmg -#define vec_splat_u8 __builtin_s390_vlrepb -#define vec_splat_s8 __builtin_s390_vlrepb -#define vec_splat_u16 __builtin_s390_vlreph -#define vec_splat_s16 __builtin_s390_vlreph -#define vec_splat_u32 __builtin_s390_vlrepf -#define vec_splat_s32 __builtin_s390_vlrepf -#define vec_splat_u64 __builtin_s390_vlrepg -#define vec_splat_s64 __builtin_s390_vlrepg +#define vec_splat_u8 __builtin_s390_vec_splat_u8 +#define vec_splat_s8 __builtin_s390_vec_splat_s8 +#define vec_splat_u16 __builtin_s390_vec_splat_u16 +#define vec_splat_s16 __builtin_s390_vec_splat_s16 +#define vec_splat_u32 __builtin_s390_vec_splat_u32 +#define vec_splat_s32 __builtin_s390_vec_splat_s32 +#define vec_splat_u64 __builtin_s390_vec_splat_u64 +#define vec_splat_s64 __builtin_s390_vec_splat_s64 #define vec_add_u128 __builtin_s390_vaq #define vec_addc_u128 __builtin_s390_vaccq #define vec_adde_u128 __builtin_s390_vacq diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec-splat-2.c b/gcc/testsuite/gcc.target/s390/zvector/vec-splat-2.c new file mode 100644 index 0000000..7ad090b --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/zvector/vec-splat-2.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -mzarch -march=z13 -mzvector" } */ + +#include + +vector signed char v16qi; +vector short v8hi; +vector int v4si; +vector long long v2di; + +vector unsigned char uv16qi; +vector unsigned short uv8hi; +vector unsigned int uv4si; +vector unsigned long long uv2di; + +int +foo () +{ + v16qi = vec_splat_s8 (-112); + uv16qi = vec_splat_u8 (215); + + v8hi = vec_splat_s16 (-32000); + uv8hi = vec_splat_u16 (64000); + + v4si = vec_splat_s32 (-32000); + uv4si = vec_splat_u32 (64000); + + v2di = vec_splat_s64 (-32000); + uv2di = vec_splat_u64 (64000); +} + +/* { dg-final { scan-assembler-times "vrepib\t%v.*,-112" 1 } } */ +/* { dg-final { scan-assembler-times "vrepib\t%v.*,-41" 1 } } */ + +/* { dg-final { scan-assembler-times "vrepih\t%v.*,-32000" 1 } } */ +/* { dg-final { scan-assembler-times "vrepih\t%v.*,-1536" 1 } } */ + +/* { dg-final { scan-assembler-times "vrepif\t%v.*,-32000" 1 } } */ +/* { dg-final { scan-assembler-times "vrepif\t%v.*,-1536" 1 } } */ + +/* { dg-final { scan-assembler-times "vrepig\t%v.*,-32000" 1 } } */ +/* { dg-final { scan-assembler-times "vrepig\t%v.*,-1536" 1 } } */ -- 2.3.0