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

commit a7e4699f286e48b9de7b8c81542b0e6897df7c0a
Author: Peter Bergner <berg...@linux.ibm.com>
Date:   Fri Jan 17 16:14:48 2025 -0500

    rs6000: Disassemble opaque modes using subregs to allow optimizations 
[PR109116]
    
    PR109116 exposes an issue where using unspecs to access each vector 
component
    of an opaque mode variable leads to unneeded register copies, because our 
rtl
    optimizers cannot handle unspecs.  Instead, use subregs to access each 
vector
    register component of the opaque mode variable, which our optimizers know 
how
    to handle and optimize.
    
    gcc/
            * config/rs6000/mma.md (unspec): Delete UNSPEC_MMA_EXTRACT.
            (vsx_disassemble_pair): Expand into a vector register sized subreg.
            (mma_disassemble_acc): Likewise.
            (*vsx_disassemble_pair): Delete.
            (*mma_disassemble_acc): Likewise.

Diff:
---
 gcc/config/rs6000/mma.md | 51 ++++--------------------------------------------
 1 file changed, 4 insertions(+), 47 deletions(-)

diff --git a/gcc/config/rs6000/mma.md b/gcc/config/rs6000/mma.md
index 6acd37d4e87f..bc6631436274 100644
--- a/gcc/config/rs6000/mma.md
+++ b/gcc/config/rs6000/mma.md
@@ -30,7 +30,6 @@
 
 (define_c_enum "unspec"
   [UNSPEC_VSX_ASSEMBLE
-   UNSPEC_MMA_EXTRACT
    UNSPEC_MMA_PMXVBF16GER2
    UNSPEC_MMA_PMXVBF16GER2NN
    UNSPEC_MMA_PMXVBF16GER2NP
@@ -434,29 +433,8 @@
    (match_operand 2 "const_0_to_1_operand")]
   "TARGET_MMA"
 {
-  rtx src;
-  int regoff = INTVAL (operands[2]);
-  src = gen_rtx_UNSPEC (V16QImode,
-                       gen_rtvec (2, operands[1], GEN_INT (regoff)),
-                       UNSPEC_MMA_EXTRACT);
-  emit_move_insn (operands[0], src);
-  DONE;
-})
-
-(define_insn_and_split "*vsx_disassemble_pair"
-  [(set (match_operand:V16QI 0 "mma_disassemble_output_operand" "=mwa")
-       (unspec:V16QI [(match_operand:OO 1 "vsx_register_operand" "wa")
-                     (match_operand 2 "const_0_to_1_operand")]
-                     UNSPEC_MMA_EXTRACT))]
-  "TARGET_MMA
-   && vsx_register_operand (operands[1], OOmode)"
-  "#"
-  "&& reload_completed"
-  [(const_int 0)]
-{
-  int reg = REGNO (operands[1]);
-  int regoff = INTVAL (operands[2]);
-  rtx src = gen_rtx_REG (V16QImode, reg + regoff);
+  int regoff = INTVAL (operands[2]) * 16;
+  rtx src = simplify_gen_subreg (V16QImode, operands[1], OOmode, regoff);
   emit_move_insn (operands[0], src);
   DONE;
 })
@@ -508,29 +486,8 @@
    (match_operand 2 "const_0_to_3_operand")]
   "TARGET_MMA"
 {
-  rtx src;
-  int regoff = INTVAL (operands[2]);
-  src = gen_rtx_UNSPEC (V16QImode,
-                       gen_rtvec (2, operands[1], GEN_INT (regoff)),
-                       UNSPEC_MMA_EXTRACT);
-  emit_move_insn (operands[0], src);
-  DONE;
-})
-
-(define_insn_and_split "*mma_disassemble_acc"
-  [(set (match_operand:V16QI 0 "mma_disassemble_output_operand" "=mwa")
-       (unspec:V16QI [(match_operand:XO 1 "fpr_reg_operand" "d")
-                     (match_operand 2 "const_0_to_3_operand")]
-                     UNSPEC_MMA_EXTRACT))]
-  "TARGET_MMA
-   && fpr_reg_operand (operands[1], XOmode)"
-  "#"
-  "&& reload_completed"
-  [(const_int 0)]
-{
-  int reg = REGNO (operands[1]);
-  int regoff = INTVAL (operands[2]);
-  rtx src = gen_rtx_REG (V16QImode, reg + regoff);
+  int regoff = INTVAL (operands[2]) * 16;
+  rtx src = simplify_gen_subreg (V16QImode, operands[1], XOmode, regoff);
   emit_move_insn (operands[0], src);
   DONE;
 })

Reply via email to