[llvm] [RISCV] Add @earlyclobber to SiFive custom matrix multiply instruction. (PR #124060)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 20:20:12 PST 2025


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/124060

All of these have a constraint that vd and vs1 cannot overlap. Some of them have an additional widening constraint for vs2.

We should use earlyclobber to protect this.

This is unlikely to be an issue in practice due to the instrinsic being ternary so vd is also a source. The intrinsic has a different type for this source than the other sources. You would have to do something crazy to get the register allocator to overlap the registers.

>From 13974a9c6993cb6d6a09333f74e12bc6c98c5b02 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 22 Jan 2025 20:15:02 -0800
Subject: [PATCH] [RISCV] Add @earlyclobber to SiFive custom matrix multiply
 instruction.

All of these have a constraint that vd and vs1 cannot overlap.
Some of them have an additional widening constraint for vs2.

We should use earlyclobber to protect this.

This is unlikely to be an issue in practice due to the instrinsic
being ternary so vd is also a source. The intrinsic has a different
type for this source than the other sources. You would have to do
something crazy to get the register allocator to overlap the registers.
---
 llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td
index 20adda91f6bde1..b55c6c55689361 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td
@@ -374,28 +374,28 @@ multiclass VPseudoVC_XVW<LMULInfo m, DAGOperand RS1Class,
   }
 }
 
-multiclass VPseudoSiFiveVMACC<string mx, VReg vd_type, VReg vs2_type,
-                              string Constraint = ""> {
+multiclass VPseudoSiFiveVMACC<string mx, VReg vd_type, VReg vs2_type> {
   def "Pseudo" # NAME # "_" # mx
-      : VPseudoTernaryNoMaskWithPolicy<vd_type, V_M1.vrclass, vs2_type, Constraint>;
+      : VPseudoTernaryNoMaskWithPolicy<vd_type, V_M1.vrclass, vs2_type,
+                                       "@earlyclobber $rd">;
 }
 
-multiclass VPseudoSiFiveVQMACCDOD<string Constraint = ""> {
+multiclass VPseudoSiFiveVQMACCDOD {
   foreach m = MxListVF8 in
     let VLMul = m.value in
-    defm NAME : VPseudoSiFiveVMACC<m.MX, m.vrclass, m.vrclass, Constraint>;
+    defm NAME : VPseudoSiFiveVMACC<m.MX, m.vrclass, m.vrclass>;
 }
 
-multiclass VPseudoSiFiveVQMACCQOQ<string Constraint = ""> {
+multiclass VPseudoSiFiveVQMACCQOQ {
   foreach m = [V_MF2, V_M1, V_M2, V_M4] in
     let VLMul = m.value in
-    defm NAME : VPseudoSiFiveVMACC<m.MX, m.wvrclass, m.vrclass, Constraint>;
+    defm NAME : VPseudoSiFiveVMACC<m.MX, m.wvrclass, m.vrclass>;
 }
 
-multiclass VPseudoSiFiveVFWMACC<string Constraint = ""> {
+multiclass VPseudoSiFiveVFWMACC {
   foreach m = MxListVF2 in
     let VLMul = m.value in
-    defm NAME : VPseudoSiFiveVMACC<m.MX, m.wvrclass, m.vrclass, Constraint>;
+    defm NAME : VPseudoSiFiveVMACC<m.MX, m.wvrclass, m.vrclass>;
 }
 
 multiclass VPseudoSiFiveVFNRCLIP<string Constraint = "@earlyclobber $rd"> {



More information about the llvm-commits mailing list