https://gcc.gnu.org/g:ccab94a6823991ad967d8e5a985888e04ae17e4a
commit ccab94a6823991ad967d8e5a985888e04ae17e4a Author: Michael Meissner <[email protected]> Date: Wed Nov 11 23:38:02 2026 -0500 Add -mvector-pair-fp support for sqrt 2026-11-11 Michael Meissner <[email protected]> * config/rs6000/rs6000-builtin.cc (rs6000_builtin_md_vectorized_function): Add support for vector pair reciprocal optimizations. * config/rs6000/rs6000-builtins.def (__builtin_vsx_xvrecipdivdp): New vector pair built-in functions. (__builtin_vsx_xvrecipdivsp_vp): Likewise. (__builtin_vsx_xvredp_vp): Likewise. (__builtin_vsx_xvresp_vp): Likewise. (__builtin_vsx_xvrsqrtdp_vp): Likewise. (__builtin_vsx_xvrsqrtsp_vp): Likewise. (__builtin_vsx_xvsqrtdp_vp): Likewise. (__builtin_vsx_xvsqrtsp_vp): Likewise. * config/rs6000/rs6000-gen-builtins.cc (enum basetype): Add support for vector pair built-in functions. (type_map): Likewise. (match_basetype): Likewise. (match_type): Likewise. (complete_vector_type): Likewise. (complete_base_type): Likewise. * config/rs6000/rs6000.cc (RECIP_V8SF_DIV): Likewise. (RECIP_V4DF_DIV): Likewise. (RECIP_V8SF_RSQRT): Likewise. (RECIP_V4DF_RSQRT): Likewise. (rs6000_init_hard_regno_mode_ok): Likewise. (rs6000_load_constant_and_splat): Likewise. (rs6000_emit_swdiv): Likewise. (rs6000_emit_swsqrt): Likewise. * config/rs6000/rs6000.h (RS6000_BTI_V4DF): Likewise. (RS6000_BTI_V8SF): Likewise. (RS6000_BTI_ptr_V4DF): Likewise. (RS6000_BTI_ptr_V8SF): Likewise. (V4DF_type_node): Likewise. (V8SF_type_node): Likewise. (ptr_V4DF_type_node): Likewise. (ptr_V8SF_type_node): Likewise. * config/rs6000/rs6000.md (RECIPF): Likewise. (sd attribute): Likewise. (VStype_div): Likewise. (VPAIR_FP_binary): Likewise. (VPAIR_FP_name): Likewise. (<VPAIR_FP_name><mode>2, VPAIR_FP_unary:VPAIR iterator): Reformat. (sqrt<mode>2, VPAIR_FP iterator): Add support for vector pair built-in functions. (rsqrte<mode>2, VPAIR_FP iterator): Likewise. (fre<mode>2, VPAIR_FP iterator): Likewise. (div<mode>3, VPAIR_FP iterator): Likewise. (*vpair_xxsel<mode>_1): Likewise. (*vpair_xxsel<mode>_2): Likewise. (*vpair_xxsel<mode>_3): Likewise. (*vpair_xxsel<mode>_4): Likewise. Diff: --- gcc/config/rs6000/rs6000-builtin.cc | 16 ++ gcc/config/rs6000/rs6000-builtins.def | 24 +++ gcc/config/rs6000/rs6000-gen-builtins.cc | 38 +++- gcc/config/rs6000/rs6000.cc | 73 +++++-- gcc/config/rs6000/rs6000.h | 8 + gcc/config/rs6000/rs6000.md | 5 +- gcc/config/rs6000/vsx.md | 334 ++++++++++++++++++++++++++++++- 7 files changed, 467 insertions(+), 31 deletions(-) diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index 3faee40ab2aa..6e9df1626dec 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -296,24 +296,40 @@ rs6000_builtin_md_vectorized_function (tree fndecl, tree type_out, && out_mode == SFmode && out_n == 4 && in_mode == SFmode && in_n == 4) return rs6000_builtin_decls[RS6000_BIF_VRSQRTFP]; + if (TARGET_VECTOR_PAIR_FP + && out_mode == SFmode && out_n == 8 + && in_mode == SFmode && in_n == 8) + return rs6000_builtin_decls[RS6000_BIF_RSQRT_8SF]; break; case RS6000_BIF_RSQRT: if (VECTOR_UNIT_VSX_P (V2DFmode) && out_mode == DFmode && out_n == 2 && in_mode == DFmode && in_n == 2) return rs6000_builtin_decls[RS6000_BIF_RSQRT_2DF]; + if (TARGET_VECTOR_PAIR_FP + && out_mode == DFmode && out_n == 4 + && in_mode == DFmode && in_n == 4) + return rs6000_builtin_decls[RS6000_BIF_RSQRT_4DF]; break; case RS6000_BIF_RECIPF: if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode) && out_mode == SFmode && out_n == 4 && in_mode == SFmode && in_n == 4) return rs6000_builtin_decls[RS6000_BIF_VRECIPFP]; + if (TARGET_VECTOR_PAIR_FP + && out_mode == SFmode && out_n == 8 + && in_mode == SFmode && in_n == 8) + return rs6000_builtin_decls[RS6000_BIF_RECIP_V8SF]; break; case RS6000_BIF_RECIP: if (VECTOR_UNIT_VSX_P (V2DFmode) && out_mode == DFmode && out_n == 2 && in_mode == DFmode && in_n == 2) return rs6000_builtin_decls[RS6000_BIF_RECIP_V2DF]; + if (TARGET_VECTOR_PAIR_FP + && out_mode == DFmode && out_n == 4 + && in_mode == DFmode && in_n == 4) + return rs6000_builtin_decls[RS6000_BIF_RECIP_V4DF]; break; default: break; diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index 1be92fda977c..5eeaeb86ab66 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -1708,15 +1708,27 @@ fpmath vd __builtin_vsx_xvrecipdivdp (vd, vd); RECIP_V2DF recipv2df3 {} + fpmath vd __builtin_vsx_xvrecipdivdp_vp (vd_vp, vd_vp); + RECIP_V4DF recipv4df3 {} + fpmath vf __builtin_vsx_xvrecipdivsp (vf, vf); RECIP_V4SF recipv4sf3 {} + fpmath vf __builtin_vsx_xvrecipdivsp_vp (vf_vp, vf_vp); + RECIP_V8SF recipv8sf3 {} + const vd __builtin_vsx_xvredp (vd); XVREDP vsx_frev2df2 {} + const vd __builtin_vsx_xvredp_vp (vd_vp); + XVREDP_V4DF frev4df2 {} + const vf __builtin_vsx_xvresp (vf); XVRESP vsx_frev4sf2 {} + const vf __builtin_vsx_xvresp_vp (vf_vp); + XVRESP_V8SF frev8sf2 {} + const vf __builtin_vsx_xvrspi (vf); XVRSPI vsx_xvrspi {} @@ -1735,9 +1747,15 @@ const vd __builtin_vsx_xvrsqrtdp (vd); RSQRT_2DF rsqrtv2df2 {} + const vd __builtin_vsx_xvrsqrtdp_vp (vd_vp); + RSQRT_4DF rsqrtv4df2 {} + const vf __builtin_vsx_xvrsqrtsp (vf); RSQRT_4SF rsqrtv4sf2 {} + const vf __builtin_vsx_xvrsqrtsp_vp (vf_vp); + RSQRT_8SF rsqrtv8sf2 {} + const vd __builtin_vsx_xvrsqrtedp (vd); XVRSQRTEDP rsqrtev2df2 {} @@ -1747,9 +1765,15 @@ const vd __builtin_vsx_xvsqrtdp (vd); XVSQRTDP sqrtv2df2 {} + const vd __builtin_vsx_xvsqrtdp_vp (vd_vp); + XVSQRTDP_4DF sqrtv4df2 {} + const vf __builtin_vsx_xvsqrtsp (vf); XVSQRTSP sqrtv4sf2 {} + const vf __builtin_vsx_xvsqrtsp_vp (vf_vp); + XVSQRTSP_8SF sqrtv8sf2 {} + fpmath vd __builtin_vsx_xvsubdp (vd, vd); XVSUBDP subv2df3 {} diff --git a/gcc/config/rs6000/rs6000-gen-builtins.cc b/gcc/config/rs6000/rs6000-gen-builtins.cc index 08068ba78fd4..e3bf5c714bdc 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.cc +++ b/gcc/config/rs6000/rs6000-gen-builtins.cc @@ -340,7 +340,9 @@ enum basetype BT_IBM128, BT_VPAIR, BT_VQUAD, - BT_DMR + BT_DMR, + BT_FLOAT_VP, + BT_DOUBLE_VP }; /* Ways in which a const int value can be restricted. RES_BITS indicates @@ -593,13 +595,17 @@ static typemap type_map[] = { "v16qi", "V16QI" }, { "v1poi", "vector_pair" }, { "v1pxi", "vector_quad" }, - { "v1tdoi", "dmr1024" }, + { "v1tdoi", "dmr1024" }, { "v1ti", "V1TI" }, { "v2df", "V2DF" }, { "v2di", "V2DI" }, + { "v4df", "V4DF" }, { "v4sf", "V4SF" }, { "v4si", "V4SI" }, + { "v8bf", "V8BF" }, + { "v8hf", "V8HF" }, { "v8hi", "V8HI" }, + { "v8sf", "V8SF" }, { "vp8hi", "pixel_V8HI" }, }; @@ -881,8 +887,12 @@ match_basetype (typeinfo *typedata) } else if (!strcmp (token, "float")) typedata->base = BT_FLOAT; + else if (!strcmp (token, "float_vp")) + typedata->base = BT_FLOAT_VP; else if (!strcmp (token, "double")) typedata->base = BT_DOUBLE; + else if (!strcmp (token, "double_vp")) + typedata->base = BT_DOUBLE_VP; else if (!strcmp (token, "__int128")) typedata->base = BT_INT128; else if (!strcmp (token, "_Float128")) @@ -1240,6 +1250,13 @@ match_type (typeinfo *typedata, int voidok) handle_pointer (typedata); return 1; } + else if (!strcmp (token, "vf_vp")) + { + typedata->isvector = 1; + typedata->base = BT_FLOAT_VP; + handle_pointer (typedata); + return 1; + } else if (!strcmp (token, "vd")) { typedata->isvector = 1; @@ -1247,6 +1264,13 @@ match_type (typeinfo *typedata, int voidok) handle_pointer (typedata); return 1; } + else if (!strcmp (token, "vd_vp")) + { + typedata->isvector = 1; + typedata->base = BT_DOUBLE_VP; + handle_pointer (typedata); + return 1; + } else if (!strcmp (token, "v256")) { typedata->isvector = 1; @@ -1554,10 +1578,18 @@ complete_vector_type (typeinfo *typeptr, char *buf, int *bufi) memcpy (&buf[*bufi], "4sf", 3); *bufi += 3; break; + case BT_FLOAT_VP: + memcpy (&buf[*bufi], "8sf", 3); + *bufi += 3; + break; case BT_DOUBLE: memcpy (&buf[*bufi], "2df", 3); *bufi += 3; break; + case BT_DOUBLE_VP: + memcpy (&buf[*bufi], "4df", 3); + *bufi += 3; + break; case BT_INT128: memcpy (&buf[*bufi], "1ti", 3); *bufi += 3; @@ -1606,9 +1638,11 @@ complete_base_type (typeinfo *typeptr, char *buf, int *bufi) memcpy (&buf[*bufi], "di", 2); break; case BT_FLOAT: + case BT_FLOAT_VP: memcpy (&buf[*bufi], "sf", 2); break; case BT_DOUBLE: + case BT_DOUBLE_VP: memcpy (&buf[*bufi], "df", 2); break; case BT_LONGDOUBLE: diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 0e14e85b5549..03113ca310ad 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -223,6 +223,13 @@ enum rs6000_recip_mask { RECIP_LOW_PRECISION = (RECIP_ALL & ~(RECIP_DF_RSQRT | RECIP_V2DF_RSQRT)) }; +/* For reciprocal optimization, treat the vector pair modes the same as + as the normal vector modes. */ +#define RECIP_V8SF_DIV RECIP_V4SF_DIV +#define RECIP_V4DF_DIV RECIP_V2DF_DIV +#define RECIP_V8SF_RSQRT RECIP_V4SF_DIV +#define RECIP_V4DF_RSQRT RECIP_V2DF_DIV + /* -mrecip options. */ static struct { @@ -3466,6 +3473,11 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) rs6000_recip_bits[V4SFmode] = RS6000_RECIP_MASK_HAVE_RE; if (VECTOR_UNIT_VSX_P (V2DFmode)) rs6000_recip_bits[V2DFmode] = RS6000_RECIP_MASK_HAVE_RE; + if (TARGET_VECTOR_PAIR_FP) + { + rs6000_recip_bits[V8SFmode] = RS6000_RECIP_MASK_HAVE_RE; + rs6000_recip_bits[V4DFmode] = RS6000_RECIP_MASK_HAVE_RE; + } if (TARGET_FRSQRTES) rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE; @@ -3475,6 +3487,11 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE; if (VECTOR_UNIT_VSX_P (V2DFmode)) rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE; + if (TARGET_VECTOR_PAIR_FP) + { + rs6000_recip_bits[V8SFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE; + rs6000_recip_bits[V4DFmode] |= RS6000_RECIP_MASK_HAVE_RSQRTE; + } if (rs6000_recip_control) { @@ -3501,10 +3518,18 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) && (rs6000_recip_control & RECIP_V4SF_DIV) != 0) rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RE; + if (RS6000_RECIP_HAVE_RE_P (V8SFmode) + && (rs6000_recip_control & RECIP_V8SF_DIV) != 0) + rs6000_recip_bits[V8SFmode] |= RS6000_RECIP_MASK_AUTO_RE; + if (RS6000_RECIP_HAVE_RE_P (V2DFmode) && (rs6000_recip_control & RECIP_V2DF_DIV) != 0) rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RE; + if (RS6000_RECIP_HAVE_RE_P (V4DFmode) + && (rs6000_recip_control & RECIP_V4DF_DIV) != 0) + rs6000_recip_bits[V4DFmode] |= RS6000_RECIP_MASK_AUTO_RE; + if (RS6000_RECIP_HAVE_RSQRTE_P (SFmode) && (rs6000_recip_control & RECIP_SF_RSQRT) != 0) rs6000_recip_bits[SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE; @@ -3517,9 +3542,17 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) && (rs6000_recip_control & RECIP_V4SF_RSQRT) != 0) rs6000_recip_bits[V4SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE; + if (RS6000_RECIP_HAVE_RSQRTE_P (V8SFmode) + && (rs6000_recip_control & RECIP_V8SF_RSQRT) != 0) + rs6000_recip_bits[V8SFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE; + if (RS6000_RECIP_HAVE_RSQRTE_P (V2DFmode) && (rs6000_recip_control & RECIP_V2DF_RSQRT) != 0) rs6000_recip_bits[V2DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE; + + if (RS6000_RECIP_HAVE_RSQRTE_P (V4DFmode) + && (rs6000_recip_control & RECIP_V4DF_RSQRT) != 0) + rs6000_recip_bits[V4DFmode] |= RS6000_RECIP_MASK_AUTO_RSQRTE; } } @@ -23656,29 +23689,27 @@ rs6000_ira_change_pseudo_allocno_class (int regno ATTRIBUTE_UNUSED, static rtx rs6000_load_constant_and_splat (machine_mode mode, REAL_VALUE_TYPE dconst) { - rtx reg; - if (mode == SFmode || mode == DFmode || FP16_SCALAR_MODE_P (mode)) { rtx d = const_double_from_real_value (dconst, mode); - reg = force_reg (mode, d); + return force_reg (mode, d); } - else if (mode == V4SFmode || mode == V8SFmode) - { - rtx d = const_double_from_real_value (dconst, SFmode); - rtvec v = gen_rtvec (4, d, d, d, d); - reg = gen_reg_rtx (mode); - rs6000_expand_vector_init (reg, gen_rtx_PARALLEL (mode, v)); - } - else if (mode == V2DFmode || mode == V4DFmode) - { - rtx d = const_double_from_real_value (dconst, DFmode); - rtvec v = gen_rtvec (2, d, d); - reg = gen_reg_rtx (mode); - rs6000_expand_vector_init (reg, gen_rtx_PARALLEL (mode, v)); - } - else - gcc_unreachable (); + + gcc_assert (VECTOR_MODE_P (mode)); + + rtx reg = gen_reg_rtx (mode); + rtx d = const_double_from_real_value (dconst, GET_MODE_INNER (mode)); + size_t nunits = GET_MODE_NUNITS (mode); + rtx dup_d[16]; + + gcc_assert (nunits <= ARRAY_SIZE (dup_d)); + + for (size_t i = 0; i < nunits; i++) + dup_d[i] = d; + + rs6000_expand_vector_init (reg, + gen_rtx_PARALLEL (mode, + gen_rtvec_v (nunits, dup_d))); return reg; } @@ -23738,7 +23769,7 @@ rs6000_emit_swdiv (rtx dst, rtx n, rtx d, bool note_p) accuracy. Each pass at least doubles the accuracy, leading to the following. */ int passes = (TARGET_RECIP_PRECISION) ? 1 : 3; - if (mode == DFmode || mode == V2DFmode) + if (mode == DFmode || mode == V2DFmode || mode == V4DFmode) passes++; enum insn_code code = optab_handler (smul_optab, mode); @@ -23813,7 +23844,7 @@ rs6000_emit_swsqrt (rtx dst, rtx src, bool recip) accuracy. Each pass at least doubles the accuracy, leading to the following. */ int passes = (TARGET_RECIP_PRECISION) ? 1 : 3; - if (mode == DFmode || mode == V2DFmode) + if (mode == DFmode || mode == V2DFmode || mode == V4DFmode) passes++; int i; diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index a0af36fe2e25..ee4ec753d650 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -2263,9 +2263,11 @@ enum rs6000_builtin_type_index RS6000_BTI_V1TI, RS6000_BTI_V2DI, RS6000_BTI_V2DF, + RS6000_BTI_V4DF, RS6000_BTI_V4HI, RS6000_BTI_V4SI, RS6000_BTI_V4SF, + RS6000_BTI_V8SF, RS6000_BTI_V8HI, RS6000_BTI_unsigned_V16QI, /* __vector unsigned char */ RS6000_BTI_unsigned_V1TI, @@ -2320,8 +2322,10 @@ enum rs6000_builtin_type_index RS6000_BTI_ptr_V1TI, RS6000_BTI_ptr_V2DI, RS6000_BTI_ptr_V2DF, + RS6000_BTI_ptr_V4DF, RS6000_BTI_ptr_V4SI, RS6000_BTI_ptr_V4SF, + RS6000_BTI_ptr_V8SF, RS6000_BTI_ptr_V8HI, RS6000_BTI_ptr_unsigned_V16QI, RS6000_BTI_ptr_unsigned_V1TI, @@ -2367,9 +2371,11 @@ enum rs6000_builtin_type_index #define V1TI_type_node (rs6000_builtin_types[RS6000_BTI_V1TI]) #define V2DI_type_node (rs6000_builtin_types[RS6000_BTI_V2DI]) #define V2DF_type_node (rs6000_builtin_types[RS6000_BTI_V2DF]) +#define V4DF_type_node (rs6000_builtin_types[RS6000_BTI_V4DF]) #define V4HI_type_node (rs6000_builtin_types[RS6000_BTI_V4HI]) #define V4SI_type_node (rs6000_builtin_types[RS6000_BTI_V4SI]) #define V4SF_type_node (rs6000_builtin_types[RS6000_BTI_V4SF]) +#define V8SF_type_node (rs6000_builtin_types[RS6000_BTI_V8SF]) #define V8HI_type_node (rs6000_builtin_types[RS6000_BTI_V8HI]) #define unsigned_V16QI_type_node (rs6000_builtin_types[RS6000_BTI_unsigned_V16QI]) #define unsigned_V1TI_type_node (rs6000_builtin_types[RS6000_BTI_unsigned_V1TI]) @@ -2421,8 +2427,10 @@ enum rs6000_builtin_type_index #define ptr_V1TI_type_node (rs6000_builtin_types[RS6000_BTI_ptr_V1TI]) #define ptr_V2DI_type_node (rs6000_builtin_types[RS6000_BTI_ptr_V2DI]) #define ptr_V2DF_type_node (rs6000_builtin_types[RS6000_BTI_ptr_V2DF]) +#define ptr_V4DF_type_node (rs6000_builtin_types[RS6000_BTI_ptr_V4DF]) #define ptr_V4SI_type_node (rs6000_builtin_types[RS6000_BTI_ptr_V4SI]) #define ptr_V4SF_type_node (rs6000_builtin_types[RS6000_BTI_ptr_V4SF]) +#define ptr_V8SF_type_node (rs6000_builtin_types[RS6000_BTI_ptr_V8SF]) #define ptr_V8HI_type_node (rs6000_builtin_types[RS6000_BTI_ptr_V8HI]) #define ptr_unsigned_V16QI_type_node (rs6000_builtin_types[RS6000_BTI_ptr_unsigned_V16QI]) #define ptr_unsigned_V1TI_type_node (rs6000_builtin_types[RS6000_BTI_ptr_unsigned_V1TI]) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 6838aafc5b0e..228824979623 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -636,7 +636,7 @@ (define_mode_iterator DIFD [DI DF DD]) ; Iterator for reciprocal estimate instructions -(define_mode_iterator RECIPF [SF DF V4SF V2DF]) +(define_mode_iterator RECIPF [SF DF V4SF V2DF V8SF V4DF]) ; SFmode or DFmode. (define_mode_iterator SFDF [SF DF]) @@ -646,7 +646,8 @@ ; A generic s/d attribute, for sp/dp for example. (define_mode_attr sd [(SF "s") (DF "d") - (V4SF "s") (V2DF "d")]) + (V4SF "s") (V2DF "d") + (V8SF "s") (V4DF "d")]) ; A generic s/d/q attribute, for sp/dp/qp for example. (define_mode_attr sdq [(SF "s") (DF "d") diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index b7da1a8aa54b..7ae54146724e 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -206,7 +206,9 @@ ;; Appropriate type for divide ops. (define_mode_attr VStype_div [(V2DF "vecdiv") + (V4DF "vecdiv") (V4SF "vecfdiv") + (V8SF "vecfdiv") (DF "ddiv")]) ;; Map to a double-sized vector mode @@ -7394,13 +7396,16 @@ ;; Unary/binary operators supporting vector pair splits (define_code_iterator VPAIR_FP_unary [abs neg]) -(define_code_iterator VPAIR_FP_binary [plus minus mult div]) +(define_code_iterator VPAIR_FP_binary [plus minus mult eq ge gt]) ;; Insn name for the unary/binary operators (define_code_attr VPAIR_FP_name [(abs "abs") (div "div") + (eq "*eq") + (ge "*ge") + (gt "*gt") (minus "sub") - (mult "mult") + (mult "mul") (neg "neg") (plus "add")]) @@ -7444,11 +7449,9 @@ "#" "&& reload_completed" [(set (match_dup 2) - (VPAIR_FP_unary:<VPAIR_FP_SINGLE> - (match_dup 3))) + (VPAIR_FP_unary:<VPAIR_FP_SINGLE> (match_dup 3))) (set (match_dup 4) - (VPAIR_FP_unary:<VPAIR_FP_SINGLE> - (match_dup 5)))] + (VPAIR_FP_unary:<VPAIR_FP_SINGLE> (match_dup 5)))] { machine_mode mode = <VPAIR_FP_SINGLE>mode; unsigned r0 = reg_or_subregno (operands[0]); @@ -7492,6 +7495,96 @@ [(set_attr "type" "<VStype_simple>") (set_attr "length" "8")]) +(define_expand "sqrt<mode>2" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand") + (sqrt:VPAIR_FP (match_operand:VPAIR_FP 1 "vsx_register_operand")))] + "TARGET_VECTOR_PAIR_FP" +{ + if (<MODE>mode == V8SFmode + && !optimize_function_for_size_p (cfun) + && flag_finite_math_only && !flag_trapping_math + && flag_unsafe_math_optimizations) + { + rs6000_emit_swsqrt (operands[0], operands[1], 0); + DONE; + } +}) + +(define_insn_and_split "*sqrt<mode>2" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa") + (sqrt:VPAIR_FP (match_operand:VPAIR_FP 1 "vsx_register_operand" "wa")))] + "TARGET_VECTOR_PAIR_FP" + "#" + "&& reload_completed" + [(set (match_dup 2) + (sqrt:<VPAIR_FP_SINGLE> (match_dup 3))) + (set (match_dup 4) + (sqrt:<VPAIR_FP_SINGLE> (match_dup 5)))] +{ + machine_mode mode = <VPAIR_FP_SINGLE>mode; + unsigned r0 = reg_or_subregno (operands[0]); + unsigned r1 = reg_or_subregno (operands[1]); + + operands[2] = gen_rtx_REG (mode, r0); + operands[3] = gen_rtx_REG (mode, r1); + + operands[4] = gen_rtx_REG (mode, r0 + 1); + operands[5] = gen_rtx_REG (mode, r1 + 1); +} + [(set_attr "type" "<sd>sqrt") + (set_attr "length" "8")]) + +;; Support needed to do reciprocal optimizations on vector pairs +(define_insn_and_split "rsqrte<mode>2" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa") + (unspec:VPAIR_FP [(match_operand:VPAIR_FP 1 "vsx_register_operand" "wa")] + UNSPEC_RSQRT))] + "TARGET_VECTOR_PAIR_FP" + "#" + "&& reload_completed" + [(set (match_dup 2) + (unspec:<VPAIR_FP_SINGLE> [(match_dup 3)] UNSPEC_RSQRT)) + (set (match_dup 4) + (unspec:<VPAIR_FP_SINGLE> [(match_dup 5)] UNSPEC_RSQRT))] +{ + machine_mode mode = <VPAIR_FP_SINGLE>mode; + unsigned r0 = reg_or_subregno (operands[0]); + unsigned r1 = reg_or_subregno (operands[1]); + + operands[2] = gen_rtx_REG (mode, r0); + operands[3] = gen_rtx_REG (mode, r1); + + operands[4] = gen_rtx_REG (mode, r0 + 1); + operands[5] = gen_rtx_REG (mode, r1 + 1); +} + [(set_attr "type" "<VStype_simple>") + (set_attr "length" "8")]) + +(define_insn_and_split "fre<mode>2" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa") + (unspec:VPAIR_FP [(match_operand:VPAIR_FP 1 "vsx_register_operand" "wa")] + UNSPEC_FRES))] + "TARGET_VECTOR_PAIR_FP" + "#" + "&& reload_completed" + [(set (match_dup 2) + (unspec:<VPAIR_FP_SINGLE> [(match_dup 3)] UNSPEC_FRES)) + (set (match_dup 4) + (unspec:<VPAIR_FP_SINGLE> [(match_dup 5)] UNSPEC_FRES))] +{ + machine_mode mode = <VPAIR_FP_SINGLE>mode; + unsigned r0 = reg_or_subregno (operands[0]); + unsigned r1 = reg_or_subregno (operands[1]); + + operands[2] = gen_rtx_REG (mode, r0); + operands[3] = gen_rtx_REG (mode, r1); + + operands[4] = gen_rtx_REG (mode, r0 + 1); + operands[5] = gen_rtx_REG (mode, r1 + 1); +} + [(set_attr "type" "<VStype_simple>") + (set_attr "length" "8")]) + (define_insn_and_split "<VPAIR_FP_name><mode>3" [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa") (VPAIR_FP_binary:VPAIR_FP @@ -7525,6 +7618,54 @@ [(set_attr "type" "<VStype_simple>") (set_attr "length" "8")]) +(define_expand "div<mode>3" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand") + (div:VPAIR_FP (match_operand:VPAIR_FP 1 "vsx_register_operand") + (match_operand:VPAIR_FP 2 "vsx_register_operand")))] + "TARGET_VECTOR_PAIR_FP" +{ + if (RS6000_RECIP_AUTO_RE_P (<MODE>mode) + && can_create_pseudo_p () && flag_finite_math_only + && !flag_trapping_math && flag_reciprocal_math) + { + rs6000_emit_swdiv (operands[0], operands[1], operands[2], true); + DONE; + } +}) + +(define_insn_and_split "*div<mode>3" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa") + (div:VPAIR_FP + (match_operand:VPAIR_FP 1 "vsx_register_operand" "wa") + (match_operand:VPAIR_FP 2 "vsx_register_operand" "wa")))] + "TARGET_VECTOR_PAIR_FP" + "#" + "&& reload_completed" + [(set (match_dup 3) + (div:<VPAIR_FP_SINGLE> + (match_dup 4) + (match_dup 5))) + (set (match_dup 6) + (div:<VPAIR_FP_SINGLE> + (match_dup 7) + (match_dup 8)))] +{ + machine_mode mode = <VPAIR_FP_SINGLE>mode; + unsigned r0 = reg_or_subregno (operands[0]); + unsigned r1 = reg_or_subregno (operands[1]); + unsigned r2 = reg_or_subregno (operands[2]); + + operands[3] = gen_rtx_REG (mode, r0); + operands[4] = gen_rtx_REG (mode, r1); + operands[5] = gen_rtx_REG (mode, r2); + + operands[6] = gen_rtx_REG (mode, r0 + 1); + operands[7] = gen_rtx_REG (mode, r1 + 1); + operands[8] = gen_rtx_REG (mode, r2 + 1); +} + [(set_attr "type" "<VStype_div>") + (set_attr "length" "8")]) + (define_insn_and_split "fma<mode>4" [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa,wa") (fma:VPAIR_FP @@ -7692,3 +7833,184 @@ } [(set_attr "type" "<VStype_simple>") (set_attr "length" "8")]) + +;; XXSEL logical operations +(define_insn_and_split "*vpair_xxsel<mode>_1" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa") + (ior:VPAIR_FP + (and:VPAIR_FP + (not:VPAIR_FP + (match_operand:VPAIR_FP 1 "vsx_register_operand" "wa")) + (match_operand:VPAIR_FP 2 "vsx_register_operand" "wa")) + (and:VPAIR_FP + (match_dup 1) + (match_operand:VPAIR_FP 3 "vsx_register_operand" "wa"))))] + "TARGET_VECTOR_PAIR_FP" + "#" + "&& reload_completed" + [(set (match_dup 4) + (ior:<VPAIR_FP_SINGLE> + (and:<VPAIR_FP_SINGLE> (not:<VPAIR_FP_SINGLE> (match_dup 5)) + (match_dup 6)) + (and:<VPAIR_FP_SINGLE> (match_dup 5) + (match_dup 7)))) + (set (match_dup 8) + (ior:<VPAIR_FP_SINGLE> + (and:<VPAIR_FP_SINGLE> (not:<VPAIR_FP_SINGLE> (match_dup 9)) + (match_dup 10)) + (and:<VPAIR_FP_SINGLE> (match_dup 9) + (match_dup 11))))] +{ + machine_mode mode = <VPAIR_FP_SINGLE>mode; + unsigned r0 = reg_or_subregno (operands[0]); + unsigned r1 = reg_or_subregno (operands[1]); + unsigned r2 = reg_or_subregno (operands[2]); + unsigned r3 = reg_or_subregno (operands[3]); + + operands[4] = gen_rtx_REG (mode, r0); + operands[5] = gen_rtx_REG (mode, r1); + operands[6] = gen_rtx_REG (mode, r2); + operands[7] = gen_rtx_REG (mode, r3); + + operands[8] = gen_rtx_REG (mode, r0 + 1); + operands[9] = gen_rtx_REG (mode, r1 + 1); + operands[10] = gen_rtx_REG (mode, r2 + 1); + operands[11] = gen_rtx_REG (mode, r3 + 1); +} + [(set_attr "type" "vecmove") + (set_attr "length" "8")]) + +(define_insn_and_split "*vpair_xxsel<mode>_2" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa") + (ior:VPAIR_FP + (and:VPAIR_FP + (not:VPAIR_FP + (match_operand:VPAIR_FP 1 "vsx_register_operand" "wa")) + (match_operand:VPAIR_FP 2 "vsx_register_operand" "wa")) + (and:VPAIR_FP + (match_operand:VPAIR_FP 3 "vsx_register_operand" "wa") + (match_dup 1))))] + "TARGET_VECTOR_PAIR_FP" + "#" + "&& reload_completed" + [(set (match_dup 4) + (ior:<VPAIR_FP_SINGLE> + (and:<VPAIR_FP_SINGLE> (not:<VPAIR_FP_SINGLE> (match_dup 5)) + (match_dup 6)) + (and:<VPAIR_FP_SINGLE> (match_dup 7) + (match_dup 5)))) + (set (match_dup 8) + (ior:<VPAIR_FP_SINGLE> + (and:<VPAIR_FP_SINGLE> (not:<VPAIR_FP_SINGLE> (match_dup 9)) + (match_dup 10)) + (and:<VPAIR_FP_SINGLE> (match_dup 11) + (match_dup 9))))] +{ + machine_mode mode = <VPAIR_FP_SINGLE>mode; + unsigned r0 = reg_or_subregno (operands[0]); + unsigned r1 = reg_or_subregno (operands[1]); + unsigned r2 = reg_or_subregno (operands[2]); + unsigned r3 = reg_or_subregno (operands[3]); + + operands[4] = gen_rtx_REG (mode, r0); + operands[5] = gen_rtx_REG (mode, r1); + operands[6] = gen_rtx_REG (mode, r2); + operands[7] = gen_rtx_REG (mode, r3); + + operands[8] = gen_rtx_REG (mode, r0 + 1); + operands[9] = gen_rtx_REG (mode, r1 + 1); + operands[10] = gen_rtx_REG (mode, r2 + 1); + operands[11] = gen_rtx_REG (mode, r3 + 1); +} + [(set_attr "type" "vecmove") + (set_attr "length" "8")]) + +(define_insn_and_split "*vpair_xxsel<mode>_3" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa") + (ior:VPAIR_FP + (and:VPAIR_FP + (match_operand:VPAIR_FP 1 "vsx_register_operand" "wa") + (match_operand:VPAIR_FP 2 "vsx_register_operand" "wa")) + (and:VPAIR_FP + (not:VPAIR_FP + (match_dup 1)) + (match_operand:VPAIR_FP 3 "vsx_register_operand" "wa"))))] + "TARGET_VECTOR_PAIR_FP" + "#" + "&& reload_completed" + [(set (match_dup 4) + (ior:<VPAIR_FP_SINGLE> + (and:<VPAIR_FP_SINGLE> (match_dup 5) + (match_dup 6)) + (and:<VPAIR_FP_SINGLE> (not:<VPAIR_FP_SINGLE> (match_dup 5)) + (match_dup 7)))) + (set (match_dup 8) + (ior:<VPAIR_FP_SINGLE> + (and:<VPAIR_FP_SINGLE> (match_dup 9) + (match_dup 10)) + (and:<VPAIR_FP_SINGLE> (not:<VPAIR_FP_SINGLE> (match_dup 9)) + (match_dup 11))))] +{ + machine_mode mode = <VPAIR_FP_SINGLE>mode; + unsigned r0 = reg_or_subregno (operands[0]); + unsigned r1 = reg_or_subregno (operands[1]); + unsigned r2 = reg_or_subregno (operands[2]); + unsigned r3 = reg_or_subregno (operands[3]); + + operands[4] = gen_rtx_REG (mode, r0); + operands[5] = gen_rtx_REG (mode, r1); + operands[6] = gen_rtx_REG (mode, r2); + operands[7] = gen_rtx_REG (mode, r3); + + operands[8] = gen_rtx_REG (mode, r0 + 1); + operands[9] = gen_rtx_REG (mode, r1 + 1); + operands[10] = gen_rtx_REG (mode, r2 + 1); + operands[11] = gen_rtx_REG (mode, r3 + 1); +} + [(set_attr "type" "vecmove") + (set_attr "length" "8")]) + +(define_insn_and_split "*vpair_xxsel<mode>_4" + [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa") + (ior:VPAIR_FP + (and:VPAIR_FP + (match_operand:VPAIR_FP 1 "vsx_register_operand" "wa") + (match_operand:VPAIR_FP 2 "vsx_register_operand" "wa")) + (and:VPAIR_FP + (not:VPAIR_FP + (match_dup 2)) + (match_operand:VPAIR_FP 3 "vsx_register_operand" "wa"))))] + "TARGET_VECTOR_PAIR_FP" + "#" + "&& reload_completed" + [(set (match_dup 4) + (ior:<VPAIR_FP_SINGLE> + (and:<VPAIR_FP_SINGLE> (match_dup 5) + (match_dup 6)) + (and:<VPAIR_FP_SINGLE> (not:<VPAIR_FP_SINGLE> (match_dup 6)) + (match_dup 7)))) + (set (match_dup 8) + (ior:<VPAIR_FP_SINGLE> + (and:<VPAIR_FP_SINGLE> (match_dup 9) + (match_dup 10)) + (and:<VPAIR_FP_SINGLE> (not:<VPAIR_FP_SINGLE> (match_dup 10)) + (match_dup 11))))] +{ + machine_mode mode = <VPAIR_FP_SINGLE>mode; + unsigned r0 = reg_or_subregno (operands[0]); + unsigned r1 = reg_or_subregno (operands[1]); + unsigned r2 = reg_or_subregno (operands[2]); + unsigned r3 = reg_or_subregno (operands[3]); + + operands[4] = gen_rtx_REG (mode, r0); + operands[5] = gen_rtx_REG (mode, r1); + operands[6] = gen_rtx_REG (mode, r2); + operands[7] = gen_rtx_REG (mode, r3); + + operands[8] = gen_rtx_REG (mode, r0 + 1); + operands[9] = gen_rtx_REG (mode, r1 + 1); + operands[10] = gen_rtx_REG (mode, r2 + 1); + operands[11] = gen_rtx_REG (mode, r3 + 1); +} + [(set_attr "type" "vecmove") + (set_attr "length" "8")])
