https://gcc.gnu.org/g:788d6e688b4190b625f79e1b70a487cbc0f53fe4

commit 788d6e688b4190b625f79e1b70a487cbc0f53fe4
Author: Michael Meissner <[email protected]>
Date:   Thu Nov 12 23:11:47 2026 -0500

    Work on -mvector-pair-fp; Add -mvector-pair-memory.
    
    2026-11-12  Michael Meissner  <[email protected]>
    
            * config/rs6000/rs6000.cc (rs6000_debug_reg_global): Print vector 
pair
            debug information.
            (rs6000_setup_reg_addr_masks): Set up quad addressing for vector 
pairs,
            and allow indexed addressing, even we are spliting the load or store
            since the constraints for the split load/store will not allow 
indexed
            addressing.
            (rs6000_init_hard_regno_mode_ok): Do not set rs6000_vector_unit to 
VSX
            for vector pair modes, unless we have -mvector-pair-fp, but do set 
the
            defaults for memory addressing if we have -mvector-pair-memory.
            (rs6000_option_override_internal): Add support for 
-mvector-pair-memory.
            (rs6000_preferred_reload_class): Vector pair modes prefer VSX 
registers.
            (opt_vars): Add the various TARGET_VECTOR_PAIR_* debug options.
            (rs6000_split_multireg_move): Treat vector pair arithmetic modes 
like
            OOmode.
            * config/rs6000/rs6000.md (isa attribute): Delete p10l and p10s
            attributes.
            * config/rs6000/rs6000.opt (-mvector-pair-memory): New option.
            (-mvector-pair-load): Rename from -mvector-pair-fp-load.  
Initialize to
            -1 to add support for -mvector-pair-memory.
            (-mvector-pair-store): Rename from -mvector-pair-fp-store.  
Initialize
            to -1 to add support for -mvector-pair-memory.
            * config/rs6000/vsx.md (mov<mode>*, VPAIR_FP iterator).  Rewrite 
move
            patterns, splitting up p10 with both vector pair insns, p10 with 
just
            vector pair load, p10 with just vector pair store, and p9 versions. 
 Set
            num_insns and max_prefixed_insns support.

Diff:
---
 gcc/config/rs6000/rs6000.cc  | 84 ++++++++++++++++++++++++++++++++++-----
 gcc/config/rs6000/rs6000.md  | 10 +----
 gcc/config/rs6000/rs6000.opt | 16 +++++---
 gcc/config/rs6000/vsx.md     | 95 ++++++++++++++++++++++++++++++--------------
 4 files changed, 151 insertions(+), 54 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 2ec65f420e6b..d88298c8b641 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -2684,6 +2684,19 @@ rs6000_debug_reg_global (void)
       fprintf (stderr, DEBUG_FMT_S, "__bf16", "disabled");
     }
 
+  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);
+
   if (TARGET_HARD_FLOAT)
     {
       rs6000_debug_fp_mode (SFmode);
@@ -2723,7 +2736,7 @@ rs6000_debug_reg_global (void)
            }
        }
 
-      if (TARGET_P9_VECTOR)
+      if (TARGET_VECTOR_PAIR_FP)
        {
          rs6000_debug_fp_mode (V8SFmode);
          rs6000_debug_fp_mode (V4DFmode);
@@ -2902,10 +2915,13 @@ rs6000_setup_reg_addr_masks (void)
 
          else if ((addr_mask != 0) && TARGET_P9_VECTOR && VPAIR_FP_P (m2))
            {
-             addr_mask |= RELOAD_REG_OFFSET;
-             if (TARGET_POWER10
-                 && TARGET_VECTOR_PAIR_FP_LOAD
-                 && TARGET_VECTOR_PAIR_FP_STORE)
+             /* 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;
            }
 
@@ -3114,15 +3130,20 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p)
     }
 
   /* paired floating point vector mode.  */
-  if (TARGET_P9_VECTOR)
+  if (TARGET_P9_VECTOR
+      && (TARGET_VECTOR_PAIR_FP || TARGET_VECTOR_PAIR_MEMORY))
     {
-      rs6000_vector_unit[V8SFmode] = VECTOR_VSX;
       rs6000_vector_mem[V8SFmode] = VECTOR_VSX;
       rs6000_vector_align[V8SFmode] = align32;
 
-      rs6000_vector_unit[V4DFmode] = VECTOR_VSX;
       rs6000_vector_mem[V4DFmode] = VECTOR_VSX;
       rs6000_vector_align[V4DFmode] = align32;
+
+      if (TARGET_VECTOR_PAIR_FP)
+       {
+         rs6000_vector_unit[V8SFmode] = VECTOR_VSX;
+         rs6000_vector_unit[V4DFmode] = VECTOR_VSX;
+       }
     }
 
   /* DFmode, see if we want to use the VSX unit.  Memory is handled
@@ -4191,6 +4212,34 @@ rs6000_option_override_internal (bool global_init_p)
               "-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);
 
@@ -14081,7 +14130,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)
@@ -25365,6 +25414,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
@@ -28268,7 +28332,7 @@ rs6000_split_multireg_move (rtx dst, rtx src)
      below.  This means the last register gets the first memory
      location.  We also need to be careful of using the right register
      numbers if we are splitting XO to OO.  */
-  if (mode == OOmode || mode == XOmode || mode == TDOmode || VPAIR_FP_P (mode))
+  if (mode == OOmode || mode == XOmode || mode == TDOmode)
     {
       nregs = hard_regno_nregs (reg, mode);
       int reg_mode_nregs = hard_regno_nregs (reg, reg_mode);
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 228824979623..932520be073e 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -371,7 +371,7 @@
   (const (symbol_ref "(enum attr_cpu) rs6000_tune")))
 
 ;; The ISA we implement.
-(define_attr "isa" 
"any,p5,p6,p7,p7v,p8,p8v,p9,p9v,p9kf,p9tf,p10,future,mma,dmf,prefixed,p10l,p10s"
+(define_attr "isa" 
"any,p5,p6,p7,p7v,p8,p8v,p9,p9v,p9kf,p9tf,p10,future,mma,dmf,prefixed"
   (const_string "any"))
 
 ;; Is this alternative enabled for the current CPU/ISA/etc.?
@@ -440,14 +440,6 @@
          (match_test "TARGET_PREFIXED"))
      (const_int 1)
 
-     (and (eq_attr "isa" "p10l")
-         (match_test "TARGET_POWER10 && TARGET_VECTOR_PAIR_FP_LOAD"))
-     (const_int 1)
-
-     (and (eq_attr "isa" "p10s")
-         (match_test "TARGET_POWER10 && TARGET_VECTOR_PAIR_FP_STORE"))
-     (const_int 1)
-
     ] (const_int 0)))
 
 ;; If this instruction is microcoded on the CELL processor
diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
index 6d3621574155..23f3a6f437cb 100644
--- a/gcc/config/rs6000/rs6000.opt
+++ b/gcc/config/rs6000/rs6000.opt
@@ -662,13 +662,17 @@ mvector-pair-fp
 Target Mask(VECTOR_PAIR_FP) Var(rs6000_isa_flags)
 Enable or disable using paired vectors for floating point operations
 
-mvector-pair-fp-load
-Target Undocumented Var(TARGET_VECTOR_PAIR_FP_LOAD) Init(1) Save
-Generate/do not generate lxvp if -mvector-pair-fp.
+mvector-pair-memory
+Target Undocumented Var(TARGET_VECTOR_PAIR_MEMORY) Init(-1) Save
+Generate/do not generate lxvp/stxvp for vector pairs.
 
-mvector-pair-fp-store
-Target Undocumented Var(TARGET_VECTOR_PAIR_FP_STORE) Init(1) Save
-Generate/do not generate stxvp if -mvector-pair-fp.
+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
diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index 931e2647213a..cfe4781dd210 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -7349,49 +7349,86 @@
 (define_expand "mov<mode>"
   [(set (match_operand:VPAIR_FP 0 "nonimmediate_operand")
         (match_operand:VPAIR_FP 1 "input_operand"))]
-  "TARGET_P9_VECTOR")
-
-(define_insn_and_split "*mov<mode>"
-  [(set (match_operand:VPAIR_FP 0 "nonimmediate_operand"
-               "=wa,  Z, wa, wO, wa, wa")
-       (match_operand:VPAIR_FP 1 "any_operand"
-                 "Z, wa, wO, wa, wa, eF"))]
   "TARGET_P9_VECTOR
-   && ((!MEM_P (operands[0]) || !MEM_P (operands[1]))
-       || (MEM_P (operands[0])
-           && ((TARGET_POWER10 && TARGET_VECTOR_PAIR_FP_STORE)
-               || vsx_quad_dform_memory_operand (operands[0], <MODE>mode)))
-       || (MEM_P (operands[1])
-           && ((TARGET_POWER10 && TARGET_VECTOR_PAIR_FP_LOAD)
-                || vsx_quad_dform_memory_operand (operands[1], <MODE>mode))))"
+   && (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
-   && ((!MEM_P (operands[0]) && !MEM_P (operands[1]))
-       || (MEM_P (operands[0])
-           && (!TARGET_POWER10
-               || !TARGET_VECTOR_PAIR_FP_STORE
-               || !indexed_or_indirect_operand (operands[0], <MODE>mode)))
-       || (MEM_P (operands[1])
-           && (!TARGET_POWER10
-               || !TARGET_VECTOR_PAIR_FP_LOAD
-               || !indexed_or_indirect_operand (operands[1], <MODE>mode))))"
+   && (!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,  vecload, vecstore, veclogical,
-                       veclogical")
-   (set_attr "isa"    "p10l,      p10s,      *,       *,        *,
-                       *")
-   (set_attr "length" "*,         *,         8,       8,        8,
-                       16")])
+  [(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])

Reply via email to