[llvm] ebe8353 - [RISCV][NFC] Add VPatUnaryVL_V class (#196229)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 7 00:25:18 PDT 2026


Author: Pengcheng Wang
Date: 2026-05-07T15:25:13+08:00
New Revision: ebe8353d63a017b2309203025a2b0e3a5259f22a

URL: https://github.com/llvm/llvm-project/commit/ebe8353d63a017b2309203025a2b0e3a5259f22a
DIFF: https://github.com/llvm/llvm-project/commit/ebe8353d63a017b2309203025a2b0e3a5259f22a.diff

LOG: [RISCV][NFC] Add VPatUnaryVL_V class (#196229)

So that we can reuse it.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
index 15709c2bf7178..0264295c247fe 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
@@ -758,6 +758,30 @@ def sew16simm5 : ComplexPattern<XLenVT, 1, "selectRVVSimm5<16>", []>;
 def sew32simm5 : ComplexPattern<XLenVT, 1, "selectRVVSimm5<32>", []>;
 def sew64simm5 : ComplexPattern<XLenVT, 1, "selectRVVSimm5<64>", []>;
 
+class VPatUnaryVL_V<SDPatternOperator vop,
+                    string instruction_name,
+                    string suffix,
+                    ValueType result_type,
+                    ValueType op1_type,
+                    ValueType mask_type,
+                    int log2sew,
+                    LMULInfo vlmul,
+                    VReg result_reg_class,
+                    VReg op1_reg_class,
+                    bit isSEWAware = 0>
+    : Pat<(result_type (vop
+                       (op1_type op1_reg_class:$rs2),
+                       (result_type result_reg_class:$passthru),
+                       (mask_type VMV0:$vm),
+                       VLOpFrag)),
+      (!cast<Instruction>(
+                   !if(isSEWAware,
+                       instruction_name#"_"#suffix#"_"#vlmul.MX#"_E"#!shl(1, log2sew)#"_MASK",
+                       instruction_name#"_"#suffix#"_"#vlmul.MX#"_MASK"))
+                   result_reg_class:$passthru,
+                   op1_reg_class:$rs2,
+                   (mask_type VMV0:$vm), GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
+
 class VPatBinaryVL_V<SDPatternOperator vop,
                      string instruction_name,
                      string suffix,
@@ -1990,19 +2014,10 @@ multiclass VPatUnaryVL_V<SDPatternOperator op, string instruction_name,
                          Predicate predicate = HasStdExtZvbb> {
   foreach vti = AllIntegerVectors in {
     let Predicates = !listconcat([predicate],
-                                 GetVTypePredicates<vti>.Predicates) in {
-      def : Pat<(vti.Vector (op (vti.Vector vti.RegClass:$rs1),
-                                (vti.Vector vti.RegClass:$passthru),
-                                (vti.Mask VMV0:$vm),
-                                VLOpFrag)),
-                (!cast<Instruction>(instruction_name#"_V_"#vti.LMul.MX#"_MASK")
-                   vti.RegClass:$passthru,
-                   vti.RegClass:$rs1,
-                   (vti.Mask VMV0:$vm),
-                   GPR:$vl,
-                   vti.Log2SEW,
-                   TAIL_AGNOSTIC)>;
-    }
+                                 GetVTypePredicates<vti>.Predicates) in
+    def : VPatUnaryVL_V<op, instruction_name, "V",
+                        vti.Vector, vti.Vector, vti.Mask, vti.Log2SEW,
+                        vti.LMul, vti.RegClass, vti.RegClass>;
   }
 }
 


        


More information about the llvm-commits mailing list