From 49adc4618014f627ea2420de215899c038c976ec Mon Sep 17 00:00:00 2001 From: Andreas Krebbel Date: Tue, 2 Apr 2019 11:08:54 +0000 Subject: [PATCH] S/390: arch13: vector string search builtins gcc/ChangeLog: 2019-04-02 Andreas Krebbel * config/s390/s390-builtin-types.def: New builtin function type definitions. * config/s390/s390-builtins.def (s390_vec_search_string_cc) (s390_vec_search_string_until_zero_cc): New overloaded builtins. (s390_vstrsb, s390_vstrsh, s390_vstrsf, s390_vstrszb) (s390_vstrszh, s390_vstrszf): New low-level builtins. * config/s390/s390.md (UNSPEC_VEC_VSTRS, UNSPEC_VEC_VSTRSCC): New constant definitions. * config/s390/vecintrin.h (vec_search_string_cc) (vec_search_string_until_zero_cc): New builtin name definitions. * config/s390/vx-builtins.md ("vstrs", "vstrsz"): New expanders. ("vec_vstrs"): New insn definition. gcc/testsuite/ChangeLog: 2019-04-02 Andreas Krebbel * gcc.target/s390/zvector/vec-search-string-cc-1.c: New test. * gcc.target/s390/zvector/vec-search-string-cc-compile.c: New test. * gcc.target/s390/zvector/vec-search-string-until-zero-cc-1.c: New test. * gcc.target/s390/zvector/vec-search-string-until-zero-cc-compile.c: New test. From-SVN: r270090 --- gcc/ChangeLog | 16 +++++ gcc/config/s390/s390-builtin-types.def | 11 +++ gcc/config/s390/s390-builtins.def | 30 ++++++++ gcc/config/s390/s390.md | 3 + gcc/config/s390/vecintrin.h | 2 + gcc/config/s390/vx-builtins.md | 68 +++++++++++++++++++ gcc/testsuite/ChangeLog | 7 ++ .../s390/zvector/vec-search-string-cc-1.c | 36 ++++++++++ .../zvector/vec-search-string-cc-compile.c | 47 +++++++++++++ .../vec-search-string-until-zero-cc-1.c | 37 ++++++++++ .../vec-search-string-until-zero-cc-compile.c | 47 +++++++++++++ 11 files changed, 304 insertions(+) create mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec-search-string-cc-1.c create mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec-search-string-cc-compile.c create mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec-search-string-until-zero-cc-1.c create mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec-search-string-until-zero-cc-compile.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bfc101f3754..149570703af 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2019-04-02 Andreas Krebbel + + * config/s390/s390-builtin-types.def: New builtin function type + definitions. + * config/s390/s390-builtins.def (s390_vec_search_string_cc) + (s390_vec_search_string_until_zero_cc): New overloaded builtins. + (s390_vstrsb, s390_vstrsh, s390_vstrsf, s390_vstrszb) + (s390_vstrszh, s390_vstrszf): New low-level builtins. + * config/s390/s390.md (UNSPEC_VEC_VSTRS, UNSPEC_VEC_VSTRSCC): New + constant definitions. + * config/s390/vecintrin.h (vec_search_string_cc) + (vec_search_string_until_zero_cc): New builtin name definitions. + * config/s390/vx-builtins.md ("vstrs", "vstrsz"): New + expanders. + ("vec_vstrs"): New insn definition. + 2019-04-02 Andreas Krebbel * config/s390/s390-builtin-types.def: Add new builtin function diff --git a/gcc/config/s390/s390-builtin-types.def b/gcc/config/s390/s390-builtin-types.def index c0dd2086cde..fc73d1f6731 100644 --- a/gcc/config/s390/s390-builtin-types.def +++ b/gcc/config/s390/s390-builtin-types.def @@ -351,14 +351,17 @@ DEF_FN_TYPE_4 (BT_FN_OV4SI_OV4SI_OUV4SI_INTCONSTPTR_UCHAR, BT_OV4SI, BT_OV4SI, B DEF_FN_TYPE_4 (BT_FN_OV4SI_OV4SI_OV4SI_OV4SI_INTPTR, BT_OV4SI, BT_OV4SI, BT_OV4SI, BT_OV4SI, BT_INTPTR) DEF_FN_TYPE_4 (BT_FN_UV16QI_UV16QI_UV16QI_INT_INTPTR, BT_UV16QI, BT_UV16QI, BT_UV16QI, BT_INT, BT_INTPTR) DEF_FN_TYPE_4 (BT_FN_UV16QI_UV16QI_UV16QI_UV16QI_INT, BT_UV16QI, BT_UV16QI, BT_UV16QI, BT_UV16QI, BT_INT) +DEF_FN_TYPE_4 (BT_FN_UV16QI_UV16QI_UV16QI_UV16QI_INTPTR, BT_UV16QI, BT_UV16QI, BT_UV16QI, BT_UV16QI, BT_INTPTR) DEF_FN_TYPE_4 (BT_FN_UV16QI_UV2DI_UV2DI_UV16QI_INT, BT_UV16QI, BT_UV2DI, BT_UV2DI, BT_UV16QI, BT_INT) DEF_FN_TYPE_4 (BT_FN_UV2DI_UV2DI_UV2DI_ULONGLONGCONSTPTR_UCHAR, BT_UV2DI, BT_UV2DI, BT_UV2DI, BT_ULONGLONGCONSTPTR, BT_UCHAR) DEF_FN_TYPE_4 (BT_FN_UV2DI_UV2DI_UV2DI_UV2DI_INT, BT_UV2DI, BT_UV2DI, BT_UV2DI, BT_UV2DI, BT_INT) DEF_FN_TYPE_4 (BT_FN_UV4SI_UV4SI_UV4SI_INT_INTPTR, BT_UV4SI, BT_UV4SI, BT_UV4SI, BT_INT, BT_INTPTR) DEF_FN_TYPE_4 (BT_FN_UV4SI_UV4SI_UV4SI_UINTCONSTPTR_UCHAR, BT_UV4SI, BT_UV4SI, BT_UV4SI, BT_UINTCONSTPTR, BT_UCHAR) DEF_FN_TYPE_4 (BT_FN_UV4SI_UV4SI_UV4SI_UV4SI_INT, BT_UV4SI, BT_UV4SI, BT_UV4SI, BT_UV4SI, BT_INT) +DEF_FN_TYPE_4 (BT_FN_UV4SI_UV4SI_UV4SI_UV8HI_INTPTR, BT_UV4SI, BT_UV4SI, BT_UV4SI, BT_UV8HI, BT_INTPTR) DEF_FN_TYPE_4 (BT_FN_UV8HI_UV8HI_UV8HI_INT_INTPTR, BT_UV8HI, BT_UV8HI, BT_UV8HI, BT_INT, BT_INTPTR) DEF_FN_TYPE_4 (BT_FN_UV8HI_UV8HI_UV8HI_UV8HI_INT, BT_UV8HI, BT_UV8HI, BT_UV8HI, BT_UV8HI, BT_INT) +DEF_FN_TYPE_4 (BT_FN_UV8HI_UV8HI_UV8HI_UV8HI_INTPTR, BT_UV8HI, BT_UV8HI, BT_UV8HI, BT_UV8HI, BT_INTPTR) DEF_FN_TYPE_4 (BT_FN_VOID_UV2DI_UV2DI_ULONGLONGPTR_ULONGLONG, BT_VOID, BT_UV2DI, BT_UV2DI, BT_ULONGLONGPTR, BT_ULONGLONG) DEF_FN_TYPE_4 (BT_FN_VOID_UV4SI_UV4SI_UINTPTR_ULONGLONG, BT_VOID, BT_UV4SI, BT_UV4SI, BT_UINTPTR, BT_ULONGLONG) DEF_FN_TYPE_4 (BT_FN_VOID_V4SI_V4SI_INTPTR_ULONGLONG, BT_VOID, BT_V4SI, BT_V4SI, BT_INTPTR, BT_ULONGLONG) @@ -495,7 +498,10 @@ DEF_OV_TYPE (BT_OV_USHORT_BV8HI_INT, BT_USHORT, BT_BV8HI, BT_INT) DEF_OV_TYPE (BT_OV_USHORT_UV8HI_INT, BT_USHORT, BT_UV8HI, BT_INT) DEF_OV_TYPE (BT_OV_UV16QI_BV16QI_BV16QI, BT_UV16QI, BT_BV16QI, BT_BV16QI) DEF_OV_TYPE (BT_OV_UV16QI_BV16QI_BV16QI_INTPTR, BT_UV16QI, BT_BV16QI, BT_BV16QI, BT_INTPTR) +DEF_OV_TYPE (BT_OV_UV16QI_BV16QI_BV16QI_UV16QI_INTPTR, BT_UV16QI, BT_BV16QI, BT_BV16QI, BT_UV16QI, BT_INTPTR) DEF_OV_TYPE (BT_OV_UV16QI_BV16QI_UV16QI, BT_UV16QI, BT_BV16QI, BT_UV16QI) +DEF_OV_TYPE (BT_OV_UV16QI_BV4SI_BV4SI_UV16QI_INTPTR, BT_UV16QI, BT_BV4SI, BT_BV4SI, BT_UV16QI, BT_INTPTR) +DEF_OV_TYPE (BT_OV_UV16QI_BV8HI_BV8HI_UV16QI_INTPTR, BT_UV16QI, BT_BV8HI, BT_BV8HI, BT_UV16QI, BT_INTPTR) DEF_OV_TYPE (BT_OV_UV16QI_LONG_UCHARCONSTPTR, BT_UV16QI, BT_LONG, BT_UCHARCONSTPTR) DEF_OV_TYPE (BT_OV_UV16QI_UCHAR, BT_UV16QI, BT_UCHAR) DEF_OV_TYPE (BT_OV_UV16QI_UCHARCONSTPTR, BT_UV16QI, BT_UCHARCONSTPTR) @@ -523,10 +529,15 @@ DEF_OV_TYPE (BT_OV_UV16QI_UV16QI_UV8HI, BT_UV16QI, BT_UV16QI, BT_UV8HI) DEF_OV_TYPE (BT_OV_UV16QI_UV16QI_V16QI, BT_UV16QI, BT_UV16QI, BT_V16QI) DEF_OV_TYPE (BT_OV_UV16QI_UV2DI_UV2DI, BT_UV16QI, BT_UV2DI, BT_UV2DI) DEF_OV_TYPE (BT_OV_UV16QI_UV4SI_UV4SI, BT_UV16QI, BT_UV4SI, BT_UV4SI) +DEF_OV_TYPE (BT_OV_UV16QI_UV4SI_UV4SI_UV16QI_INTPTR, BT_UV16QI, BT_UV4SI, BT_UV4SI, BT_UV16QI, BT_INTPTR) DEF_OV_TYPE (BT_OV_UV16QI_UV8HI_UV8HI, BT_UV16QI, BT_UV8HI, BT_UV8HI) DEF_OV_TYPE (BT_OV_UV16QI_UV8HI_UV8HI_INTPTR, BT_UV16QI, BT_UV8HI, BT_UV8HI, BT_INTPTR) +DEF_OV_TYPE (BT_OV_UV16QI_UV8HI_UV8HI_UV16QI_INTPTR, BT_UV16QI, BT_UV8HI, BT_UV8HI, BT_UV16QI, BT_INTPTR) DEF_OV_TYPE (BT_OV_UV16QI_V16QI, BT_UV16QI, BT_V16QI) +DEF_OV_TYPE (BT_OV_UV16QI_V16QI_V16QI_UV16QI_INTPTR, BT_UV16QI, BT_V16QI, BT_V16QI, BT_UV16QI, BT_INTPTR) +DEF_OV_TYPE (BT_OV_UV16QI_V4SI_V4SI_UV16QI_INTPTR, BT_UV16QI, BT_V4SI, BT_V4SI, BT_UV16QI, BT_INTPTR) DEF_OV_TYPE (BT_OV_UV16QI_V8HI_V8HI, BT_UV16QI, BT_V8HI, BT_V8HI) +DEF_OV_TYPE (BT_OV_UV16QI_V8HI_V8HI_UV16QI_INTPTR, BT_UV16QI, BT_V8HI, BT_V8HI, BT_UV16QI, BT_INTPTR) DEF_OV_TYPE (BT_OV_UV2DI_BV2DI_UV2DI, BT_UV2DI, BT_BV2DI, BT_UV2DI) DEF_OV_TYPE (BT_OV_UV2DI_LONG_ULONGLONGCONSTPTR, BT_UV2DI, BT_LONG, BT_ULONGLONGCONSTPTR) DEF_OV_TYPE (BT_OV_UV2DI_ULONGLONG, BT_UV2DI, BT_ULONGLONG) diff --git a/gcc/config/s390/s390-builtins.def b/gcc/config/s390/s390-builtins.def index 6ee921d2499..108f997720c 100644 --- a/gcc/config/s390/s390-builtins.def +++ b/gcc/config/s390/s390-builtins.def @@ -2951,3 +2951,33 @@ OB_DEF_VAR (s390_vec_srdb_flt, s390_vsrd, 0, OB_DEF_VAR (s390_vec_srdb_dbl, s390_vsrd, 0, O3_U3, BT_OV_V2DF_V2DF_V2DF_UINT) B_DEF (s390_vsrd, vec_srdbv16qi, 0, B_VXE2, O3_U3, BT_FN_UV16QI_UV16QI_UV16QI_INT) + +OB_DEF (s390_vec_search_string_cc, s390_vstrs_s8, s390_vstrs_u32, B_VXE2, BT_FN_OV4SI_OV4SI_OV4SI_OV4SI_INTPTR) +OB_DEF_VAR (s390_vstrs_s8, s390_vstrsb, 0, 0, BT_OV_UV16QI_V16QI_V16QI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrs_b8, s390_vstrsb, 0, 0, BT_OV_UV16QI_BV16QI_BV16QI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrs_u8, s390_vstrsb, 0, 0, BT_OV_UV16QI_UV16QI_UV16QI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrs_s16, s390_vstrsh, 0, 0, BT_OV_UV16QI_V8HI_V8HI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrs_b16, s390_vstrsh, 0, 0, BT_OV_UV16QI_BV8HI_BV8HI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrs_u16, s390_vstrsh, 0, 0, BT_OV_UV16QI_UV8HI_UV8HI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrs_s32, s390_vstrsf, 0, 0, BT_OV_UV16QI_V4SI_V4SI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrs_b32, s390_vstrsf, 0, 0, BT_OV_UV16QI_BV4SI_BV4SI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrs_u32, s390_vstrsf, 0, 0, BT_OV_UV16QI_UV4SI_UV4SI_UV16QI_INTPTR) + +B_DEF (s390_vstrsb, vstrsv16qi, 0, B_VXE2, 0, BT_FN_UV16QI_UV16QI_UV16QI_UV16QI_INTPTR) +B_DEF (s390_vstrsh, vstrsv8hi, 0, B_VXE2, 0, BT_FN_UV8HI_UV8HI_UV8HI_UV8HI_INTPTR) +B_DEF (s390_vstrsf, vstrsv4si, 0, B_VXE2, 0, BT_FN_UV4SI_UV4SI_UV4SI_UV8HI_INTPTR) + +OB_DEF (s390_vec_search_string_until_zero_cc, s390_vstrsz_s8, s390_vstrsz_u32, B_VXE2, BT_FN_OV4SI_OV4SI_OV4SI_OV4SI_INTPTR) +OB_DEF_VAR (s390_vstrsz_s8, s390_vstrszb, 0, 0, BT_OV_UV16QI_V16QI_V16QI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrsz_b8, s390_vstrszb, 0, 0, BT_OV_UV16QI_BV16QI_BV16QI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrsz_u8, s390_vstrszb, 0, 0, BT_OV_UV16QI_UV16QI_UV16QI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrsz_s16, s390_vstrszh, 0, 0, BT_OV_UV16QI_V8HI_V8HI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrsz_b16, s390_vstrszh, 0, 0, BT_OV_UV16QI_BV8HI_BV8HI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrsz_u16, s390_vstrszh, 0, 0, BT_OV_UV16QI_UV8HI_UV8HI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrsz_s32, s390_vstrszf, 0, 0, BT_OV_UV16QI_V4SI_V4SI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrsz_b32, s390_vstrszf, 0, 0, BT_OV_UV16QI_BV4SI_BV4SI_UV16QI_INTPTR) +OB_DEF_VAR (s390_vstrsz_u32, s390_vstrszf, 0, 0, BT_OV_UV16QI_UV4SI_UV4SI_UV16QI_INTPTR) + +B_DEF (s390_vstrszb, vstrszv16qi, 0, B_VXE2, 0, BT_FN_UV16QI_UV16QI_UV16QI_UV16QI_INTPTR) +B_DEF (s390_vstrszh, vstrszv8hi, 0, B_VXE2, 0, BT_FN_UV8HI_UV8HI_UV8HI_UV8HI_INTPTR) +B_DEF (s390_vstrszf, vstrszv4si, 0, B_VXE2, 0, BT_FN_UV4SI_UV4SI_UV4SI_UV8HI_INTPTR) diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 56ad11fe3d7..45eff845161 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -222,6 +222,9 @@ UNSPEC_VEC_VSTRC UNSPEC_VEC_VSTRCCC + UNSPEC_VEC_VSTRS + UNSPEC_VEC_VSTRSCC + UNSPEC_VEC_VCDGB UNSPEC_VEC_VCDLGB diff --git a/gcc/config/s390/vecintrin.h b/gcc/config/s390/vecintrin.h index fb60a77ba06..b2d1c6eab9c 100644 --- a/gcc/config/s390/vecintrin.h +++ b/gcc/config/s390/vecintrin.h @@ -329,4 +329,6 @@ __lcbb(const void *ptr, int bndry) #define vec_reve __builtin_s390_vec_reve #define vec_sldb __builtin_s390_vec_sldb #define vec_srdb __builtin_s390_vec_srdb +#define vec_search_string_cc __builtin_s390_vec_search_string_cc +#define vec_search_string_until_zero_cc __builtin_s390_vec_search_string_until_zero_cc #endif /* _VECINTRIN_H */ diff --git a/gcc/config/s390/vx-builtins.md b/gcc/config/s390/vx-builtins.md index 1c42d4e679b..97fd47fdc20 100644 --- a/gcc/config/s390/vx-builtins.md +++ b/gcc/config/s390/vx-builtins.md @@ -1626,6 +1626,74 @@ operands[4] = GEN_INT (INTVAL (operands[4]) | VSTRING_FLAG_CS | VSTRING_FLAG_ZS); }) +; Vector string search + +(define_expand "vstrs" + [(parallel + [(set (match_operand:V16QI 0 "register_operand" "") + (unspec:V16QI [(match_operand:VI_HW_QHS 1 "register_operand" "") + (match_operand:VI_HW_QHS 2 "register_operand" "") + (match_operand:V16QI 3 "register_operand" "") + (const_int 0)] + UNSPEC_VEC_VSTRS)) + (set (reg:CCRAW CC_REGNUM) + (unspec:CCRAW [(match_dup 1) + (match_dup 2) + (match_dup 3) + (const_int 0)] + UNSPEC_VEC_VSTRSCC))]) + (set (match_operand:SI 4 "memory_operand" "") + (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))] + "TARGET_VXE2") + +(define_expand "vstrsz" + [(parallel + [(set (match_operand:V16QI 0 "register_operand" "") + (unspec:V16QI [(match_operand:VI_HW_QHS 1 "register_operand" "") + (match_operand:VI_HW_QHS 2 "register_operand" "") + (match_operand:V16QI 3 "register_operand" "") + (const_int VSTRING_FLAG_ZS)] + UNSPEC_VEC_VSTRS)) + (set (reg:CCRAW CC_REGNUM) + (unspec:CCRAW [(match_dup 1) + (match_dup 2) + (match_dup 3) + (const_int VSTRING_FLAG_ZS)] + UNSPEC_VEC_VSTRSCC))]) + (set (match_operand:SI 4 "memory_operand" "") + (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))] + "TARGET_VXE2") + +; vstrsb, vstrsh, vstrsf +; vstrszb, vstrszh, vstrszf +(define_insn "vec_vstrs" + [(set (match_operand:V16QI 0 "register_operand" "=v") + (unspec:V16QI [(match_operand:VI_HW_QHS 1 "register_operand" "v") + (match_operand:VI_HW_QHS 2 "register_operand" "v") + (match_operand:V16QI 3 "register_operand" "v") + (match_operand:QI 4 "const_mask_operand" "C")] + UNSPEC_VEC_VSTRS)) + (set (reg:CCRAW CC_REGNUM) + (unspec:CCRAW [(match_dup 1) + (match_dup 2) + (match_dup 3) + (match_dup 4)] + UNSPEC_VEC_VSTRSCC))] + "TARGET_VXE2" +{ + unsigned HOST_WIDE_INT flags = UINTVAL (operands[4]); + + gcc_assert (!(flags & ~VSTRING_FLAG_ZS)); + + if (flags == VSTRING_FLAG_ZS) + return "vstrsz\t%v0,%v1,%v2,%v3"; + return "vstrs\t%v0,%v1,%v2,%v3"; +} + [(set_attr "op_type" "VRR")]) + + +; Vector convert int<->float + (define_insn "vcdgb" [(set (match_operand:V2DF 0 "register_operand" "=v") (unspec:V2DF [(match_operand:V2DI 1 "register_operand" "v") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 693655b5e5d..0f76782da34 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-04-02 Andreas Krebbel + + * gcc.target/s390/zvector/vec-search-string-cc-1.c: New test. + * gcc.target/s390/zvector/vec-search-string-cc-compile.c: New test. + * gcc.target/s390/zvector/vec-search-string-until-zero-cc-1.c: New test. + * gcc.target/s390/zvector/vec-search-string-until-zero-cc-compile.c: New test. + 2019-04-02 Andreas Krebbel * gcc.target/s390/zvector/vec-shift-left-double-by-bit-1.c: New test. diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-cc-1.c b/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-cc-1.c new file mode 100644 index 00000000000..57039f2103c --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-cc-1.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-require-effective-target s390_vxe2 } */ +/* { dg-options "-O3 -mzarch -march=arch13 -mzvector --save-temps" } */ + +#include + +void __attribute__((noinline,noclone)) +vstrs1 () +{ + int cc; + vector signed char haystack = { 'h', 'o', 'l', 'a', 'h', 'i', 'h', 'o', + 'h', 'i', 'h', 'o' }; + vector signed char needle = { 'h', 'i', 'h', 'o' }; + vector unsigned char length = { 0 }; + length[7] = 4; + + vector unsigned char result = vec_search_string_cc (haystack, needle, + length, &cc); + + if (result[7] != 4) + __builtin_abort (); + + /* CC2 indicates a full match. */ + if (cc != 2) + __builtin_abort (); +} + +int +main () +{ + vstrs1 (); + + return 0; +} + +/* { dg-final { scan-assembler-times "vstrsb\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-cc-compile.c b/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-cc-compile.c new file mode 100644 index 00000000000..f802f92d189 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-cc-compile.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -mzarch -march=arch13 -mzvector" } */ + +#include + +unsigned char +vstrsb () +{ + int cc; + vector signed char haystack = { 'h', 'o', 'l', 'a', 'h', 'i', 'h', 'o', + 'h', 'i', 'h', 'o' }; + vector signed char needle = { 'h', 'i', 'h', 'o' }; + vector unsigned char length = { 0 }; + vector unsigned char result = vec_search_string_cc (haystack, needle, + length, &cc); + return result[7]; +} + +/* { dg-final { scan-assembler-times "vstrsb\t" 1 } } */ + +unsigned char +vstrsh () +{ + int cc; + vector signed short haystack = { 'h', 'o', 'l', 'a', 'h', 'i', 'h', 'o' }; + vector signed short needle = { 'h', 'i', 'h', 'o' }; + vector unsigned char length = { 0 }; + vector unsigned char result = vec_search_string_cc (haystack, needle, + length, &cc); + return result[7]; +} + +/* { dg-final { scan-assembler-times "vstrsh\t" 1 } } */ + +unsigned char +vstrsf () +{ + int cc; + vector signed int haystack = { 'h', 'i', 'h', 'o' }; + vector signed int needle = { 'h', 'o' }; + vector unsigned char length = { 0 }; + vector unsigned char result = vec_search_string_cc (haystack, needle, + length, &cc); + return result[7]; +} + +/* { dg-final { scan-assembler-times "vstrsf\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-until-zero-cc-1.c b/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-until-zero-cc-1.c new file mode 100644 index 00000000000..6ceb764cc49 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-until-zero-cc-1.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-require-effective-target s390_vxe2 } */ +/* { dg-options "-O3 -mzarch -march=arch13 -mzvector --save-temps" } */ + +#include + +void __attribute__((noinline,noclone)) +vstrs1 () +{ + int cc; + vector signed char haystack = { 'h', 'o', 'l', 'a', 'h', 'i', 'h', 'o', + 'h', 'i', 'h', 'o' }; + vector signed char needle = { 'h', 'i', 'h', 'o', 0 }; + vector unsigned char length = { 0 }; + length[7] = 16; + + vector unsigned char result + = vec_search_string_until_zero_cc (haystack, needle, + length, &cc); + + if (result[7] != 4) + __builtin_abort (); + + /* CC2 indicates a full match. */ + if (cc != 2) + __builtin_abort (); +} + +int +main () +{ + vstrs1 (); + + return 0; +} + +/* { dg-final { scan-assembler-times "vstrszb\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-until-zero-cc-compile.c b/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-until-zero-cc-compile.c new file mode 100644 index 00000000000..317035ee002 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/zvector/vec-search-string-until-zero-cc-compile.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -mzarch -march=arch13 -mzvector" } */ + +#include + +unsigned char +vstrszb () +{ + int cc; + vector signed char haystack = { 'h', 'o', 'l', 'a', 'h', 'i', 'h', 'o', + 'h', 'i', 'h', 'o' }; + vector signed char needle = { 'h', 'i', 'h', 'o' }; + vector unsigned char length = { 0 }; + vector unsigned char result + = vec_search_string_until_zero_cc (haystack, needle, length, &cc); + return result[7]; +} + +/* { dg-final { scan-assembler-times "vstrszb\t" 1 } } */ + +unsigned char +vstrszh () +{ + int cc; + vector signed short haystack = { 'h', 'o', 'l', 'a', 'h', 'i', 'h', 'o' }; + vector signed short needle = { 'h', 'i', 'h', 'o' }; + vector unsigned char length = { 0 }; + vector unsigned char result + = vec_search_string_until_zero_cc (haystack, needle, length, &cc); + return result[7]; +} + +/* { dg-final { scan-assembler-times "vstrszh\t" 1 } } */ + +unsigned char +vstrszf () +{ + int cc; + vector signed int haystack = { 'h', 'i', 'h', 'o' }; + vector signed int needle = { 'h', 'o' }; + vector unsigned char length = { 0 }; + vector unsigned char result + = vec_search_string_until_zero_cc (haystack, needle, length, &cc); + return result[7]; +} + +/* { dg-final { scan-assembler-times "vstrszf\t" 1 } } */ -- 2.30.2