https://gcc.gnu.org/g:fc7c2abd34f8ebd893cb6134a3011c573cf6e373

commit fc7c2abd34f8ebd893cb6134a3011c573cf6e373
Author: Michael Meissner <[email protected]>
Date:   Tue Nov 17 00:08:52 2026 -0500

    Add -mvector-pair-fp
    
    This is an experimental patch that adds an option (-mvector-pair-fp) that
    generates vector pair load/stores during vectorization for float and double
    operations.
    
    2026-11-17  Michael Meissner  <[email protected]>
    
            * config/rs6000/constraints.md (eF constraint): New constraint for
            V8SFmode and V4DFmode constants.
            * config/rs6000/float16.md (truncv8sfv8hf2): New insn for
            -mvector-pair-fp.
            (vsx_register_operand): Likewise.
            * config/rs6000/predicates.md (easy_vector_constant): Add support 
for
            -mvector-pair-fp.
            (easy_vpair_fp_constant): New predicate.
            * config/rs6000/rs6000-builtin.cc
            (rs6000_builtin_md_vectorized_function): Add support for
            -mvector-pair-fp.
            * config/rs6000/rs6000-builtins.def (__builtin_vsx_xvrecipdivdp_vp):
            Likewise.
            (__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-cpus.def(POWERPC_MASKS): Likewise.
            * config/rs6000/rs6000-gen-builtins.cc (enum basetype): Likewise.
            (type_map): Likewise.
            (match_basetype): Likewise.
            (match_type): Likewise.
            (complete_vector_type): Likewise.
            (complete_base_type): Likewise.
            * config/rs6000/rs6000-protos.h (vec_const_256bit_to_bytes): New
            declaration.
            (vect_const_method): Likewise.
            (vect_const_can_be_generated): Likewise.
            (split_vector_pair_operands): Likewise.
            * config/rs6000/rs6000.cc (RECIP_V8SF_DIV): New macro.
            (RECIP_V4DF_DIV): Likewise.
            (RECIP_V8SF_RSQRT): Likewise.
            (RECIP_V4DF_RSQRT): Likewise.
            (rs6000_hard_regno_mode_ok_uncached): Add support for 
-mvector-pair-fp.
            (rs6000_debug_reg_global): Likewise.
            (rs6000_setup_reg_addr_masks): Likewise.
            (rs6000_init_hard_regno_mode_ok): Likewise.
            (rs6000_option_override_internal): Likewise.
            (rs6000_builtin_vectorization_cost): Likewise.
            (rs6000_expand_vector_init): Likewise.
            (rs6000_expand_vector_set): Likewise.
            (rs6000_expand_vector_extract): Likewise.
            (reg_offset_addressing_ok_p): Likewise.
            (rs6000_const_vec): Likewise.
            (rs6000_emit_move): Likewise.
            (rs6000_preferred_reload_class): Likewise.
            (rs6000_handle_altivec_attribute): Likewise.
            (rs6000_load_constant_and_splat): Likewise.
            (rs6000_emit_swdiv): Likewise.
            (rs6000_emit_swsqrt): Likewise.
            (opt_masks): Likewise.
            (opt_vars): Likewise.
            (rs6000_split_multireg_move): Likewise.
            (vec_const_256bit_to_bytes): New function.
            (vect_const_can_be_generated): Likewise.
            (split_vector_pair_operands): Likewise.
            * config/rs6000/rs6000.h (VPAIR_FP_P): New macro.
            (rs6000_builtin_type_index): New vector pair types.
            (V4DF_type_node): Likewise.
            (V8SF_type_node): Likewise.
            (ptr_V4DF_type_node): Likewise.
            (ptr_V8SF_type_node): Likewise.
            * config/rs6000/rs6000.md (RECIPF mode iterator): Add support for
            -mvector-pair-fp.
            (sd mode attribute): Likewise.
            (RELOAD mode iterator): Likewise.
            * config/rs6000/rs6000.opt (-mvector-pair-fp): New option.
            (-mvector-pair-memory): New debug option.
            (-mvector-pair-load): Likewise.
            (-mvector-pair-store): Likewise.
            (-mvector-pair-float): Likewise.
            (-mvector-pair-double): Likewise.
            * config/rs6000/vector.md (VEC_E): Add V8SF and V4DF modes.
            (VEC_base): Likewise.
            (VEC_base_l): Likewise.
            * config/rs6000/vsx.md (VStype_simple): Add support for
            -mvector-pair-fp.
            (VStype_div): Likewise.
            (VPAIR_FP): Likewise.
            (mov<mode>, VPAIR_FP iterator): Likewise.
            (mov<mode>_p10): Likewise.
            (mov<mode>_p10_lxvp): Likewise.
            (mov<mode>_p10_stxvp): Likewise.
            (mov<mode>_p9): Likewise.
            (VPAIR_FP_unary): Likewise.
            (VPAIR_FP_binary): Likewise.
            (VPAIR_FP_name): Likewise.
            (VPAIR_FP_BASE): Likewise.
            (VPAIR_FP_SINGLE): Likewise.
            (dup<mode>, VPAIR_FP iterator): Likewise.
            (<VPAIR_FP_name><mode>2): Likewise.
            (nabs<mode>2): Likewise.
            (sqrt<mode>2): Likewise.
            (rsqrte<mode>2): Likewise.
            (fre<mode>2): Likewise.
            (div<mode>3): Likewise.
            (fma<mode>4): Likewise.
            (fms<mode>4): Likewise.
            (nfma<mode>4): Likewise.
            (nfms<mode>4): Likewise.
            (vpair_xxsel<mode>_1): Likewise.
            (vpair_xxsel<mode>_): Likewise.
            (vpair_xxsel<mode>_3): Likewise.
            (vpair_xxsel<mode>_4): Likewise.
            * doc/invoke.texi (PowerPC options): Add -mvector-pair-fp.

Diff:
---
 gcc/config/rs6000/constraints.md         |   6 +
 gcc/config/rs6000/float16.md             |  42 +++
 gcc/config/rs6000/predicates.md          |  36 ++
 gcc/config/rs6000/rs6000-builtin.cc      |  16 +
 gcc/config/rs6000/rs6000-builtins.def    |  24 ++
 gcc/config/rs6000/rs6000-cpus.def        |   1 +
 gcc/config/rs6000/rs6000-gen-builtins.cc |  38 ++-
 gcc/config/rs6000/rs6000-protos.h        |  17 +
 gcc/config/rs6000/rs6000.cc              | 515 +++++++++++++++++++++++++++--
 gcc/config/rs6000/rs6000.h               |  12 +
 gcc/config/rs6000/rs6000.md              |   7 +-
 gcc/config/rs6000/rs6000.opt             |  24 ++
 gcc/config/rs6000/vector.md              |   8 +-
 gcc/config/rs6000/vsx.md                 | 541 +++++++++++++++++++++++++++++++
 gcc/doc/invoke.texi                      |  13 +-
 15 files changed, 1269 insertions(+), 31 deletions(-)

diff --git a/gcc/config/rs6000/constraints.md b/gcc/config/rs6000/constraints.md
index 292ca67efb57..038eb272e303 100644
--- a/gcc/config/rs6000/constraints.md
+++ b/gcc/config/rs6000/constraints.md
@@ -206,6 +206,12 @@
   (and (match_code "const_int")
        (match_test "((- (unsigned HOST_WIDE_INT) ival) + 0x8000) < 0x10000")))
 
+;; A 256-bit vector floating point constant that can be loaded into a
+;; pair of vectors
+(define_constraint "eF"
+  "A 256-bit vector floating point constant that can be loaded."
+  (match_operand 0 "easy_vpair_fp_constant"))
+
 ;; 34-bit signed integer constant
 (define_constraint "eI"
   "A signed 34-bit integer constant if prefixed instructions are supported."
diff --git a/gcc/config/rs6000/float16.md b/gcc/config/rs6000/float16.md
index 1bbad9729c5e..533dbfba46b0 100644
--- a/gcc/config/rs6000/float16.md
+++ b/gcc/config/rs6000/float16.md
@@ -1111,6 +1111,27 @@
   DONE;
 })
 
+(define_insn_and_split "truncv8sfv8hf2"
+  [(set (match_operand:V8HF 0 "vsx_register_operand")
+       (float_truncate:V8HF
+        (match_operand:V8SF 1 "vsx_register_operand")))]
+  "TARGET_FLOAT16_HW && can_create_pseudo_p ()"
+  "#"
+  "&& 1"
+  [(pc)]
+{
+  rtx r1 = gen_reg_rtx (V8HFmode);
+  rtx r2 = gen_reg_rtx (V8HFmode);
+  rtx op1 = operands[1];
+  rtx op1_hi = gen_rtx_SUBREG (V4SFmode, op1, BYTES_BIG_ENDIAN ?  0 : 16);
+  rtx op1_lo = gen_rtx_SUBREG (V4SFmode, op1, BYTES_BIG_ENDIAN ? 16 :  0);
+
+  emit_insn (gen_xvcvsphp_v8hf (r1, op1_hi));
+  emit_insn (gen_xvcvsphp_v8hf (r2, op1_lo));
+  rs6000_expand_extract_even (operands[0], r1, r2);
+  DONE;
+})
+
 (define_expand "vec_pack_trunc_v4sf_v8bf"
   [(match_operand:V8BF 0 "vfloat_operand")
    (match_operand:V4SF 1 "vfloat_operand")
@@ -1126,6 +1147,27 @@
   DONE;
 })
 
+(define_insn_and_split "truncv8sfv8bf2"
+  [(set (match_operand:V8BF 0 "vsx_register_operand")
+       (float_truncate:V8BF
+        (match_operand:V8SF 1 "vsx_register_operand")))]
+  "TARGET_FLOAT16_HW && can_create_pseudo_p ()"
+  "#"
+  "&& 1"
+  [(pc)]
+{
+  rtx r1 = gen_reg_rtx (V8BFmode);
+  rtx r2 = gen_reg_rtx (V8BFmode);
+  rtx op1 = operands[1];
+  rtx op1_hi = gen_rtx_SUBREG (V4SFmode, op1, BYTES_BIG_ENDIAN ?  0 : 16);
+  rtx op1_lo = gen_rtx_SUBREG (V4SFmode, op1, BYTES_BIG_ENDIAN ? 16 :  0);
+
+  emit_insn (gen_xvcvspbf16_v8bf (r1, op1_hi));
+  emit_insn (gen_xvcvspbf16_v8bf (r2, op1_lo));
+  rs6000_expand_extract_even (operands[0], r1, r2);
+  DONE;
+})
+
 ;; Unfortunately the machine independent code assumes there is only one
 ;; 16-bit floating point type.  This means we have to choose whether to
 ;; support packing _Float16 or __bfloat16.  It looks like __bfloat16 is
diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index a4e5ce1d2753..24f5d5b74928 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -854,6 +854,10 @@
       if (zero_constant (op, mode) || all_ones_constant (op, mode))
        return true;
 
+      /* Handle paired constants.  */
+      if (VPAIR_FP_P (mode))
+       return easy_vpair_fp_constant (op, mode);
+
       /* Constants that can be generated with ISA 3.1 instructions are
          easy.  */
       vec_const_128bit_type vsx_const;
@@ -938,6 +942,38 @@
            (and (match_test "easy_altivec_constant (op, mode)")
                 (match_test "vspltis_shifted (op) != 0")))))
 
+
+;; Return 1 if the vector is a paired vector constant that can be
+;; loaded into a vector register using a combination or XXLXOR,
+;; XXSPLTIB, XXSPLTIW, or XXSPLTIDP instructions.
+(define_predicate "easy_vpair_fp_constant"
+  (match_code "const_vector,vec_duplicate")
+{
+  if (!VPAIR_FP_P (mode))
+    return false;
+
+  if (op == CONST0_RTX (mode))
+    return true;
+
+  vec_const_128bit_type hi_const;
+  vec_const_128bit_type lo_const;
+  unsigned info = 0;
+
+  /* Decode the constant into 2 128-bit parts.  */
+  if (!vec_const_256bit_to_bytes (op, mode, &hi_const, &lo_const))
+    return false;
+
+  /* Can the first 128 bits be generated without a load?  */
+  if (vect_const_can_be_generated (&hi_const, &info) == VECT_CONST_MEMORY)
+    return false;
+
+  /* Can the second 128 bits be generated without a load?  */
+  if (vect_const_can_be_generated (&lo_const, &info) == VECT_CONST_MEMORY)
+    return false;
+
+  return true;
+})
+
 ;; Return true if this is a vector constant and each byte in
 ;; it is the same.
 (define_predicate "const_vector_each_byte_same"
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-cpus.def 
b/gcc/config/rs6000/rs6000-cpus.def
index cac42403fd94..40725ad78a74 100644
--- a/gcc/config/rs6000/rs6000-cpus.def
+++ b/gcc/config/rs6000/rs6000-cpus.def
@@ -164,6 +164,7 @@
                                 | OPTION_MASK_RECIP_PRECISION          \
                                 | OPTION_MASK_SOFT_FLOAT               \
                                 | OPTION_MASK_STRICT_ALIGN_OPTIONAL    \
+                                | OPTION_MASK_VECTOR_PAIR_FP           \
                                 | OPTION_MASK_VSX)
 
 #endif
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-protos.h 
b/gcc/config/rs6000/rs6000-protos.h
index a4a1cb82fd1f..903c23e76f70 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -255,10 +255,27 @@ typedef struct {
 
 extern bool vec_const_128bit_to_bytes (rtx, machine_mode,
                                       vec_const_128bit_type *);
+extern bool vec_const_256bit_to_bytes (rtx, machine_mode,
+                                      vec_const_128bit_type *,
+                                      vec_const_128bit_type *);
 extern unsigned constant_generates_lxvkq (vec_const_128bit_type *);
 extern unsigned constant_generates_xxspltiw (vec_const_128bit_type *);
 extern unsigned constant_generates_xxspltidp (vec_const_128bit_type *);
 
+typedef enum {
+  VECT_CONST_MEMORY,           /* need to load constant from memory.  */
+  VECT_CONST_ZERO,             /* constant is all 0's.  */
+  VECT_CONST_ONES,             /* constant is all 1's.  */
+  VECT_CONST_XXSPLTIB,         /* constant can be loaded with XXSPLTIB.  */
+  VECT_CONST_XXSPLTIW,         /* constant can be loaded with XXSPLTIW.  */
+  VECT_CONST_XXSPLTIDP,                /* constant can be loaded with 
XXSPLTIDP.  */
+  VECT_CONST_LXVKG             /* constant can be loaded with LXVKQ.  */
+} vect_const_method;
+
+extern vect_const_method vect_const_can_be_generated (vec_const_128bit_type *,
+                                                     unsigned *);
+extern void split_vector_pair_operands (size_t, rtx [], machine_mode);
+
 /* From float16.cc.  */
 /* Optimize bfloat16 and float16 operations.  */
 enum fp16_operation {
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 4108692e7b8c..530ba364c7c0 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
 {
@@ -1899,6 +1906,9 @@ rs6000_hard_regno_mode_ok_uncached (int regno, 
machine_mode mode)
   if (mode == OOmode)
     return ((TARGET_MMA || TARGET_DMF) && VSX_REGNO_P (regno) && (regno & 1) 
== 0);
 
+  if (VPAIR_FP_P (mode))
+    return (TARGET_P9_VECTOR && VSX_REGNO_P (regno) && (regno & 1) == 0);
+
   /* MMA accumulator modes need FPR registers divisible by 4.
      If TARGET_DMF is true, XOmode value can be held in a DMR register.  */
   if (mode == XOmode)
@@ -2675,6 +2685,20 @@ rs6000_debug_reg_global (void)
       fprintf (stderr, DEBUG_FMT_S, "__bf16", "disabled");
     }
 
+  /* Print information about the vector pair support.  */
+  fprintf (stderr, DEBUG_FMT_S, "VECTOR_PAIR_FP",
+          TARGET_VECTOR_PAIR_FP ? "yes" : "no");
+  fprintf (stderr, DEBUG_FMT_D, "VECTOR_PAIR_MEMORY",
+          TARGET_VECTOR_PAIR_MEMORY);
+  fprintf (stderr, DEBUG_FMT_D, "VECTOR_PAIR_LOAD",
+          TARGET_VECTOR_PAIR_LOAD);
+  fprintf (stderr, DEBUG_FMT_D, "VECTOR_PAIR_STORE",
+          TARGET_VECTOR_PAIR_STORE);
+  fprintf (stderr, DEBUG_FMT_D, "VECTOR_PAIR_FLOAT",
+          TARGET_VECTOR_PAIR_FLOAT);
+  fprintf (stderr, DEBUG_FMT_D, "VECTOR_PAIR_DOUBLE",
+          TARGET_VECTOR_PAIR_DOUBLE);
+
   /* Print information about the various floating point formats used.  */
   if (TARGET_HARD_FLOAT)
     {
@@ -2714,6 +2738,12 @@ rs6000_debug_reg_global (void)
              rs6000_debug_fp_mode (V8HFmode);
            }
        }
+
+      if (TARGET_VECTOR_PAIR_FP)
+       {
+         rs6000_debug_fp_mode (V8SFmode);
+         rs6000_debug_fp_mode (V4DFmode);
+       }
     }
 }
 
@@ -2886,6 +2916,18 @@ rs6000_setup_reg_addr_masks (void)
                }
            }
 
+         else if ((addr_mask != 0) && TARGET_P9_VECTOR && VPAIR_FP_P (m2))
+           {
+             /* For vector pairs, we can do offset addressing, even if we
+                split the loads/stores into 2 operations.  Allow indexed on
+                power10, even if we are splitting lxvp to 2 lxv's or stxvp
+                into 2 stxv's.  The constraints used will restrict the
+                addressing mode when we are doing the splitting.  */
+             addr_mask |= RELOAD_REG_OFFSET | RELOAD_REG_QUAD_OFFSET;
+             if (TARGET_POWER10)
+                addr_mask |= RELOAD_REG_INDEXED;
+           }
+
          /* VMX registers can do (REG & -16) and ((REG+REG) & -16)
             addressing on 128-bit types.  */
          if (rc == RELOAD_REG_VMX && msize == 16
@@ -3090,6 +3132,23 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p)
        rs6000_vector_unit[V8BFmode] = VECTOR_VSX;
     }
 
+  /* paired floating point vector mode.  */
+  if (TARGET_P9_VECTOR
+      && (TARGET_VECTOR_PAIR_FP || TARGET_VECTOR_PAIR_MEMORY))
+    {
+      rs6000_vector_mem[V8SFmode] = VECTOR_VSX;
+      rs6000_vector_align[V8SFmode] = align32;
+
+      rs6000_vector_mem[V4DFmode] = VECTOR_VSX;
+      rs6000_vector_align[V4DFmode] = align32;
+
+      if (TARGET_VECTOR_PAIR_FP)
+       {
+         rs6000_vector_unit[V4DFmode] = VECTOR_VSX;
+         rs6000_vector_unit[V8SFmode] = VECTOR_VSX;
+       }
+    }
+
   /* DFmode, see if we want to use the VSX unit.  Memory is handled
      differently, so don't set rs6000_vector_mem.  */
   if (TARGET_VSX)
@@ -3217,6 +3276,14 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p)
              reg_addr[BFmode].reload_load  = CODE_FOR_reload_bf_di_load;
            }
 
+         if (TARGET_P9_VECTOR)
+           {
+             reg_addr[V8SFmode].reload_store = CODE_FOR_reload_v8sf_di_store;
+             reg_addr[V4DFmode].reload_store = CODE_FOR_reload_v4df_di_store;
+             reg_addr[V8SFmode].reload_load  = CODE_FOR_reload_v8sf_di_load;
+             reg_addr[V4DFmode].reload_load  = CODE_FOR_reload_v4df_di_load;
+           }
+
          /* Only provide a reload handler for SDmode if lfiwzx/stfiwx are
             available.  */
          if (TARGET_NO_SDMODE_STACK)
@@ -3430,6 +3497,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;
@@ -3439,6 +3511,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)
     {
@@ -3465,10 +3542,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;
@@ -3481,9 +3566,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;
        }
     }
 
@@ -4108,6 +4201,48 @@ rs6000_option_override_internal (bool global_init_p)
     rs6000_isa_flags &= ~((OPTION_MASK_P8_VECTOR | OPTION_MASK_CRYPTO)
                         & ~rs6000_isa_flags_explicit);
 
+  /* See if -mvector-pair-fp can be used.  On power10 systems, we use the
+     load/store vector pair instructions.  On power9 systems, we limit the
+     addresses to offsettable instructions so we can do 2 loads or stores.
+     Don't allow the option on power8 or before.  */
+  if (TARGET_VECTOR_PAIR_FP
+      && (!TARGET_P9_VECTOR || BYTES_BIG_ENDIAN || !TARGET_POWERPC64))
+    {
+      rs6000_isa_flags &= ~OPTION_MASK_VECTOR_PAIR_FP;
+      if (rs6000_isa_flags_explicit & OPTION_MASK_VECTOR_PAIR_FP)
+       error ("%qs is only available on 64-bit little endian systems "
+              "that use at least %qs",
+              "-mvector-pair-fp", "-mcpu=power9");
+    }
+
+  /* Determine the defaults for vector pair.  There 3 options for using vector
+     pair memory:
+
+       -mvector-pair-memory    -- use both lxvp and stxvp
+       -mvector-pair-load      -- use lxvp
+       -mvector-pair-store     -- use stxvp.
+
+     Setting -mvector-pair-memory, overrides both -mvector-pair-load and
+     -mvector-pair-store.  Setting -mvector-pair-fp enables any memory
+     operation that wasn't explicitly set.  */
+
+  if (TARGET_VECTOR_PAIR_MEMORY >= 0)
+    TARGET_VECTOR_PAIR_LOAD = TARGET_VECTOR_PAIR_STORE = 
TARGET_VECTOR_PAIR_MEMORY;
+
+  else
+    {
+      int vp_default = TARGET_VECTOR_PAIR_FP ? 1 : 0;
+
+      if (TARGET_VECTOR_PAIR_LOAD < 0)
+       TARGET_VECTOR_PAIR_LOAD = vp_default;
+
+      if (TARGET_VECTOR_PAIR_STORE < 0)
+       TARGET_VECTOR_PAIR_STORE = vp_default;
+
+      TARGET_VECTOR_PAIR_MEMORY = (TARGET_VECTOR_PAIR_LOAD
+                                  | TARGET_VECTOR_PAIR_STORE);
+    }
+
   if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
     rs6000_print_isa_options (stderr, 0, "before defaults", rs6000_isa_flags);
 
@@ -5405,6 +5540,15 @@ rs6000_builtin_vectorization_cost (enum 
vect_cost_for_stmt type_of_cost,
 static machine_mode
 rs6000_preferred_simd_mode (scalar_mode mode)
 {
+  if (TARGET_VECTOR_PAIR_FP)
+    {
+      if (mode == SFmode && TARGET_VECTOR_PAIR_FLOAT)
+       return V8SFmode;
+
+      if (mode == DFmode && TARGET_VECTOR_PAIR_DOUBLE)
+       return V4DFmode;
+    }
+
   opt_machine_mode vmode = mode_for_vector (mode, 16 / GET_MODE_SIZE (mode));
 
   if (vmode.exists () && !VECTOR_MEM_NONE_P (vmode.require ()))
@@ -7112,6 +7256,66 @@ rs6000_expand_vector_init (rtx target, rtx vals)
        all_same = false;
     }
 
+  /* Expand vector pairs into separate initializations.  */
+  if (mode == V4DFmode)
+    {
+      rtx target_hi = gen_rtx_SUBREG (V2DFmode, target, BYTES_BIG_ENDIAN ? 0 : 
16);
+      rtvec rtvec_hi = gen_rtvec (2,
+                                 XVECEXP (vals, 0, 0),
+                                 XVECEXP (vals, 0, 1));
+      rtx vals_hi = gen_rtx_PARALLEL (V2DFmode, rtvec_hi);
+
+      rs6000_expand_vector_init (target_hi, vals_hi);
+
+      rtx target_lo = gen_rtx_SUBREG (V2DFmode, target, BYTES_BIG_ENDIAN ? 16 
: 0);
+      if (all_same)
+       emit_move_insn (target_lo, target_hi);
+
+      else
+       {
+         rtvec rtvec_lo = gen_rtvec (2,
+                                     XVECEXP (vals, 0, 2),
+                                     XVECEXP (vals, 0, 3));
+         rtx vals_lo = gen_rtx_PARALLEL (V2DFmode, rtvec_lo);
+
+         rs6000_expand_vector_init (target_lo, vals_lo);
+       }
+
+      return;
+    }
+
+  else if (mode == V8SFmode)
+    {
+      rtx target_hi = gen_rtx_SUBREG (V4SFmode, target, BYTES_BIG_ENDIAN ? 0 : 
16);
+      rtvec rtvec_hi = gen_rtvec (4,
+                                 XVECEXP (vals, 0, 0),
+                                 XVECEXP (vals, 0, 1),
+                                 XVECEXP (vals, 0, 2),
+                                 XVECEXP (vals, 0, 3));
+      rtx vals_hi = gen_rtx_PARALLEL (V4SFmode, rtvec_hi);
+
+      rs6000_expand_vector_init (target_hi, vals_hi);
+
+      rtx target_lo = gen_rtx_SUBREG (V4SFmode, target, BYTES_BIG_ENDIAN ? 16 
: 0);
+
+      if (all_same)
+       emit_move_insn (target_lo, target_hi);
+
+      else
+       {
+         rtvec rtvec_lo = gen_rtvec (4,
+                                     XVECEXP (vals, 0, 4),
+                                     XVECEXP (vals, 0, 5),
+                                     XVECEXP (vals, 0, 6),
+                                     XVECEXP (vals, 0, 7));
+         rtx vals_lo = gen_rtx_PARALLEL (V4SFmode, rtvec_lo);
+
+         rs6000_expand_vector_init (target_lo, vals_lo);
+       }
+
+      return;
+    }
+
   if (n_var == 0)
     {
       rtx const_vec = gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0));
@@ -7750,13 +7954,30 @@ rs6000_expand_vector_set (rtx target, rtx val, rtx 
elt_rtx)
 {
   machine_mode mode = GET_MODE (target);
   machine_mode inner_mode = GET_MODE_INNER (mode);
-  rtx reg = gen_reg_rtx (mode);
   rtx mask, mem, x;
-  int width = GET_MODE_SIZE (inner_mode);
   int i;
 
   val = force_reg (GET_MODE (val), val);
 
+  /* Vectors that take more than one register like vector pairs need to store
+     the whole vector, store the value and then reload.  */
+  if (GET_MODE_SIZE (mode) > 16)
+    {
+      mem = assign_stack_temp (mode, GET_MODE_SIZE (mode));
+      emit_move_insn (mem, target);
+
+      rtx addr = copy_to_mode_reg (Pmode, XEXP (mem, 0));
+      if (elt_rtx != const0_rtx)
+       emit_insn (gen_add2_insn (addr, elt_rtx));
+
+      emit_move_insn (change_address (mem, inner_mode, addr), val);
+      emit_move_insn (target, mem);
+      return;
+    }
+
+  rtx reg = gen_reg_rtx (mode);
+  int width = GET_MODE_SIZE (inner_mode);
+
   if (VECTOR_MEM_VSX_P (mode))
     {
       if (!CONST_INT_P (elt_rtx))
@@ -7878,6 +8099,34 @@ rs6000_expand_vector_extract (rtx target, rtx vec, rtx 
elt)
   machine_mode inner_mode = GET_MODE_INNER (mode);
   rtx mem;
 
+  /* For vector pairs with constant elements, change it into a vector extract
+     of the single register.  */
+  if (VPAIR_FP_P (mode) && CONST_INT_P (elt))
+    {
+      size_t nunits = GET_MODE_NUNITS (mode);
+      size_t elt_num = (size_t) UINTVAL (elt);
+      size_t v_num;
+      machine_mode v_mode;
+
+      if (BYTES_BIG_ENDIAN)
+       v_num = (elt_num >= nunits) ? 16 : 0;
+      else
+       v_num = (elt_num < nunits) ? 16 : 0;
+
+      if (mode == V4DFmode)
+       v_mode = V2DFmode;
+      else if (mode == V8SFmode)
+       v_mode = V4SFmode;
+      else
+       gcc_unreachable ();
+
+      rtx v_vec = gen_rtx_SUBREG (v_mode, vec, v_num);
+      size_t v_nunits = GET_MODE_NUNITS (v_mode);
+      rs6000_expand_vector_extract (target, v_vec,
+                                   GEN_INT (elt_num % v_nunits));
+      return;
+    }
+
   if (VECTOR_MEM_VSX_P (mode) && CONST_INT_P (elt))
     {
       switch (mode)
@@ -8978,6 +9227,8 @@ reg_offset_addressing_ok_p (machine_mode mode)
     case E_TImode:
     case E_TFmode:
     case E_KFmode:
+    case E_V8SFmode:
+    case E_V4DFmode:
       /* AltiVec/VSX vector modes.  Only reg+reg addressing was valid until the
         ISA 3.0 vector d-form addressing mode was added.  While TImode is not
         a vector mode, if we want to use the VSX registers to move it around,
@@ -11094,11 +11345,13 @@ rs6000_const_vec (machine_mode mode)
       break;
     case E_V4SFmode:
     case E_V4SImode:
+    case E_V4DFmode:
       subparts = 4;
       break;
     case E_V8HImode:
     case E_V8HFmode:
     case E_V8BFmode:
+    case E_V8SFmode:
       subparts = 8;
       break;
     case E_V16QImode:
@@ -11561,6 +11814,8 @@ rs6000_emit_move (rtx dest, rtx source, machine_mode 
mode)
     case E_V2DFmode:
     case E_V2DImode:
     case E_V1TImode:
+    case E_V8SFmode:
+    case E_V4DFmode:
       if (CONSTANT_P (operands[1])
          && !easy_vector_constant (operands[1], mode))
        operands[1] = force_const_mem (mode, operands[1]);
@@ -13864,7 +14119,7 @@ rs6000_preferred_reload_class (rtx x, enum reg_class 
rclass)
      the GPR registers.  */
   if (rclass == GEN_OR_FLOAT_REGS)
     {
-      if (mode == OOmode)
+      if (mode == OOmode || VPAIR_FP_P (mode))
        return VSX_REGS;
 
       if (mode == XOmode)
@@ -21034,6 +21289,7 @@ rs6000_handle_altivec_attribute (tree *node,
             proper type in the 'b' case below.  */
        case E_V4SImode: case E_V8HImode: case E_V16QImode: case E_V4SFmode:
        case E_V2DImode: case E_V2DFmode:
+       case E_V8SFmode: case E_V4DFmode:
          result = type;
        default: break;
        }
@@ -23457,29 +23713,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)
-    {
-      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)
-    {
-      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;
 }
@@ -23539,7 +23793,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);
@@ -23614,7 +23868,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;
@@ -25077,6 +25331,7 @@ static struct rs6000_opt_mask const rs6000_opt_masks[] =
   { "save-toc-indirect",       OPTION_MASK_SAVE_TOC_INDIRECT,  false, true  },
   { "string",                  0,                              false, true  },
   { "update",                  OPTION_MASK_NO_UPDATE,          true , true  },
+  { "vector-pair-fp",          OPTION_MASK_VECTOR_PAIR_FP,     false, true  },
   { "vsx",                     OPTION_MASK_VSX,                false, true  },
 #ifdef OPTION_MASK_64BIT
 #if TARGET_AIX_OS
@@ -25148,6 +25403,21 @@ static struct rs6000_opt_var const rs6000_opt_vars[] =
   { "speculate-indirect-jumps",
     offsetof (struct gcc_options, x_rs6000_speculate_indirect_jumps),
     offsetof (struct cl_target_option, x_rs6000_speculate_indirect_jumps), },
+  { "vector-pair-memory",
+    offsetof (struct gcc_options, x_TARGET_VECTOR_PAIR_MEMORY),
+    offsetof (struct cl_target_option, x_TARGET_VECTOR_PAIR_MEMORY), },
+  { "vector-pair-load",
+    offsetof (struct gcc_options, x_TARGET_VECTOR_PAIR_LOAD),
+    offsetof (struct cl_target_option, x_TARGET_VECTOR_PAIR_LOAD), },
+  { "vector-pairstore",
+    offsetof (struct gcc_options, x_TARGET_VECTOR_PAIR_STORE),
+    offsetof (struct cl_target_option, x_TARGET_VECTOR_PAIR_STORE), },
+  { "vector-pair-float",
+    offsetof (struct gcc_options, x_TARGET_VECTOR_PAIR_FLOAT),
+    offsetof (struct cl_target_option, x_TARGET_VECTOR_PAIR_FLOAT), },
+  { "vector-pair-double",
+    offsetof (struct gcc_options, x_TARGET_VECTOR_PAIR_DOUBLE),
+    offsetof (struct cl_target_option, x_TARGET_VECTOR_PAIR_DOUBLE), },
 };
 
 /* Inner function to handle attribute((target("..."))) and #pragma GCC target
@@ -27997,6 +28267,10 @@ rs6000_split_multireg_move (rtx dst, rtx src)
      vectors.  */
   else if (mode == OOmode || mode == XOmode || mode == TDOmode)
     reg_mode = V1TImode;
+  else if (mode == V8SFmode)
+    reg_mode = V4SFmode;
+  else if (mode == V4DFmode)
+    reg_mode = V2DFmode;
   else if (FP_REGNO_P (reg))
     reg_mode = DECIMAL_FLOAT_MODE_P (mode) ? DDmode :
        (TARGET_HARD_FLOAT ? DFmode : SFmode);
@@ -29720,6 +29994,113 @@ vec_const_128bit_to_bytes (rtx op,
   return true;
 }
 
+/* Convert a vector constant OP with mode MODE to a pair of vector 128-bit
+   constant structures INFO similar to vec_const_256bit_to_bytes.  This is to
+   handle constants of paired vectors such as V8SFmode and V4DFmode.
+
+   Break out the constant out to bytes, half words, words, and double words.
+   Return true if we have successfully converted the constant.  We use the
+   128-bit constant infrastructure, returning two separate structures.
+
+   We handle CONST_VECTOR and VEC_DUPLICATE of constants.  */
+
+bool
+vec_const_256bit_to_bytes (rtx op,
+                          machine_mode mode,
+                          vec_const_128bit_type *info_hi,
+                          vec_const_128bit_type *info_lo)
+{
+  /* Initialize the constant structures.  */
+  memset ((void *)info_hi, 0, sizeof (vec_const_128bit_type));
+  memset ((void *)info_lo, 0, sizeof (vec_const_128bit_type));
+
+  machine_mode vmode;                  /* single vector mode.  */
+
+  if (mode == V8SFmode)
+    vmode = V4SFmode;
+
+  else if (mode == V4DFmode)
+    vmode = V2DFmode;
+
+  else
+    return false;
+
+  switch (GET_CODE (op))
+    {
+      /* Treat VEC_DUPLICATE of a constant just like a vector constant.
+        Since we are duplicating the element, we don't have to worry about
+        endian issues.  */
+    case VEC_DUPLICATE:
+      {
+       rtx vdup = gen_rtx_VEC_DUPLICATE (vmode, XEXP (op, 0));
+       if (vec_const_128bit_to_bytes (vdup, vmode, info_hi))
+         {
+           *info_lo = *info_hi;
+           return true;
+         }
+      }
+      break;
+
+      /* Vector constants, use vec_const_128bit_to_bytes to handle each
+        vector's worth.  On little endian systems, we have to reverse the
+        vectors, and vec_const_128bit_to_bytes will reverse the elements
+        within that vector.  */
+    case CONST_VECTOR:
+      {
+       if (!BYTES_BIG_ENDIAN)
+         std::swap (info_hi, info_lo);
+
+       size_t nunits = GET_MODE_NUNITS (vmode);
+
+      /* Split V4DFmode/V4DImode into 2 V2DFmode/V2DImode tests.  */
+       if (nunits == 2)
+         {
+           /* Validate the first 2 elements.  */
+           rtvec v = gen_rtvec (2,
+                                CONST_VECTOR_ELT (op, 0),
+                                CONST_VECTOR_ELT (op, 1));
+
+           rtx cv = gen_rtx_CONST_VECTOR (V2DFmode, v);
+           if (!vec_const_128bit_to_bytes (cv, vmode, info_hi))
+             return false;
+
+           /* Validate the last 2 elements.  */
+           RTVEC_ELT (v, 0) = CONST_VECTOR_ELT (op, 2);
+           RTVEC_ELT (v, 1) = CONST_VECTOR_ELT (op, 3);
+           return vec_const_128bit_to_bytes (cv, vmode, info_lo);
+         }
+
+       /* Split V8SFmode/V8SImode into 2 V4SFmode/V4SImode tests.  */
+       else if (nunits == 4)
+         {
+           /* Validate the first 4 elements.  */
+           rtvec v = gen_rtvec (4,
+                                CONST_VECTOR_ELT (op, 0),
+                                CONST_VECTOR_ELT (op, 1),
+                                CONST_VECTOR_ELT (op, 2),
+                                CONST_VECTOR_ELT (op, 3));
+
+           rtx cv = gen_rtx_CONST_VECTOR (vmode, v);
+           if (!vec_const_128bit_to_bytes (cv, vmode, info_hi))
+             return false;
+
+           /* Validate the last 4 elements.  */
+           RTVEC_ELT (v, 0) = CONST_VECTOR_ELT (op, 4);
+           RTVEC_ELT (v, 1) = CONST_VECTOR_ELT (op, 5);
+           RTVEC_ELT (v, 2) = CONST_VECTOR_ELT (op, 6);
+           RTVEC_ELT (v, 3) = CONST_VECTOR_ELT (op, 7);
+           return vec_const_128bit_to_bytes (cv, vmode, info_lo);
+         }
+      }
+      break;
+
+    default:
+      break;
+    }
+
+  return false;
+}
+
 /* Determine if an IEEE 128-bit constant can be loaded with LXVKQ.  Return zero
    if the LXVKQ instruction cannot be used.  Otherwise return the immediate
    value to be used with the LXVKQ instruction.  */
@@ -29904,6 +30285,59 @@ constant_generates_xxspltidp (vec_const_128bit_type 
*vsx_const)
   return sf_value;
 }
 
+/* Return how to generate a vector constant if it can be loaded into a vector
+   register via any means without doing a load.  INFO returns the value that
+   the constant_generate_<xxx> instructions return.  */
+
+vect_const_method
+vect_const_can_be_generated (vec_const_128bit_type *vect_const,
+                            unsigned *info)
+{
+  if (vect_const->all_bytes_same)
+    {
+      unsigned char value = vect_const->bytes[0];
+      *info = value;
+      if (value == 0)
+       return VECT_CONST_ZERO;         /* XXLXOR.  */
+
+      if (TARGET_P9_VECTOR)
+       return VECT_CONST_XXSPLTIB;
+
+      if (value == 0xff && TARGET_P8_VECTOR)
+       return VECT_CONST_ONES;         /* XXLORC.  */
+    }
+
+  if (TARGET_POWER10)
+    {
+      unsigned info2;
+
+      info2 = constant_generates_xxspltiw (vect_const);
+      if (info2 != 0)
+       {
+         *info = info2;
+         return VECT_CONST_XXSPLTIW;
+       }
+
+      info2 = constant_generates_xxspltidp (vect_const);
+      if (info2 != 0)
+       {
+         *info = info2;
+         return VECT_CONST_XXSPLTIDP;
+       }
+
+      info2 = constant_generates_lxvkq (vect_const);
+      if (info2 != 0)
+       {
+         *info = info2;
+         return VECT_CONST_LXVKG;
+       }
+    }
+
+  /* Constant can't be loaded.  */
+  *info = 0;
+  return VECT_CONST_MEMORY;
+}
+
 /* Now we have three opaque types: the __vector_quad, __vector_pair and
    __dmr1024 built-in types.  They are target specific and each one is
    only available when its required ISA support is enabled:
@@ -29994,7 +30428,40 @@ rs6000_opaque_type_invalid_use_p (gimple *stmt)
 
   return false;
 }
+
+/* Split up the operands for vector pair operation into separate operations on
+   each vector register.  Take the first N_OPERANDS from the OPERANDS array and
+   adjust the next n_operands to have the high register and the following
+   n_operands will have the low register.  Each single register operands will
+   use MODE for the machine mode.
+
+   Because vector pair registers are required to be even/odd regiters, we don't
+   have to worry about registers overlapping.
+
+   Unary operations have 2 operands, binary operations have 3 operands, and
+   fma/xxsel operation have 4 operands.  */
+
+void
+split_vector_pair_operands (size_t n_operands,
+                           rtx operands[],
+                           machine_mode mode)
+{
+  size_t hi_regs = n_operands;
+  size_t lo_regs = n_operands * 2;
+
+  gcc_assert (IN_RANGE (n_operands, 2, 4));
+
+  for (size_t i = 0; i < n_operands; i++)
+    {
+      unsigned r = reg_or_subregno (operands[i]);
+      operands[ hi_regs+i ] = gen_rtx_REG (mode, r);
+      operands[ lo_regs+i ] = gen_rtx_REG (mode, r+1);
+    }
+
+  return;
+}
 
+
 #undef TARGET_DOCUMENTATION_NAME
 #define TARGET_DOCUMENTATION_NAME "PowerPC"
 
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 4a9eb4832b9b..129ef317761f 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -353,6 +353,10 @@ extern const char *host_detect_local_cpu (int argc, const 
char **argv);
                                         && !BYTES_BIG_ENDIAN           \
                                         && TARGET_HARD_FLOAT)
 
+/* Whether a given mode represents a paired vector used for floating point
+   arithmetic operations.  */
+#define VPAIR_FP_P(MODE)       ((MODE) == V8SFmode || (MODE) == V4DFmode)
+
 /* Helper macros for TFmode.  Quad floating point (TFmode) can be either IBM
    long double format that uses a pair of doubles, or IEEE 128-bit floating
    point.  KFmode was added as a way to represent IEEE 128-bit floating point,
@@ -2274,9 +2278,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,
@@ -2331,8 +2337,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,
@@ -2378,9 +2386,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])
@@ -2432,8 +2442,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 a3cc33f63ff9..aa6c4a998ebd 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -628,7 +628,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])
@@ -638,7 +638,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")
@@ -876,7 +877,7 @@
 ;; supplement addressing modes.
 (define_mode_iterator RELOAD [V16QI V8HI V8BF V8HF V4SI V2DI V4SF V2DF V1TI
                              SF SD SI DF DD DI TI PTI KF IF TF HF BF
-                             OO XO])
+                             OO XO V8SF V4DF])
 
 ;; Iterate over smin, smax
 (define_code_iterator fp_minmax        [smin smax])
diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
index f39d6f0a3107..23f3a6f437cb 100644
--- a/gcc/config/rs6000/rs6000.opt
+++ b/gcc/config/rs6000/rs6000.opt
@@ -658,6 +658,30 @@ mfloat16-debug2
 Target Undocumented Var(TARGET_FLOAT16_DEBUG2) Init(0) Save
 Turn on float16 debugging #2.
 
+mvector-pair-fp
+Target Mask(VECTOR_PAIR_FP) Var(rs6000_isa_flags)
+Enable or disable using paired vectors for floating point operations
+
+mvector-pair-memory
+Target Undocumented Var(TARGET_VECTOR_PAIR_MEMORY) Init(-1) Save
+Generate/do not generate lxvp/stxvp for vector pairs.
+
+mvector-pair-load
+Target Undocumented Var(TARGET_VECTOR_PAIR_LOAD) Init(-1) Save
+Generate/do not generate lxvp for vector pairs.
+
+mvector-pair-store
+Target Undocumented Var(TARGET_VECTOR_PAIR_STORE) Init(-1) Save
+Generate/do not generate stxvp for vector pairs.
+
+mvector-pair-float
+Target Undocumented Var(TARGET_VECTOR_PAIR_FLOAT) Init(1) Save
+Generate/do not vectorize float to use vector pair if -mvector-pair-fp.
+
+mvector-pair-double
+Target Undocumented Var(TARGET_VECTOR_PAIR_DOUBLE) Init(1) Save
+Generate/do not vectorize double to use vector pair if -mvector-pair-fp.
+
 ; Documented parameters
 
 -param=rs6000-vect-unroll-limit=
diff --git a/gcc/config/rs6000/vector.md b/gcc/config/rs6000/vector.md
index 5fd4e470ade0..cda17e877df0 100644
--- a/gcc/config/rs6000/vector.md
+++ b/gcc/config/rs6000/vector.md
@@ -90,7 +90,9 @@
                             V8BF
                             V8HF
                             V4SF
-                            V2DF])
+                            V2DF
+                            V8SF
+                            V4DF])
 
 ;; Vector modes for 64-bit base types
 (define_mode_iterator VEC_64 [V2DI V2DF])
@@ -107,6 +109,8 @@
                            (V8HF  "HF")
                            (V4SF  "SF")
                            (V2DF  "DF")
+                           (V8SF  "SF")
+                           (V4DF  "DF")
                            (V1TI  "TI")
                            (TI    "TI")])
 
@@ -119,6 +123,8 @@
                              (V8HF  "hf")
                              (V4SF  "sf")
                              (V2DF  "df")
+                             (V8SF  "sf")
+                             (V4DF  "df")
                              (V1TI  "ti")
                              (TI    "ti")])
 
diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index 486efadeea89..7a9f8c4ba165 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -195,6 +195,8 @@
 ;; Appropriate type for add ops (and other simple FP ops)
 (define_mode_attr VStype_simple        [(V2DF "vecdouble")
                                 (V4SF "vecfloat")
+                                (V4DF "vecdouble")
+                                (V8SF "vecfloat")
                                 (DF   "fp")])
 
 ;; Appropriate type for multiply ops
@@ -204,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
@@ -286,6 +290,9 @@
 ;; and Vector Integer Multiply/Divide/Modulo Instructions
 (define_mode_iterator VIlong [V2DI V4SI])
 
+;; Mode iterator for floating point vectors paired together
+(define_mode_iterator VPAIR_FP [V8SF V4DF])
+
 ;; Constants for creating unspecs
 (define_c_enum "unspec"
   [UNSPEC_VSX_CONCAT
@@ -7343,3 +7350,537 @@
                     UNSPEC_XSREBASE3T3UQM))]
   "TARGET_FUTURE"
   "xsrebase3t3uqm %x0,%x2,%x3")
+
+
+;; Vector pair load/store for floating point.
+(define_expand "mov<mode>"
+  [(set (match_operand:VPAIR_FP 0 "nonimmediate_operand")
+        (match_operand:VPAIR_FP 1 "input_operand"))]
+  "TARGET_P9_VECTOR
+   && (TARGET_VECTOR_PAIR_FP || TARGET_VECTOR_PAIR_MEMORY)")
+
+(define_insn_and_split "*mov<mode>_p10"
+  [(set (match_operand:VPAIR_FP 0 "nonimmediate_operand" "=wa,ZwO,wa,wa")
+       (match_operand:VPAIR_FP 1 "any_operand"          "ZwO, wa,wa,eF"))]
+  "TARGET_POWER10 && TARGET_VECTOR_PAIR_LOAD && TARGET_VECTOR_PAIR_STORE"
+  "@
+   lxvp%X1 %x0,%1
+   stxvp%X0 %x1,%0
+   #
+   #"
+  "&& reload_completed && !MEM_P (operands[0]) && !MEM_P (operands[1])"
+  [(const_int 0)]
+{
+  rs6000_split_multireg_move (operands[0], operands[1]);
+  DONE;
+}
+  [(set_attr "type" "vecload,vecstore,veclogical,veclogical")
+   (set_attr "length" "*,*,8,16")
+   (set_attr "num_insns" "*,*,2,2")
+   (set_attr "max_prefixed_insns" "*,*,*,2")])
+
+(define_insn_and_split "*mov<mode>_p10_lxvp"
+  [(set (match_operand:VPAIR_FP 0 "nonimmediate_operand" "=wa,wO,wa,wa")
+       (match_operand:VPAIR_FP 1 "any_operand"          "ZwO,wa,wa,eF"))]
+  "TARGET_POWER10 && TARGET_VECTOR_PAIR_LOAD && !TARGET_VECTOR_PAIR_STORE"
+  "@
+   lxvp%X1 %x0,%1
+   #
+   #
+   #"
+  "&& reload_completed && !MEM_P (operands[1])"
+  [(const_int 0)]
+{
+  rs6000_split_multireg_move (operands[0], operands[1]);
+  DONE;
+}
+  [(set_attr "type" "vecload,vecstore,veclogical,veclogical")
+   (set_attr "length" "*,8,8,16")
+   (set_attr "num_insns" "*,2,2,2")
+   (set_attr "max_prefixed_insns" "*,2,*,2")])
+
+(define_insn_and_split "*mov<mode>_p10_stxvp"
+  [(set (match_operand:VPAIR_FP 0 "nonimmediate_operand" "=wa,ZwO,wa,wa")
+       (match_operand:VPAIR_FP 1 "any_operand"           "wO, wa,wa,eF"))]
+  "TARGET_POWER10 && !TARGET_VECTOR_PAIR_LOAD && TARGET_VECTOR_PAIR_STORE"
+  "@
+   #
+   stxvp%X0 %x1,%0
+   #
+   #"
+  "&& reload_completed && !MEM_P (operands[0])"
+  [(const_int 0)]
+{
+  rs6000_split_multireg_move (operands[0], operands[1]);
+  DONE;
+}
+  [(set_attr "type" "vecload,vecstore,veclogical,veclogical")
+   (set_attr "length" "8,*,8,16")
+   (set_attr "num_insns" "2,*,2,2")
+   (set_attr "max_prefixed_insns" "2,*,*,2")])
+
+(define_insn_and_split "*mov<mode>_p9"
+  [(set (match_operand:VPAIR_FP 0 "nonimmediate_operand" "=wa,wO,wa,wa")
+       (match_operand:VPAIR_FP 1 "any_operand"           "wO,wa,wa, j"))]
+  "TARGET_P9_VECTOR
+   && (TARGET_VECTOR_PAIR_FP || TARGET_VECTOR_PAIR_MEMORY)"
+  "#"
+  "&& reload_completed
+   && (!TARGET_POWER10
+       || (!TARGET_VECTOR_PAIR_LOAD && !TARGET_VECTOR_PAIR_STORE))"
+  [(const_int 0)]
+{
+  rs6000_split_multireg_move (operands[0], operands[1]);
+  DONE;
+}
+  [(set_attr "type" "vecload,vecstore,veclogical,veclogical")
+   (set_attr "length" "8,8,8,32")
+   (set_attr "num_insns" "2,2,2,2")])
+
+;; Unary/binary operators supporting vector pair splits
+(define_code_iterator VPAIR_FP_unary [abs neg])
+
+(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  "mul")
+                                (neg   "neg")
+                                (plus  "add")])
+
+;; Map a paired vector mode to the base mode
+(define_mode_attr VPAIR_FP_BASE [(V8SF  "SF")
+                                (V4DF  "DF")])
+
+;; Map a paired vector mode back into the single vector mode
+(define_mode_attr VPAIR_FP_SINGLE [(V8SF "V4SF")
+                                  (V4DF "V2DF")])
+
+(define_insn_and_split "*dup<mode>"
+  [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa,wa,wa")
+       (vec_duplicate:VPAIR_FP
+        (match_operand:<VPAIR_FP_BASE> 1 "splat_input_operand" "Z,wa,eP")))]
+  "TARGET_VECTOR_PAIR_FP"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 2)
+       (vec_duplicate:VPAIR_FP
+        (match_dup 1)))
+   (set (match_dup 3)
+       (vec_duplicate:VPAIR_FP
+        (match_dup 1)))]
+{
+  machine_mode mode = <VPAIR_FP_SINGLE>mode;
+  unsigned r0 = reg_or_subregno (operands[0]);
+
+  operands[2] = gen_rtx_REG (mode, r0);
+  operands[3] = gen_rtx_REG (mode, r0 + 1);
+}
+  [(set_attr "type" "vecload,vecperm,veclogical")
+   (set_attr "length" "8,8,16")
+   (set_attr "prefixed" "*,*,yes")])
+
+(define_insn_and_split "<VPAIR_FP_name><mode>2"
+  [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa")
+       (VPAIR_FP_unary:VPAIR_FP
+        (match_operand:VPAIR_FP 1 "vsx_register_operand" "wa")))]
+  "TARGET_VECTOR_PAIR_FP"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 2)
+       (VPAIR_FP_unary:<VPAIR_FP_SINGLE> (match_dup 3)))
+   (set (match_dup 4)
+       (VPAIR_FP_unary:<VPAIR_FP_SINGLE> (match_dup 5)))]
+{
+  split_vector_pair_operands (2, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(set_attr "type" "<VStype_simple>")
+   (set_attr "length" "8")])
+
+(define_insn_and_split "*nabs<mode>2"
+  [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa")
+       (VPAIR_FP_unary:VPAIR_FP
+        (match_operand:VPAIR_FP 1 "vsx_register_operand" "wa")))]
+  "TARGET_VECTOR_PAIR_FP"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 2)
+       (neg:<VPAIR_FP_SINGLE>
+        (abs:<VPAIR_FP_SINGLE>
+         (match_dup 3))))
+   (set (match_dup 4)
+       (neg:<VPAIR_FP_SINGLE>
+        (abs:<VPAIR_FP_SINGLE>
+         (match_dup 5))))]
+{
+  split_vector_pair_operands (2, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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)))]
+{
+  split_vector_pair_operands (2, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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))]
+{
+  split_vector_pair_operands (2, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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))]
+{
+  split_vector_pair_operands (2, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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
+        (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)
+       (VPAIR_FP_binary:<VPAIR_FP_SINGLE>
+        (match_dup 4)
+        (match_dup 5)))
+   (set (match_dup 6)
+       (VPAIR_FP_binary:<VPAIR_FP_SINGLE>
+        (match_dup 7)
+        (match_dup 8)))]
+{
+  split_vector_pair_operands (3, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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)))]
+{
+  split_vector_pair_operands (3, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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
+        (match_operand:VPAIR_FP 1 "vsx_register_operand" "%wa,wa")
+        (match_operand:VPAIR_FP 2 "vsx_register_operand" "wa,0")
+        (match_operand:VPAIR_FP 3 "vsx_register_operand" "0,wa")))]
+  "TARGET_VECTOR_PAIR_FP"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 4)
+       (fma:<VPAIR_FP_SINGLE>
+        (match_dup 5)
+        (match_dup 6)
+        (match_dup 7)))
+   (set (match_dup 8)
+       (fma:<VPAIR_FP_SINGLE>
+        (match_dup 9)
+        (match_dup 10)
+        (match_dup 11)))]
+{
+  split_vector_pair_operands (4, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(set_attr "type" "<VStype_simple>")
+   (set_attr "length" "8")])
+
+(define_insn_and_split "*fms<mode>4"
+  [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa,wa")
+       (fma:VPAIR_FP
+        (match_operand:VPAIR_FP 1 "vsx_register_operand" "%wa,wa")
+        (match_operand:VPAIR_FP 2 "vsx_register_operand" "wa,0")
+        (neg:VPAIR_FP
+         (match_operand:VPAIR_FP 3 "vsx_register_operand" "0,wa"))))]
+  "TARGET_VECTOR_PAIR_FP"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 4)
+       (fma:<VPAIR_FP_SINGLE>
+        (match_dup 5)
+        (match_dup 6)
+        (neg:<VPAIR_FP_SINGLE>
+         (match_dup 7))))
+   (set (match_dup 8)
+       (fma:<VPAIR_FP_SINGLE>
+        (match_dup 9)
+        (match_dup 10)
+        (neg:<VPAIR_FP_SINGLE>
+         (match_dup 11))))]
+{
+  split_vector_pair_operands (4, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(set_attr "type" "<VStype_simple>")
+   (set_attr "length" "8")])
+
+(define_insn_and_split "*nfma<mode>4"
+  [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa,wa")
+       (neg:VPAIR_FP
+        (fma:VPAIR_FP
+         (match_operand:VPAIR_FP 1 "vsx_register_operand" "%wa,wa")
+         (match_operand:VPAIR_FP 2 "vsx_register_operand" "wa,0")
+         (match_operand:VPAIR_FP 3 "vsx_register_operand" "0,wa"))))]
+  "TARGET_VECTOR_PAIR_FP"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 4)
+       (neg:<VPAIR_FP_SINGLE>
+        (fma:<VPAIR_FP_SINGLE>
+         (match_dup 5)
+         (match_dup 6)
+         (match_dup 7))))
+   (set (match_dup 8)
+       (neg:<VPAIR_FP_SINGLE>
+        (fma:<VPAIR_FP_SINGLE>
+         (match_dup 9)
+         (match_dup 10)
+         (match_dup 11))))]
+{
+  split_vector_pair_operands (4, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(set_attr "type" "<VStype_simple>")
+   (set_attr "length" "8")])
+
+(define_insn_and_split "*nfms<mode>4"
+  [(set (match_operand:VPAIR_FP 0 "vsx_register_operand" "=wa,wa")
+       (neg:VPAIR_FP
+        (fma:VPAIR_FP
+         (match_operand:VPAIR_FP 1 "vsx_register_operand" "%wa,wa")
+         (match_operand:VPAIR_FP 2 "vsx_register_operand" "wa,0")
+         (neg:VPAIR_FP
+          (match_operand:VPAIR_FP 3 "vsx_register_operand" "0,wa")))))]
+  "TARGET_VECTOR_PAIR_FP"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 4)
+       (neg:<VPAIR_FP_SINGLE>
+        (fma:<VPAIR_FP_SINGLE>
+         (match_dup 5)
+         (match_dup 6)
+         (neg:<VPAIR_FP_SINGLE>
+          (match_dup 7)))))
+   (set (match_dup 8)
+       (neg:<VPAIR_FP_SINGLE>
+        (fma:<VPAIR_FP_SINGLE>
+         (match_dup 9)
+         (match_dup 10)
+         (neg:<VPAIR_FP_SINGLE>
+          (match_dup 11)))))]
+{
+  split_vector_pair_operands (4, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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))))]
+{
+  split_vector_pair_operands (4, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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))))]
+{
+  split_vector_pair_operands (4, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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))))]
+{
+  split_vector_pair_operands (4, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(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))))]
+{
+  split_vector_pair_operands (4, operands, <VPAIR_FP_SINGLE>mode);
+}
+  [(set_attr "type" "vecmove")
+   (set_attr "length" "8")])
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index dc44e953c946..56e172dc2ecf 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1410,7 +1410,8 @@ See RS/6000 and PowerPC Options.
 -mstack-protector-guard-offset=@var{offset}  -mprefixed
 -mpcrel  -mmma  -mdense-math  -mrop-protect  -mprivileged
 -mno-splat-word-constant  -mno-splat-float-constant
--mno-ieee128-constant  -mno-warn-altivec-long}
+-mno-ieee128-constant  -mno-warn-altivec-long
+-mvector-pair-fp}
 
 @emph{RX Options} (@ref{RX Options})
 @gccoptlist{-m64bit-doubles  -m32bit-doubles  -fpu  -nofpu
@@ -33186,6 +33187,16 @@ This option is enabled by default.
 Enable or disable warnings about deprecated @samp{vector long ...} Altivec
 type usage.  This option is enabled by default.
 
+@opindex mvector-pair-fp
+@opindex mno-vector-pair-fp
+@item -mvector-pair-fp
+@itemx -mno-vector-pair-fp
+Enable or disable generation of vector pair load and vectore pair
+store instructions when generating code for @code{-mcpu=power10} or
+later systems.
+
+At present, this is an experimental option.  It is not on by default,
+and it may change in the future.
 @end table
 
 @node RX Options

Reply via email to