[llvm] 58d4f10 - [RISCV] Refactor predicates for rvv VL patterns.

Jianjian GUAN via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 23:13:10 PDT 2023


Author: Jianjian GUAN
Date: 2023-05-19T14:13:02+08:00
New Revision: 58d4f10733ce924dfe731156a570e7e7dcf98a57

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

LOG: [RISCV] Refactor predicates for rvv VL patterns.

This patch is similar to https://reviews.llvm.org/D150550 and https://reviews.llvm.org/D150754, it adds accurate predicates for VL patterns depending on vector type.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D150850

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 2e6a7d59240d..c34ebf6bc8e3 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
@@ -655,30 +655,35 @@ multiclass VPatBinaryVL_XI_E<SDPatternOperator vop,
                      (mask_type V0), GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
 }
 
-multiclass VPatBinaryVL_VV_VX<SDPatternOperator vop, string instruction_name> {
-  foreach vti = AllIntegerVectors in {
-    defm : VPatBinaryVL_V<vop, instruction_name, "VV",
-                           vti.Vector, vti.Vector, vti.Vector, vti.Mask,
-                           vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
-                           vti.RegClass>;
-    defm : VPatBinaryVL_XI<vop, instruction_name, "VX",
-                           vti.Vector, vti.Vector, vti.Vector, vti.Mask,
-                           vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
-                           SplatPat, GPR>;
+multiclass VPatBinaryVL_VV_VX<SDPatternOperator vop, string instruction_name,
+                              list<VTypeInfo> vtilist = AllIntegerVectors> {
+  foreach vti = vtilist in {
+    let Predicates = GetVTypePredicates<vti>.Predicates in {
+      defm : VPatBinaryVL_V<vop, instruction_name, "VV",
+                             vti.Vector, vti.Vector, vti.Vector, vti.Mask,
+                             vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
+                             vti.RegClass>;
+      defm : VPatBinaryVL_XI<vop, instruction_name, "VX",
+                             vti.Vector, vti.Vector, vti.Vector, vti.Mask,
+                             vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
+                             SplatPat, GPR>;
+    }
   }
 }
 
 multiclass VPatBinaryVL_VV_VX_E<SDPatternOperator vop,
                                 string instruction_name> {
   foreach vti = AllIntegerVectors in {
-    defm : VPatBinaryVL_V_E<vop, instruction_name, "VV",
-                           vti.Vector, vti.Vector, vti.Vector, vti.Mask,
-                           vti.Log2SEW, vti.LMul, vti.SEW,
-                           vti.RegClass, vti.RegClass, vti.RegClass>;
-    defm : VPatBinaryVL_XI_E<vop, instruction_name, "VX",
-                           vti.Vector, vti.Vector, vti.Vector, vti.Mask,
-                           vti.Log2SEW, vti.LMul, vti.SEW,
-                           vti.RegClass, vti.RegClass, SplatPat, GPR>;
+    let Predicates = GetVTypePredicates<vti>.Predicates in {
+      defm : VPatBinaryVL_V_E<vop, instruction_name, "VV",
+                             vti.Vector, vti.Vector, vti.Vector, vti.Mask,
+                             vti.Log2SEW, vti.LMul, vti.SEW,
+                             vti.RegClass, vti.RegClass, vti.RegClass>;
+      defm : VPatBinaryVL_XI_E<vop, instruction_name, "VX",
+                             vti.Vector, vti.Vector, vti.Vector, vti.Mask,
+                             vti.Log2SEW, vti.LMul, vti.SEW,
+                             vti.RegClass, vti.RegClass, SplatPat, GPR>;
+    }
   }
 }
 
@@ -686,6 +691,7 @@ multiclass VPatBinaryVL_VV_VX_VI<SDPatternOperator vop, string instruction_name,
                                  Operand ImmType = simm5>
     : VPatBinaryVL_VV_VX<vop, instruction_name> {
   foreach vti = AllIntegerVectors in {
+    let Predicates = GetVTypePredicates<vti>.Predicates in
     defm : VPatBinaryVL_XI<vop, instruction_name, "VI",
                            vti.Vector, vti.Vector, vti.Vector, vti.Mask,
                            vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
@@ -698,14 +704,17 @@ multiclass VPatBinaryWVL_VV_VX<SDPatternOperator vop, string instruction_name> {
   foreach VtiToWti = AllWidenableIntVectors in {
     defvar vti = VtiToWti.Vti;
     defvar wti = VtiToWti.Wti;
-    defm : VPatBinaryVL_V<vop, instruction_name, "VV",
-                          wti.Vector, vti.Vector, vti.Vector, vti.Mask,
-                          vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
-                          vti.RegClass>;
-    defm : VPatBinaryVL_XI<vop, instruction_name, "VX",
-                           wti.Vector, vti.Vector, vti.Vector, vti.Mask,
-                           vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
-                           SplatPat, GPR>;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in {
+      defm : VPatBinaryVL_V<vop, instruction_name, "VV",
+                            wti.Vector, vti.Vector, vti.Vector, vti.Mask,
+                            vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
+                            vti.RegClass>;
+      defm : VPatBinaryVL_XI<vop, instruction_name, "VX",
+                             wti.Vector, vti.Vector, vti.Vector, vti.Mask,
+                             vti.Log2SEW, vti.LMul, wti.RegClass, vti.RegClass,
+                             SplatPat, GPR>;
+    }
   }
 }
 multiclass VPatBinaryWVL_VV_VX_WV_WX<SDPatternOperator vop, SDNode vop_w,
@@ -714,17 +723,20 @@ multiclass VPatBinaryWVL_VV_VX_WV_WX<SDPatternOperator vop, SDNode vop_w,
   foreach VtiToWti = AllWidenableIntVectors in {
     defvar vti = VtiToWti.Vti;
     defvar wti = VtiToWti.Wti;
-    defm : VPatTiedBinaryNoMaskVL_V<vop_w, instruction_name, "WV",
-                                    wti.Vector, vti.Vector, vti.Log2SEW,
-                                    vti.LMul, wti.RegClass, vti.RegClass>;
-    defm : VPatBinaryVL_V<vop_w, instruction_name, "WV",
-                          wti.Vector, wti.Vector, vti.Vector, vti.Mask,
-                          vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
-                          vti.RegClass>;
-    defm : VPatBinaryVL_XI<vop_w, instruction_name, "WX",
-                           wti.Vector, wti.Vector, vti.Vector, vti.Mask,
-                           vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
-                           SplatPat, GPR>;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in {
+      defm : VPatTiedBinaryNoMaskVL_V<vop_w, instruction_name, "WV",
+                                      wti.Vector, vti.Vector, vti.Log2SEW,
+                                      vti.LMul, wti.RegClass, vti.RegClass>;
+      defm : VPatBinaryVL_V<vop_w, instruction_name, "WV",
+                            wti.Vector, wti.Vector, vti.Vector, vti.Mask,
+                            vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
+                            vti.RegClass>;
+      defm : VPatBinaryVL_XI<vop_w, instruction_name, "WX",
+                             wti.Vector, wti.Vector, vti.Vector, vti.Mask,
+                             vti.Log2SEW, vti.LMul, wti.RegClass, wti.RegClass,
+                             SplatPat, GPR>;
+    }
   }
 }
 
@@ -732,19 +744,22 @@ multiclass VPatBinaryNVL_WV_WX_WI<SDPatternOperator vop, string instruction_name
   foreach VtiToWti = AllWidenableIntVectors in {
     defvar vti = VtiToWti.Vti;
     defvar wti = VtiToWti.Wti;
-    defm : VPatBinaryVL_V<vop, instruction_name, "WV",
-                          vti.Vector, wti.Vector, vti.Vector, vti.Mask,
-                          vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
-                          vti.RegClass>;
-    defm : VPatBinaryVL_XI<vop, instruction_name, "WX",
-                           vti.Vector, wti.Vector, vti.Vector, vti.Mask,
-                           vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
-                           SplatPat, GPR>;
-    defm : VPatBinaryVL_XI<vop, instruction_name, "WI",
-                           vti.Vector, wti.Vector, vti.Vector, vti.Mask,
-                           vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
-                           !cast<ComplexPattern>(SplatPat#_#uimm5),
-                           uimm5>;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in {
+      defm : VPatBinaryVL_V<vop, instruction_name, "WV",
+                            vti.Vector, wti.Vector, vti.Vector, vti.Mask,
+                            vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
+                            vti.RegClass>;
+      defm : VPatBinaryVL_XI<vop, instruction_name, "WX",
+                             vti.Vector, wti.Vector, vti.Vector, vti.Mask,
+                             vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
+                             SplatPat, GPR>;
+      defm : VPatBinaryVL_XI<vop, instruction_name, "WI",
+                             vti.Vector, wti.Vector, vti.Vector, vti.Mask,
+                             vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
+                             !cast<ComplexPattern>(SplatPat#_#uimm5),
+                             uimm5>;
+    }
   }
 }
 
@@ -795,33 +810,38 @@ multiclass VPatBinaryVL_VF_E<SDPatternOperator vop,
 
 multiclass VPatBinaryFPVL_VV_VF<SDPatternOperator vop, string instruction_name> {
   foreach vti = AllFloatVectors in {
-    defm : VPatBinaryVL_V<vop, instruction_name, "VV",
-                          vti.Vector, vti.Vector, vti.Vector, vti.Mask,
-                          vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
-                          vti.RegClass>;
-    defm : VPatBinaryVL_VF<vop, instruction_name#"_V"#vti.ScalarSuffix,
-                           vti.Vector, vti.Vector, vti.Mask, vti.Log2SEW,
-                           vti.LMul, vti.RegClass, vti.RegClass,
-                           vti.ScalarRegClass>;
+    let Predicates = GetVTypePredicates<vti>.Predicates in {
+      defm : VPatBinaryVL_V<vop, instruction_name, "VV",
+                            vti.Vector, vti.Vector, vti.Vector, vti.Mask,
+                            vti.Log2SEW, vti.LMul, vti.RegClass, vti.RegClass,
+                            vti.RegClass>;
+      defm : VPatBinaryVL_VF<vop, instruction_name#"_V"#vti.ScalarSuffix,
+                             vti.Vector, vti.Vector, vti.Mask, vti.Log2SEW,
+                             vti.LMul, vti.RegClass, vti.RegClass,
+                             vti.ScalarRegClass>;
+    }
   }
 }
 
 multiclass VPatBinaryFPVL_VV_VF_E<SDPatternOperator vop,
                                   string instruction_name> {
   foreach vti = AllFloatVectors in {
-    defm : VPatBinaryVL_V_E<vop, instruction_name, "VV",
-                          vti.Vector, vti.Vector, vti.Vector, vti.Mask,
-                          vti.Log2SEW, vti.LMul, vti.SEW,
-                          vti.RegClass, vti.RegClass, vti.RegClass>;
-    defm : VPatBinaryVL_VF_E<vop, instruction_name#"_V"#vti.ScalarSuffix,
-                           vti.Vector, vti.Vector, vti.Mask, vti.Log2SEW,
-                           vti.LMul, vti.SEW, vti.RegClass, vti.RegClass,
-                           vti.ScalarRegClass>;
+    let Predicates = GetVTypePredicates<vti>.Predicates in {
+      defm : VPatBinaryVL_V_E<vop, instruction_name, "VV",
+                            vti.Vector, vti.Vector, vti.Vector, vti.Mask,
+                            vti.Log2SEW, vti.LMul, vti.SEW,
+                            vti.RegClass, vti.RegClass, vti.RegClass>;
+      defm : VPatBinaryVL_VF_E<vop, instruction_name#"_V"#vti.ScalarSuffix,
+                             vti.Vector, vti.Vector, vti.Mask, vti.Log2SEW,
+                             vti.LMul, vti.SEW, vti.RegClass, vti.RegClass,
+                             vti.ScalarRegClass>;
+    }
   }
 }
 
 multiclass VPatBinaryFPVL_R_VF<SDPatternOperator vop, string instruction_name> {
   foreach fvti = AllFloatVectors in {
+    let Predicates = GetVTypePredicates<fvti>.Predicates in
     def : Pat<(fvti.Vector (vop (SplatFPOp fvti.ScalarRegClass:$rs2),
                                 fvti.RegClass:$rs1,
                                 (fvti.Vector fvti.RegClass:$merge),
@@ -837,6 +857,7 @@ multiclass VPatBinaryFPVL_R_VF<SDPatternOperator vop, string instruction_name> {
 multiclass VPatBinaryFPVL_R_VF_E<SDPatternOperator vop,
                                  string instruction_name> {
   foreach fvti = AllFloatVectors in {
+    let Predicates = GetVTypePredicates<fvti>.Predicates in
     def : Pat<(fvti.Vector (vop (SplatFPOp fvti.ScalarRegClass:$rs2),
                                 fvti.RegClass:$rs1,
                                 (fvti.Vector fvti.RegClass:$merge),
@@ -948,36 +969,38 @@ multiclass VPatFPSetCCVL_VV_VF_FV<SDPatternOperator vop, CondCode cc,
                                   string inst_name,
                                   string swapped_op_inst_name> {
   foreach fvti = AllFloatVectors in {
-    def : Pat<(fvti.Mask (vop (fvti.Vector fvti.RegClass:$rs1),
-                               fvti.RegClass:$rs2,
-                               cc,
-                               VR:$merge,
-                               (fvti.Mask V0),
-                               VLOpFrag)),
-              (!cast<Instruction>(inst_name#"_VV_"#fvti.LMul.MX#"_MASK")
-                  VR:$merge, fvti.RegClass:$rs1,
-                  fvti.RegClass:$rs2, (fvti.Mask V0),
-                  GPR:$vl, fvti.Log2SEW)>;
-    def : Pat<(fvti.Mask (vop (fvti.Vector fvti.RegClass:$rs1),
-                              (SplatFPOp fvti.ScalarRegClass:$rs2),
-                              cc,
-                              VR:$merge,
-                              (fvti.Mask V0),
-                              VLOpFrag)),
-              (!cast<Instruction>(inst_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_MASK")
-                  VR:$merge, fvti.RegClass:$rs1,
-                  fvti.ScalarRegClass:$rs2, (fvti.Mask V0),
-                  GPR:$vl, fvti.Log2SEW)>;
-    def : Pat<(fvti.Mask (vop (SplatFPOp fvti.ScalarRegClass:$rs2),
-                              (fvti.Vector fvti.RegClass:$rs1),
-                              cc,
-                              VR:$merge,
-                              (fvti.Mask V0),
-                              VLOpFrag)),
-              (!cast<Instruction>(swapped_op_inst_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_MASK")
-                  VR:$merge, fvti.RegClass:$rs1,
-                  fvti.ScalarRegClass:$rs2, (fvti.Mask V0),
-                  GPR:$vl, fvti.Log2SEW)>;
+    let Predicates = GetVTypePredicates<fvti>.Predicates in {
+      def : Pat<(fvti.Mask (vop (fvti.Vector fvti.RegClass:$rs1),
+                                 fvti.RegClass:$rs2,
+                                 cc,
+                                 VR:$merge,
+                                 (fvti.Mask V0),
+                                 VLOpFrag)),
+                (!cast<Instruction>(inst_name#"_VV_"#fvti.LMul.MX#"_MASK")
+                    VR:$merge, fvti.RegClass:$rs1,
+                    fvti.RegClass:$rs2, (fvti.Mask V0),
+                    GPR:$vl, fvti.Log2SEW)>;
+      def : Pat<(fvti.Mask (vop (fvti.Vector fvti.RegClass:$rs1),
+                                (SplatFPOp fvti.ScalarRegClass:$rs2),
+                                cc,
+                                VR:$merge,
+                                (fvti.Mask V0),
+                                VLOpFrag)),
+                (!cast<Instruction>(inst_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_MASK")
+                    VR:$merge, fvti.RegClass:$rs1,
+                    fvti.ScalarRegClass:$rs2, (fvti.Mask V0),
+                    GPR:$vl, fvti.Log2SEW)>;
+      def : Pat<(fvti.Mask (vop (SplatFPOp fvti.ScalarRegClass:$rs2),
+                                (fvti.Vector fvti.RegClass:$rs1),
+                                cc,
+                                VR:$merge,
+                                (fvti.Mask V0),
+                                VLOpFrag)),
+                (!cast<Instruction>(swapped_op_inst_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX#"_MASK")
+                    VR:$merge, fvti.RegClass:$rs1,
+                    fvti.ScalarRegClass:$rs2, (fvti.Mask V0),
+                    GPR:$vl, fvti.Log2SEW)>;
+    }
   }
 }
 
@@ -986,6 +1009,8 @@ multiclass VPatExtendVL_V<SDNode vop, string inst_name, string suffix,
   foreach vtiTofti = fraction_list in {
     defvar vti = vtiTofti.Vti;
     defvar fti = vtiTofti.Fti;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<fti>.Predicates) in
     def : Pat<(vti.Vector (vop (fti.Vector fti.RegClass:$rs2),
                                (fti.Mask V0), VLOpFrag)),
               (!cast<Instruction>(inst_name#"_"#suffix#"_"#vti.LMul.MX#"_MASK")
@@ -1000,6 +1025,8 @@ multiclass VPatExtendVL_V<SDNode vop, string inst_name, string suffix,
 multiclass VPatConvertFP2IVL_V<SDPatternOperator vop, string instruction_name> {
   foreach fvti = AllFloatVectors in {
     defvar ivti = GetIntVTypeInfo<fvti>.Vti;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<ivti>.Predicates) in
     def : Pat<(ivti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
                                 (fvti.Mask V0),
                                 VLOpFrag)),
@@ -1012,6 +1039,8 @@ multiclass VPatConvertFP2IVL_V<SDPatternOperator vop, string instruction_name> {
 multiclass VPatConvertFP2I_RM_VL_V<SDPatternOperator vop, string instruction_name> {
   foreach fvti = AllFloatVectors in {
     defvar ivti = GetIntVTypeInfo<fvti>.Vti;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<ivti>.Predicates) in
     def : Pat<(ivti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
                                 (fvti.Mask V0), (XLenVT timm:$frm),
                                 VLOpFrag)),
@@ -1025,6 +1054,8 @@ multiclass VPatConvertFP2I_RM_VL_V<SDPatternOperator vop, string instruction_nam
 multiclass VPatConvertI2FPVL_V<SDPatternOperator vop, string instruction_name> {
   foreach fvti = AllFloatVectors in {
     defvar ivti = GetIntVTypeInfo<fvti>.Vti;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<ivti>.Predicates) in
     def : Pat<(fvti.Vector (vop (ivti.Vector ivti.RegClass:$rs1),
                                 (ivti.Mask V0),
                                 VLOpFrag)),
@@ -1037,6 +1068,8 @@ multiclass VPatConvertI2FPVL_V<SDPatternOperator vop, string instruction_name> {
 multiclass VPatConvertI2FP_RM_VL_V<SDNode vop, string instruction_name> {
   foreach fvti = AllFloatVectors in {
     defvar ivti = GetIntVTypeInfo<fvti>.Vti;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<ivti>.Predicates) in
     def : Pat<(fvti.Vector (vop (ivti.Vector ivti.RegClass:$rs1),
                                 (ivti.Mask V0), (XLenVT timm:$frm),
                                 VLOpFrag)),
@@ -1052,6 +1085,8 @@ multiclass VPatWConvertFP2IVL_V<SDPatternOperator vop, string instruction_name>
   foreach fvtiToFWti = AllWidenableFloatVectors in {
     defvar fvti = fvtiToFWti.Vti;
     defvar iwti = GetIntVTypeInfo<fvtiToFWti.Wti>.Vti;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<iwti>.Predicates) in
     def : Pat<(iwti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
                                 (fvti.Mask V0),
                                 VLOpFrag)),
@@ -1065,6 +1100,8 @@ multiclass VPatWConvertFP2I_RM_VL_V<SDNode vop, string instruction_name> {
   foreach fvtiToFWti = AllWidenableFloatVectors in {
     defvar fvti = fvtiToFWti.Vti;
     defvar iwti = GetIntVTypeInfo<fvtiToFWti.Wti>.Vti;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<iwti>.Predicates) in
     def : Pat<(iwti.Vector (vop (fvti.Vector fvti.RegClass:$rs1),
                                 (fvti.Mask V0), (XLenVT timm:$frm),
                                 VLOpFrag)),
@@ -1079,6 +1116,8 @@ multiclass VPatWConvertI2FPVL_V<SDPatternOperator vop,
   foreach vtiToWti = AllWidenableIntToFloatVectors in {
     defvar ivti = vtiToWti.Vti;
     defvar fwti = vtiToWti.Wti;
+    let Predicates = !listconcat(GetVTypePredicates<ivti>.Predicates,
+                                 GetVTypePredicates<fwti>.Predicates) in
     def : Pat<(fwti.Vector (vop (ivti.Vector ivti.RegClass:$rs1),
                                 (ivti.Mask V0),
                                 VLOpFrag)),
@@ -1092,6 +1131,8 @@ multiclass VPatWConvertI2FP_RM_VL_V<SDNode vop, string instruction_name> {
   foreach vtiToWti = AllWidenableIntToFloatVectors in {
     defvar ivti = vtiToWti.Vti;
     defvar fwti = vtiToWti.Wti;
+    let Predicates = !listconcat(GetVTypePredicates<ivti>.Predicates,
+                                 GetVTypePredicates<fwti>.Predicates) in
     def : Pat<(fwti.Vector (vop (ivti.Vector ivti.RegClass:$rs1),
                                 (ivti.Mask V0), (XLenVT timm:$frm),
                                 VLOpFrag)),
@@ -1110,6 +1151,8 @@ multiclass VPatNConvertFP2IVL_W<SDPatternOperator vop,
   foreach vtiToWti = AllWidenableIntToFloatVectors in {
     defvar vti = vtiToWti.Vti;
     defvar fwti = vtiToWti.Wti;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<fwti>.Predicates) in
     def : Pat<(vti.Vector (vop (fwti.Vector fwti.RegClass:$rs1),
                                (fwti.Mask V0),
                                VLOpFrag)),
@@ -1123,6 +1166,8 @@ multiclass VPatNConvertFP2I_RM_VL_W<SDNode vop, string instruction_name> {
   foreach vtiToWti = AllWidenableIntToFloatVectors in {
     defvar vti = vtiToWti.Vti;
     defvar fwti = vtiToWti.Wti;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<fwti>.Predicates) in
     def : Pat<(vti.Vector (vop (fwti.Vector fwti.RegClass:$rs1),
                                (fwti.Mask V0), (XLenVT timm:$frm),
                                VLOpFrag)),
@@ -1137,6 +1182,8 @@ multiclass VPatNConvertI2FPVL_W<SDPatternOperator vop,
   foreach fvtiToFWti = AllWidenableFloatVectors in {
     defvar fvti = fvtiToFWti.Vti;
     defvar iwti = GetIntVTypeInfo<fvtiToFWti.Wti>.Vti;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<iwti>.Predicates) in
     def : Pat<(fvti.Vector (vop (iwti.Vector iwti.RegClass:$rs1),
                                 (iwti.Mask V0),
                                 VLOpFrag)),
@@ -1150,6 +1197,8 @@ multiclass VPatNConvertI2FP_RM_VL_W<SDNode vop, string instruction_name> {
   foreach fvtiToFWti = AllWidenableFloatVectors in {
     defvar fvti = fvtiToFWti.Vti;
     defvar iwti = GetIntVTypeInfo<fvtiToFWti.Wti>.Vti;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<iwti>.Predicates) in
     def : Pat<(fvti.Vector (vop (iwti.Vector iwti.RegClass:$rs1),
                                 (iwti.Mask V0),  (XLenVT timm:$frm),
                                 VLOpFrag)),
@@ -1162,25 +1211,27 @@ multiclass VPatNConvertI2FP_RM_VL_W<SDNode vop, string instruction_name> {
 multiclass VPatReductionVL<SDNode vop, string instruction_name, bit is_float> {
   foreach vti = !if(is_float, AllFloatVectors, AllIntegerVectors) in {
     defvar vti_m1 = !cast<VTypeInfo>(!if(is_float, "VF", "VI") # vti.SEW # "M1");
-    def: Pat<(vti_m1.Vector (vop (vti_m1.Vector VR:$merge),
-                                 (vti.Vector vti.RegClass:$rs1), VR:$rs2,
-                                 (vti.Mask true_mask), VLOpFrag,
-                                 (XLenVT timm:$policy))),
-        (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW)
-            (vti_m1.Vector VR:$merge),
-            (vti.Vector vti.RegClass:$rs1),
-            (vti_m1.Vector VR:$rs2),
-            GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
-
-    def: Pat<(vti_m1.Vector (vop (vti_m1.Vector VR:$merge),
-                                 (vti.Vector vti.RegClass:$rs1), VR:$rs2,
-                                 (vti.Mask V0), VLOpFrag,
-                                 (XLenVT timm:$policy))),
-        (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
-            (vti_m1.Vector VR:$merge),
-            (vti.Vector vti.RegClass:$rs1),
-            (vti_m1.Vector VR:$rs2),
-            (vti.Mask V0), GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
+    let Predicates = GetVTypePredicates<vti>.Predicates in {
+      def: Pat<(vti_m1.Vector (vop (vti_m1.Vector VR:$merge),
+                                   (vti.Vector vti.RegClass:$rs1), VR:$rs2,
+                                   (vti.Mask true_mask), VLOpFrag,
+                                   (XLenVT timm:$policy))),
+          (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW)
+              (vti_m1.Vector VR:$merge),
+              (vti.Vector vti.RegClass:$rs1),
+              (vti_m1.Vector VR:$rs2),
+              GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
+
+      def: Pat<(vti_m1.Vector (vop (vti_m1.Vector VR:$merge),
+                                   (vti.Vector vti.RegClass:$rs1), VR:$rs2,
+                                   (vti.Mask V0), VLOpFrag,
+                                   (XLenVT timm:$policy))),
+          (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
+              (vti_m1.Vector VR:$merge),
+              (vti.Vector vti.RegClass:$rs1),
+              (vti_m1.Vector VR:$rs2),
+              (vti.Mask V0), GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
+    }
   }
 }
 
@@ -1189,24 +1240,27 @@ multiclass VPatBinaryExtVL_WV_WX<SDNode op, PatFrags extop, string instruction_n
   foreach vtiToWti = AllWidenableIntVectors in {
     defvar vti = vtiToWti.Vti;
     defvar wti = vtiToWti.Wti;
-    def : Pat<
-      (vti.Vector
-        (riscv_trunc_vector_vl
-          (op (wti.Vector wti.RegClass:$rs2),
-              (wti.Vector (extop (vti.Vector vti.RegClass:$rs1)))),
-          (vti.Mask true_mask),
-          VLOpFrag)),
-      (!cast<Instruction>(instruction_name#"_WV_"#vti.LMul.MX)
-        wti.RegClass:$rs2, vti.RegClass:$rs1, GPR:$vl, vti.Log2SEW)>;
-    def : Pat<
-      (vti.Vector
-        (riscv_trunc_vector_vl
-          (op (wti.Vector wti.RegClass:$rs2),
-              (wti.Vector (extop (vti.Vector (SplatPat GPR:$rs1))))),
-          (vti.Mask true_mask),
-          VLOpFrag)),
-      (!cast<Instruction>(instruction_name#"_WX_"#vti.LMul.MX)
-        wti.RegClass:$rs2, GPR:$rs1, GPR:$vl, vti.Log2SEW)>;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in {
+      def : Pat<
+        (vti.Vector
+          (riscv_trunc_vector_vl
+            (op (wti.Vector wti.RegClass:$rs2),
+                (wti.Vector (extop (vti.Vector vti.RegClass:$rs1)))),
+            (vti.Mask true_mask),
+            VLOpFrag)),
+        (!cast<Instruction>(instruction_name#"_WV_"#vti.LMul.MX)
+          wti.RegClass:$rs2, vti.RegClass:$rs1, GPR:$vl, vti.Log2SEW)>;
+      def : Pat<
+        (vti.Vector
+          (riscv_trunc_vector_vl
+            (op (wti.Vector wti.RegClass:$rs2),
+                (wti.Vector (extop (vti.Vector (SplatPat GPR:$rs1))))),
+            (vti.Mask true_mask),
+            VLOpFrag)),
+        (!cast<Instruction>(instruction_name#"_WX_"#vti.LMul.MX)
+          wti.RegClass:$rs2, GPR:$rs1, GPR:$vl, vti.Log2SEW)>;
+    }
   }
 }
 
@@ -1216,6 +1270,8 @@ multiclass VPatBinaryVL_WV_WX_WI<SDNode op, string instruction_name>
   foreach vtiToWti = AllWidenableIntVectors in {
     defvar vti = vtiToWti.Vti;
     defvar wti = vtiToWti.Wti;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in
     def : Pat<
       (vti.Vector
         (riscv_trunc_vector_vl
@@ -1232,22 +1288,25 @@ multiclass VPatWidenReductionVL<SDNode vop, PatFrags extop, string instruction_n
     defvar vti = vtiToWti.Vti;
     defvar wti = vtiToWti.Wti;
     defvar wti_m1 = !cast<VTypeInfo>(!if(is_float, "VF", "VI") # wti.SEW # "M1");
-    def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
-                                 (wti.Vector (extop (vti.Vector vti.RegClass:$rs1))),
-                                 VR:$rs2, (vti.Mask true_mask), VLOpFrag,
-                                 (XLenVT timm:$policy))),
-             (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW)
-                (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
-                (wti_m1.Vector VR:$rs2), GPR:$vl, vti.Log2SEW,
-                (XLenVT timm:$policy))>;
-    def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
-                                 (wti.Vector (extop (vti.Vector vti.RegClass:$rs1))),
-                                 VR:$rs2, (vti.Mask V0), VLOpFrag,
-                                 (XLenVT timm:$policy))),
-             (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
-                (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
-                (wti_m1.Vector VR:$rs2), (vti.Mask V0), GPR:$vl, vti.Log2SEW,
-                (XLenVT timm:$policy))>;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in {
+      def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
+                                   (wti.Vector (extop (vti.Vector vti.RegClass:$rs1))),
+                                   VR:$rs2, (vti.Mask true_mask), VLOpFrag,
+                                   (XLenVT timm:$policy))),
+               (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW)
+                  (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
+                  (wti_m1.Vector VR:$rs2), GPR:$vl, vti.Log2SEW,
+                  (XLenVT timm:$policy))>;
+      def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
+                                   (wti.Vector (extop (vti.Vector vti.RegClass:$rs1))),
+                                   VR:$rs2, (vti.Mask V0), VLOpFrag,
+                                   (XLenVT timm:$policy))),
+               (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
+                  (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
+                  (wti_m1.Vector VR:$rs2), (vti.Mask V0), GPR:$vl, vti.Log2SEW,
+                  (XLenVT timm:$policy))>;
+    }
   }
 }
 
@@ -1256,22 +1315,25 @@ multiclass VPatWidenReductionVL_Ext_VL<SDNode vop, PatFrags extop, string instru
     defvar vti = vtiToWti.Vti;
     defvar wti = vtiToWti.Wti;
     defvar wti_m1 = !cast<VTypeInfo>(!if(is_float, "VF", "VI") # wti.SEW # "M1");
-    def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
-                                 (wti.Vector (extop (vti.Vector vti.RegClass:$rs1), (vti.Mask true_mask), VLOpFrag)),
-                                 VR:$rs2, (vti.Mask true_mask), VLOpFrag,
-                                 (XLenVT timm:$policy))),
-             (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW)
-                (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
-                (wti_m1.Vector VR:$rs2), GPR:$vl, vti.Log2SEW,
-                (XLenVT timm:$policy))>;
-    def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
-                                 (wti.Vector (extop (vti.Vector vti.RegClass:$rs1), (vti.Mask true_mask), VLOpFrag)),
-                                 VR:$rs2, (vti.Mask V0), VLOpFrag,
-                                 (XLenVT timm:$policy))),
-             (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
-                (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
-                (wti_m1.Vector VR:$rs2), (vti.Mask V0), GPR:$vl, vti.Log2SEW,
-                (XLenVT timm:$policy))>;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in {
+      def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
+                                   (wti.Vector (extop (vti.Vector vti.RegClass:$rs1), (vti.Mask true_mask), VLOpFrag)),
+                                   VR:$rs2, (vti.Mask true_mask), VLOpFrag,
+                                   (XLenVT timm:$policy))),
+               (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW)
+                  (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
+                  (wti_m1.Vector VR:$rs2), GPR:$vl, vti.Log2SEW,
+                  (XLenVT timm:$policy))>;
+      def: Pat<(wti_m1.Vector (vop (wti_m1.Vector VR:$merge),
+                                   (wti.Vector (extop (vti.Vector vti.RegClass:$rs1), (vti.Mask true_mask), VLOpFrag)),
+                                   VR:$rs2, (vti.Mask V0), VLOpFrag,
+                                   (XLenVT timm:$policy))),
+               (!cast<Instruction>(instruction_name#"_VS_"#vti.LMul.MX#"_E"#vti.SEW#"_MASK")
+                  (wti_m1.Vector VR:$merge), (vti.Vector vti.RegClass:$rs1),
+                  (wti_m1.Vector VR:$rs2), (vti.Mask V0), GPR:$vl, vti.Log2SEW,
+                  (XLenVT timm:$policy))>;
+    }
   }
 }
 
@@ -1279,22 +1341,25 @@ multiclass VPatWidenBinaryFPVL_VV_VF<SDNode op, PatFrags extop, string instructi
   foreach fvtiToFWti = AllWidenableFloatVectors in {
     defvar fvti = fvtiToFWti.Vti;
     defvar fwti = fvtiToFWti.Wti;
-    def : Pat<(fwti.Vector (op (fwti.Vector (extop (fvti.Vector fvti.RegClass:$rs2),
-                                                   (fvti.Mask true_mask), VLOpFrag)),
-                               (fwti.Vector (extop (fvti.Vector fvti.RegClass:$rs1),
-                                                   (fvti.Mask true_mask), VLOpFrag)),
-                               srcvalue, (fwti.Mask true_mask), VLOpFrag)),
-              (!cast<Instruction>(instruction_name#"_VV_"#fvti.LMul.MX)
-                 fvti.RegClass:$rs2, fvti.RegClass:$rs1,
-                 GPR:$vl, fvti.Log2SEW)>;
-    def : Pat<(fwti.Vector (op (fwti.Vector (extop (fvti.Vector fvti.RegClass:$rs2),
-                                                   (fvti.Mask true_mask), VLOpFrag)),
-                               (fwti.Vector (extop (fvti.Vector (SplatFPOp fvti.ScalarRegClass:$rs1)),
-                                                   (fvti.Mask true_mask), VLOpFrag)),
-                               srcvalue, (fwti.Mask true_mask), VLOpFrag)),
-              (!cast<Instruction>(instruction_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX)
-                 fvti.RegClass:$rs2, fvti.ScalarRegClass:$rs1,
-                 GPR:$vl, fvti.Log2SEW)>;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<fwti>.Predicates) in {
+      def : Pat<(fwti.Vector (op (fwti.Vector (extop (fvti.Vector fvti.RegClass:$rs2),
+                                                     (fvti.Mask true_mask), VLOpFrag)),
+                                 (fwti.Vector (extop (fvti.Vector fvti.RegClass:$rs1),
+                                                     (fvti.Mask true_mask), VLOpFrag)),
+                                 srcvalue, (fwti.Mask true_mask), VLOpFrag)),
+                (!cast<Instruction>(instruction_name#"_VV_"#fvti.LMul.MX)
+                   fvti.RegClass:$rs2, fvti.RegClass:$rs1,
+                   GPR:$vl, fvti.Log2SEW)>;
+      def : Pat<(fwti.Vector (op (fwti.Vector (extop (fvti.Vector fvti.RegClass:$rs2),
+                                                     (fvti.Mask true_mask), VLOpFrag)),
+                                 (fwti.Vector (extop (fvti.Vector (SplatFPOp fvti.ScalarRegClass:$rs1)),
+                                                     (fvti.Mask true_mask), VLOpFrag)),
+                                 srcvalue, (fwti.Mask true_mask), VLOpFrag)),
+                (!cast<Instruction>(instruction_name#"_V"#fvti.ScalarSuffix#"_"#fvti.LMul.MX)
+                   fvti.RegClass:$rs2, fvti.ScalarRegClass:$rs1,
+                   GPR:$vl, fvti.Log2SEW)>;
+    }
   }
 }
 
@@ -1302,20 +1367,23 @@ multiclass VPatWidenBinaryFPVL_WV_WF<SDNode op, PatFrags extop, string instructi
   foreach fvtiToFWti = AllWidenableFloatVectors in {
     defvar fvti = fvtiToFWti.Vti;
     defvar fwti = fvtiToFWti.Wti;
-    def : Pat<(fwti.Vector (op (fwti.Vector fwti.RegClass:$rs2),
-                               (fwti.Vector (extop (fvti.Vector fvti.RegClass:$rs1),
-                                                   (fvti.Mask true_mask), VLOpFrag)),
-                               srcvalue, (fwti.Mask true_mask), VLOpFrag)),
-              (!cast<Instruction>(instruction_name#"_WV_"#fvti.LMul.MX#"_TIED")
-                 fwti.RegClass:$rs2, fvti.RegClass:$rs1,
-                 GPR:$vl, fvti.Log2SEW, TAIL_AGNOSTIC)>;
-    def : Pat<(fwti.Vector (op (fwti.Vector fwti.RegClass:$rs2),
-                               (fwti.Vector (extop (fvti.Vector (SplatFPOp fvti.ScalarRegClass:$rs1)),
-                                                   (fvti.Mask true_mask), VLOpFrag)),
-                               srcvalue, (fwti.Mask true_mask), VLOpFrag)),
-              (!cast<Instruction>(instruction_name#"_W"#fvti.ScalarSuffix#"_"#fvti.LMul.MX)
-                 fwti.RegClass:$rs2, fvti.ScalarRegClass:$rs1,
-                 GPR:$vl, fvti.Log2SEW)>;
+    let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                                 GetVTypePredicates<fwti>.Predicates) in {
+      def : Pat<(fwti.Vector (op (fwti.Vector fwti.RegClass:$rs2),
+                                 (fwti.Vector (extop (fvti.Vector fvti.RegClass:$rs1),
+                                                     (fvti.Mask true_mask), VLOpFrag)),
+                                 srcvalue, (fwti.Mask true_mask), VLOpFrag)),
+                (!cast<Instruction>(instruction_name#"_WV_"#fvti.LMul.MX#"_TIED")
+                   fwti.RegClass:$rs2, fvti.RegClass:$rs1,
+                   GPR:$vl, fvti.Log2SEW, TAIL_AGNOSTIC)>;
+      def : Pat<(fwti.Vector (op (fwti.Vector fwti.RegClass:$rs2),
+                                 (fwti.Vector (extop (fvti.Vector (SplatFPOp fvti.ScalarRegClass:$rs1)),
+                                                     (fvti.Mask true_mask), VLOpFrag)),
+                                 srcvalue, (fwti.Mask true_mask), VLOpFrag)),
+                (!cast<Instruction>(instruction_name#"_W"#fvti.ScalarSuffix#"_"#fvti.LMul.MX)
+                   fwti.RegClass:$rs2, fvti.ScalarRegClass:$rs1,
+                   GPR:$vl, fvti.Log2SEW)>;
+    }
   }
 }
 
@@ -1327,6 +1395,8 @@ multiclass VPatNarrowShiftSplatExt_WX<SDNode op, PatFrags extop, string instruct
   foreach vtiToWti = AllWidenableIntVectors in {
     defvar vti = vtiToWti.Vti;
     defvar wti = vtiToWti.Wti;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in
     def : Pat<
       (vti.Vector
         (riscv_trunc_vector_vl
@@ -1343,88 +1413,92 @@ multiclass VPatNarrowShiftSplatExt_WX<SDNode op, PatFrags extop, string instruct
 multiclass VPatMultiplyAddVL_VV_VX<SDNode op, string instruction_name> {
   foreach vti = AllIntegerVectors in {
     defvar suffix = vti.LMul.MX;
-    // NOTE: We choose VMADD because it has the most commuting freedom. So it
-    // works best with how TwoAddressInstructionPass tries commuting.
-    def : Pat<(vti.Vector
-             (op vti.RegClass:$rs2,
-                 (riscv_mul_vl_oneuse vti.RegClass:$rs1,
-                                      vti.RegClass:$rd,
-                                      srcvalue, (vti.Mask true_mask), VLOpFrag),
-                           srcvalue, (vti.Mask true_mask), VLOpFrag)),
-            (!cast<Instruction>(instruction_name#"_VV_"# suffix)
-                 vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
-                 GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
-    // The choice of VMADD here is arbitrary, vmadd.vx and vmacc.vx are equally
-    // commutable.
-    def : Pat<(vti.Vector
-             (op vti.RegClass:$rs2,
-                 (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1),
-                                       vti.RegClass:$rd,
-                                       srcvalue, (vti.Mask true_mask), VLOpFrag),
-                           srcvalue, (vti.Mask true_mask), VLOpFrag)),
-            (!cast<Instruction>(instruction_name#"_VX_" # suffix)
-                 vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
-                 GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    let Predicates = GetVTypePredicates<vti>.Predicates in {
+      // NOTE: We choose VMADD because it has the most commuting freedom. So it
+      // works best with how TwoAddressInstructionPass tries commuting.
+      def : Pat<(vti.Vector
+               (op vti.RegClass:$rs2,
+                   (riscv_mul_vl_oneuse vti.RegClass:$rs1,
+                                        vti.RegClass:$rd,
+                                        srcvalue, (vti.Mask true_mask), VLOpFrag),
+                             srcvalue, (vti.Mask true_mask), VLOpFrag)),
+              (!cast<Instruction>(instruction_name#"_VV_"# suffix)
+                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
+                   GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+      // The choice of VMADD here is arbitrary, vmadd.vx and vmacc.vx are equally
+      // commutable.
+      def : Pat<(vti.Vector
+               (op vti.RegClass:$rs2,
+                   (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1),
+                                         vti.RegClass:$rd,
+                                         srcvalue, (vti.Mask true_mask), VLOpFrag),
+                             srcvalue, (vti.Mask true_mask), VLOpFrag)),
+              (!cast<Instruction>(instruction_name#"_VX_" # suffix)
+                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
+                   GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    }
   }
 }
 
 multiclass VPatMultiplyAccVL_VV_VX<PatFrag op, string instruction_name> {
   foreach vti = AllIntegerVectors in {
   defvar suffix = vti.LMul.MX;
-  def : Pat<(riscv_vp_merge_vl (vti.Mask true_mask),
-              (vti.Vector (op vti.RegClass:$rd,
-                              (riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
-                                  srcvalue, (vti.Mask true_mask), VLOpFrag),
-                              srcvalue, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_VV_"# suffix)
-                 vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
-                 GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
-  def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
-              (vti.Vector (op vti.RegClass:$rd,
-                              (riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
-                                  srcvalue, (vti.Mask true_mask), VLOpFrag),
-                              srcvalue, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
-                 vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
-  def : Pat<(riscv_vp_merge_vl (vti.Mask true_mask),
-              (vti.Vector (op vti.RegClass:$rd,
-                              (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
-                                  srcvalue, (vti.Mask true_mask), VLOpFrag),
-                              srcvalue, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_VX_"# suffix)
-                 vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
-                 GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
-  def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
-              (vti.Vector (op vti.RegClass:$rd,
-                              (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
-                                  srcvalue, (vti.Mask true_mask), VLOpFrag),
-                              srcvalue, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_VX_"# suffix #"_MASK")
-                 vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
-  def : Pat<(riscv_vselect_vl (vti.Mask V0),
-              (vti.Vector (op vti.RegClass:$rd,
-                              (riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
-                                  srcvalue, (vti.Mask true_mask), VLOpFrag),
-                              srcvalue, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
-                 vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
-  def : Pat<(riscv_vselect_vl (vti.Mask V0),
-              (vti.Vector (op vti.RegClass:$rd,
-                              (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
-                                  srcvalue, (vti.Mask true_mask), VLOpFrag),
-                              srcvalue, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_VX_"# suffix #"_MASK")
-                 vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(riscv_vp_merge_vl (vti.Mask true_mask),
+                (vti.Vector (op vti.RegClass:$rd,
+                                (riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
+                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
+                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_VV_"# suffix)
+                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
+                   GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
+    def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
+                (vti.Vector (op vti.RegClass:$rd,
+                                (riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
+                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
+                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
+                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
+    def : Pat<(riscv_vp_merge_vl (vti.Mask true_mask),
+                (vti.Vector (op vti.RegClass:$rd,
+                                (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
+                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
+                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_VX_"# suffix)
+                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
+                   GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
+    def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
+                (vti.Vector (op vti.RegClass:$rd,
+                                (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
+                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
+                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_VX_"# suffix #"_MASK")
+                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
+    def : Pat<(riscv_vselect_vl (vti.Mask V0),
+                (vti.Vector (op vti.RegClass:$rd,
+                                (riscv_mul_vl_oneuse vti.RegClass:$rs1, vti.RegClass:$rs2,
+                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
+                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
+                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    def : Pat<(riscv_vselect_vl (vti.Mask V0),
+                (vti.Vector (op vti.RegClass:$rd,
+                                (riscv_mul_vl_oneuse (SplatPat XLenVT:$rs1), vti.RegClass:$rs2,
+                                    srcvalue, (vti.Mask true_mask), VLOpFrag),
+                                srcvalue, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_VX_"# suffix #"_MASK")
+                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    }
   }
 }
 
@@ -1432,24 +1506,27 @@ multiclass VPatWidenMultiplyAddVL_VV_VX<PatFrag op1, string instruction_name> {
   foreach vtiTowti = AllWidenableIntVectors in {
     defvar vti = vtiTowti.Vti;
     defvar wti = vtiTowti.Wti;
-    def : Pat<(wti.Vector
-             (riscv_add_vl wti.RegClass:$rd,
-                           (op1 vti.RegClass:$rs1,
-                                (vti.Vector vti.RegClass:$rs2),
-                                srcvalue, (vti.Mask true_mask), VLOpFrag),
-                          srcvalue, (vti.Mask true_mask), VLOpFrag)),
-            (!cast<Instruction>(instruction_name#"_VV_" # vti.LMul.MX)
-                 wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
-                 GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
-    def : Pat<(wti.Vector
-             (riscv_add_vl wti.RegClass:$rd,
-                          (op1 (SplatPat XLenVT:$rs1),
-                               (vti.Vector vti.RegClass:$rs2),
-                               srcvalue, (vti.Mask true_mask), VLOpFrag),
-                           srcvalue, (vti.Mask true_mask), VLOpFrag)),
-            (!cast<Instruction>(instruction_name#"_VX_" # vti.LMul.MX)
-                 wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
-                 GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in {
+      def : Pat<(wti.Vector
+               (riscv_add_vl wti.RegClass:$rd,
+                             (op1 vti.RegClass:$rs1,
+                                  (vti.Vector vti.RegClass:$rs2),
+                                  srcvalue, (vti.Mask true_mask), VLOpFrag),
+                            srcvalue, (vti.Mask true_mask), VLOpFrag)),
+              (!cast<Instruction>(instruction_name#"_VV_" # vti.LMul.MX)
+                   wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
+                   GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+      def : Pat<(wti.Vector
+               (riscv_add_vl wti.RegClass:$rd,
+                            (op1 (SplatPat XLenVT:$rs1),
+                                 (vti.Vector vti.RegClass:$rs2),
+                                 srcvalue, (vti.Mask true_mask), VLOpFrag),
+                             srcvalue, (vti.Mask true_mask), VLOpFrag)),
+              (!cast<Instruction>(instruction_name#"_VX_" # vti.LMul.MX)
+                   wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
+                   GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    }
   }
 }
 
@@ -1457,70 +1534,77 @@ multiclass VPatNarrowShiftSplat_WX_WI<SDNode op, string instruction_name> {
   foreach vtiTowti = AllWidenableIntVectors in {
     defvar vti = vtiTowti.Vti;
     defvar wti = vtiTowti.Wti;
-    def : Pat<(vti.Vector (riscv_trunc_vector_vl
-              (wti.Vector (op wti.RegClass:$rs1, (SplatPat XLenVT:$rs2),
-                              srcvalue, true_mask, VLOpFrag)), true_mask, VLOpFrag)),
-              (!cast<Instruction>(instruction_name#"_WX_"#vti.LMul.MX)
-                   wti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
-    def : Pat<(vti.Vector (riscv_trunc_vector_vl
-              (wti.Vector (op wti.RegClass:$rs1, (SplatPat_uimm5 uimm5:$rs2),
-                              srcvalue, true_mask, VLOpFrag)), true_mask, VLOpFrag)),
-              (!cast<Instruction>(instruction_name#"_WI_"#vti.LMul.MX)
-                   wti.RegClass:$rs1, uimm5:$rs2, GPR:$vl, vti.Log2SEW)>;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in {
+      def : Pat<(vti.Vector (riscv_trunc_vector_vl
+                (wti.Vector (op wti.RegClass:$rs1, (SplatPat XLenVT:$rs2),
+                                srcvalue, true_mask, VLOpFrag)), true_mask, VLOpFrag)),
+                (!cast<Instruction>(instruction_name#"_WX_"#vti.LMul.MX)
+                     wti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
+      def : Pat<(vti.Vector (riscv_trunc_vector_vl
+                (wti.Vector (op wti.RegClass:$rs1, (SplatPat_uimm5 uimm5:$rs2),
+                                srcvalue, true_mask, VLOpFrag)), true_mask, VLOpFrag)),
+                (!cast<Instruction>(instruction_name#"_WI_"#vti.LMul.MX)
+                     wti.RegClass:$rs1, uimm5:$rs2, GPR:$vl, vti.Log2SEW)>;
+    }
   }
 }
 
 multiclass VPatFPMulAddVL_VV_VF<SDPatternOperator vop, string instruction_name> {
   foreach vti = AllFloatVectors in {
   defvar suffix = vti.LMul.MX;
-  def : Pat<(vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rd,
-                             vti.RegClass:$rs2, (vti.Mask V0),
-                             VLOpFrag)),
-            (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
-                 vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rd,
+                               vti.RegClass:$rs2, (vti.Mask V0),
+                               VLOpFrag)),
+              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
+                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
 
-  def : Pat<(vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1),
-                             vti.RegClass:$rd, vti.RegClass:$rs2,
-                             (vti.Mask V0),
-                             VLOpFrag)),
-            (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
-                 vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
+    def : Pat<(vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1),
+                               vti.RegClass:$rd, vti.RegClass:$rs2,
+                               (vti.Mask V0),
+                               VLOpFrag)),
+              (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
+                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
+    }
   }
 }
 
 multiclass VPatFPMulAccVL_VV_VF<PatFrag vop, string instruction_name> {
   foreach vti = AllFloatVectors in {
   defvar suffix = vti.LMul.MX;
-  def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
-                         (vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rs2,
-                          vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
-                 vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
-  def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
-                         (vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1), vti.RegClass:$rs2,
-                          vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
-                 vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
-  def : Pat<(riscv_vselect_vl (vti.Mask V0),
-                         (vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rs2,
-                          vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
-                 vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
-  def : Pat<(riscv_vselect_vl (vti.Mask V0),
-                         (vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1), vti.RegClass:$rs2,
-                          vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
-                          vti.RegClass:$rd, VLOpFrag),
-            (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
-                 vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
+                           (vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rs2,
+                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
+                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
+    def : Pat<(riscv_vp_merge_vl (vti.Mask V0),
+                           (vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1), vti.RegClass:$rs2,
+                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
+                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_UNDISTURBED_MASK_UNDISTURBED)>;
+    def : Pat<(riscv_vselect_vl (vti.Mask V0),
+                           (vti.Vector (vop vti.RegClass:$rs1, vti.RegClass:$rs2,
+                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_VV_"# suffix #"_MASK")
+                   vti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    def : Pat<(riscv_vselect_vl (vti.Mask V0),
+                           (vti.Vector (vop (SplatFPOp vti.ScalarRegClass:$rs1), vti.RegClass:$rs2,
+                            vti.RegClass:$rd, (vti.Mask true_mask), VLOpFrag)),
+                            vti.RegClass:$rd, VLOpFrag),
+              (!cast<Instruction>(instruction_name#"_V" # vti.ScalarSuffix # "_" # suffix # "_MASK")
+                   vti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    }
   }
 }
 
@@ -1528,20 +1612,23 @@ multiclass VPatWidenFPMulAccVL_VV_VF<SDNode vop, string instruction_name> {
   foreach vtiToWti = AllWidenableFloatVectors in {
     defvar vti = vtiToWti.Vti;
     defvar wti = vtiToWti.Wti;
-    def : Pat<(vop (vti.Vector vti.RegClass:$rs1),
-                   (vti.Vector vti.RegClass:$rs2),
-                   (wti.Vector wti.RegClass:$rd), (vti.Mask V0),
-                   VLOpFrag),
-              (!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX #"_MASK")
-                 wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
-    def : Pat<(vop (vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
-                   (vti.Vector vti.RegClass:$rs2),
-                   (wti.Vector wti.RegClass:$rd), (vti.Mask V0),
-                   VLOpFrag),
-              (!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX #"_MASK")
-                 wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<wti>.Predicates) in {
+      def : Pat<(vop (vti.Vector vti.RegClass:$rs1),
+                     (vti.Vector vti.RegClass:$rs2),
+                     (wti.Vector wti.RegClass:$rd), (vti.Mask V0),
+                     VLOpFrag),
+                (!cast<Instruction>(instruction_name#"_VV_"#vti.LMul.MX #"_MASK")
+                   wti.RegClass:$rd, vti.RegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
+      def : Pat<(vop (vti.Vector (SplatFPOp vti.ScalarRegClass:$rs1)),
+                     (vti.Vector vti.RegClass:$rs2),
+                     (wti.Vector wti.RegClass:$rd), (vti.Mask V0),
+                     VLOpFrag),
+                (!cast<Instruction>(instruction_name#"_V"#vti.ScalarSuffix#"_"#vti.LMul.MX #"_MASK")
+                   wti.RegClass:$rd, vti.ScalarRegClass:$rs1, vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
+    }
   }
 }
 
@@ -1549,8 +1636,6 @@ multiclass VPatWidenFPMulAccVL_VV_VF<SDNode vop, string instruction_name> {
 // Patterns.
 //===----------------------------------------------------------------------===//
 
-let Predicates = [HasVInstructions] in {
-
 // 11. Vector Integer Arithmetic Instructions
 
 // 11.1. Vector Single-Width Integer Add and Subtract
@@ -1559,18 +1644,20 @@ defm : VPatBinaryVL_VV_VX<riscv_sub_vl, "PseudoVSUB">;
 // Handle VRSUB specially since it's the only integer binary op with reversed
 // pattern operands
 foreach vti = AllIntegerVectors in {
-  def : Pat<(riscv_sub_vl (vti.Vector (SplatPat (XLenVT GPR:$rs2))),
-                          (vti.Vector vti.RegClass:$rs1),
-                          vti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
-            (!cast<Instruction>("PseudoVRSUB_VX_"# vti.LMul.MX#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs1, GPR:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
-  def : Pat<(riscv_sub_vl (vti.Vector (SplatPat_simm5 simm5:$rs2)),
-                          (vti.Vector vti.RegClass:$rs1),
-                          vti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
-            (!cast<Instruction>("PseudoVRSUB_VI_"# vti.LMul.MX#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs1, simm5:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(riscv_sub_vl (vti.Vector (SplatPat (XLenVT GPR:$rs2))),
+                            (vti.Vector vti.RegClass:$rs1),
+                            vti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
+              (!cast<Instruction>("PseudoVRSUB_VX_"# vti.LMul.MX#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs1, GPR:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    def : Pat<(riscv_sub_vl (vti.Vector (SplatPat_simm5 simm5:$rs2)),
+                            (vti.Vector vti.RegClass:$rs1),
+                            vti.RegClass:$merge, (vti.Mask V0), VLOpFrag),
+              (!cast<Instruction>("PseudoVRSUB_VI_"# vti.LMul.MX#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs1, simm5:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+  }
 }
 
 // 11.2. Vector Widening Integer Add/Subtract
@@ -1605,6 +1692,7 @@ defm : VPatBinaryVL_VV_VX_VI<riscv_sra_vl, "PseudoVSRA", uimm5>;
 
 foreach vti = AllIntegerVectors in {
   // Emit shift by 1 as an add since it might be faster.
+  let Predicates = GetVTypePredicates<vti>.Predicates in
   def : Pat<(riscv_shl_vl (vti.Vector vti.RegClass:$rs1),
                           (riscv_vmv_v_x_vl (vti.Vector undef), 1, (XLenVT srcvalue)),
                           srcvalue, (vti.Mask true_mask), VLOpFrag),
@@ -1628,6 +1716,8 @@ defm : VPatBinaryNVL_WV_WX_WI<riscv_vnsrl_vl, "PseudoVNSRL">;
 foreach vtiTowti = AllWidenableIntVectors in {
   defvar vti = vtiTowti.Vti;
   defvar wti = vtiTowti.Wti;
+  let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                               GetVTypePredicates<wti>.Predicates) in
   def : Pat<(vti.Vector (riscv_trunc_vector_vl (wti.Vector wti.RegClass:$rs1),
                                                (vti.Mask V0),
                                                VLOpFrag)),
@@ -1638,39 +1728,41 @@ foreach vtiTowti = AllWidenableIntVectors in {
 
 // 11.8. Vector Integer Comparison Instructions
 foreach vti = AllIntegerVectors in {
-  defm : VPatIntegerSetCCVL_VV<vti, "PseudoVMSEQ", SETEQ>;
-  defm : VPatIntegerSetCCVL_VV<vti, "PseudoVMSNE", SETNE>;
-
-  defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLT",  SETLT,  SETGT>;
-  defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLTU", SETULT, SETUGT>;
-  defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLE",  SETLE,  SETGE>;
-  defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
-
-  defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSEQ",  SETEQ,  SETEQ>;
-  defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSNE",  SETNE,  SETNE>;
-  defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLT",  SETLT,  SETGT>;
-  defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLTU", SETULT, SETUGT>;
-  defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLE",  SETLE,  SETGE>;
-  defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
-  defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSGT",  SETGT,  SETLT>;
-  defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSGTU", SETUGT, SETULT>;
-  // There is no VMSGE(U)_VX instruction
-
-  defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSEQ",  SETEQ,  SETEQ>;
-  defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSNE",  SETNE,  SETNE>;
-  defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSLE",  SETLE,  SETGE>;
-  defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
-  defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSGT",  SETGT,  SETLT>;
-  defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSGTU", SETUGT, SETULT>;
-
-  defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSLE",  SETLT, SETGT,
-                                              SplatPat_simm5_plus1>;
-  defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSLEU", SETULT, SETUGT,
-                                              SplatPat_simm5_plus1_nonzero>;
-  defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSGT",  SETGE, SETLE,
-                                              SplatPat_simm5_plus1>;
-  defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSGTU", SETUGE, SETULE,
-                                              SplatPat_simm5_plus1_nonzero>;
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    defm : VPatIntegerSetCCVL_VV<vti, "PseudoVMSEQ", SETEQ>;
+    defm : VPatIntegerSetCCVL_VV<vti, "PseudoVMSNE", SETNE>;
+
+    defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLT",  SETLT,  SETGT>;
+    defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLTU", SETULT, SETUGT>;
+    defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLE",  SETLE,  SETGE>;
+    defm : VPatIntegerSetCCVL_VV_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
+
+    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSEQ",  SETEQ,  SETEQ>;
+    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSNE",  SETNE,  SETNE>;
+    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLT",  SETLT,  SETGT>;
+    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLTU", SETULT, SETUGT>;
+    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLE",  SETLE,  SETGE>;
+    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
+    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSGT",  SETGT,  SETLT>;
+    defm : VPatIntegerSetCCVL_VX_Swappable<vti, "PseudoVMSGTU", SETUGT, SETULT>;
+    // There is no VMSGE(U)_VX instruction
+
+    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSEQ",  SETEQ,  SETEQ>;
+    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSNE",  SETNE,  SETNE>;
+    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSLE",  SETLE,  SETGE>;
+    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
+    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSGT",  SETGT,  SETLT>;
+    defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSGTU", SETUGT, SETULT>;
+
+    defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSLE",  SETLT, SETGT,
+                                                SplatPat_simm5_plus1>;
+    defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSLEU", SETULT, SETUGT,
+                                                SplatPat_simm5_plus1_nonzero>;
+    defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSGT",  SETGE, SETLE,
+                                                SplatPat_simm5_plus1>;
+    defm : VPatIntegerSetCCVL_VIPlus1_Swappable<vti, "PseudoVMSGTU", SETUGE, SETULE,
+                                                SplatPat_simm5_plus1_nonzero>;
+  }
 } // foreach vti = AllIntegerVectors
 
 // 11.9. Vector Integer Min/Max Instructions
@@ -1681,8 +1773,13 @@ defm : VPatBinaryVL_VV_VX<riscv_smax_vl, "PseudoVMAX">;
 
 // 11.10. Vector Single-Width Integer Multiply Instructions
 defm : VPatBinaryVL_VV_VX<riscv_mul_vl, "PseudoVMUL">;
-defm : VPatBinaryVL_VV_VX<riscv_mulhs_vl, "PseudoVMULH">;
-defm : VPatBinaryVL_VV_VX<riscv_mulhu_vl, "PseudoVMULHU">;
+defm : VPatBinaryVL_VV_VX<riscv_mulhs_vl, "PseudoVMULH", IntegerVectorsExceptI64>;
+defm : VPatBinaryVL_VV_VX<riscv_mulhu_vl, "PseudoVMULHU", IntegerVectorsExceptI64>;
+// vsmul.vv and vsmul.vx are not included in EEW=64 in Zve64*.
+let Predicates = [HasVInstructionsFullMultiply] in {
+  defm : VPatBinaryVL_VV_VX<riscv_mulhs_vl, "PseudoVMULH", I64IntegerVectors>;
+  defm : VPatBinaryVL_VV_VX<riscv_mulhu_vl, "PseudoVMULHU", I64IntegerVectors>;  
+}
 
 // 11.11. Vector Integer Divide Instructions
 defm : VPatBinaryVL_VV_VX_E<riscv_udiv_vl, "PseudoVDIVU">;
@@ -1708,6 +1805,8 @@ defm : VPatWidenMultiplyAddVL_VV_VX<riscv_vwmulsu_vl_oneuse, "PseudoVWMACCSU">;
 foreach vtiTowti = AllWidenableIntVectors in {
   defvar vti = vtiTowti.Vti;
   defvar wti = vtiTowti.Wti;
+  let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                               GetVTypePredicates<wti>.Predicates) in
   def : Pat<(wti.Vector
              (riscv_add_vl wti.RegClass:$rd,
                            (riscv_vwmulsu_vl_oneuse (vti.Vector vti.RegClass:$rs1),
@@ -1723,71 +1822,75 @@ foreach vtiTowti = AllWidenableIntVectors in {
 
 // 11.15. Vector Integer Merge Instructions
 foreach vti = AllIntegerVectors in {
-  def : Pat<(vti.Vector (riscv_vselect_vl (vti.Mask V0),
-                                          vti.RegClass:$rs1,
-                                          vti.RegClass:$rs2,
-                                          VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VVM_"#vti.LMul.MX)
-                 vti.RegClass:$rs2, vti.RegClass:$rs1, (vti.Mask V0),
-                 GPR:$vl, vti.Log2SEW)>;
-
-  def : Pat<(vti.Vector (riscv_vselect_vl (vti.Mask V0),
-                                          (SplatPat XLenVT:$rs1),
-                                          vti.RegClass:$rs2,
-                                          VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VXM_"#vti.LMul.MX)
-                 vti.RegClass:$rs2, GPR:$rs1, (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
-
-  def : Pat<(vti.Vector (riscv_vselect_vl (vti.Mask V0),
-                                          (SplatPat_simm5 simm5:$rs1),
-                                          vti.RegClass:$rs2,
-                                          VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VIM_"#vti.LMul.MX)
-                 vti.RegClass:$rs2, simm5:$rs1, (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
-
-  def : Pat<(vti.Vector (riscv_vp_merge_vl (vti.Mask V0),
-                                           vti.RegClass:$rs1,
-                                           vti.RegClass:$rs2,
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VVM_"#vti.LMul.MX#"_TU")
-                 vti.RegClass:$rs2, vti.RegClass:$rs2, vti.RegClass:$rs1,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
-
-  def : Pat<(vti.Vector (riscv_vp_merge_vl (vti.Mask V0),
-                                           (SplatPat XLenVT:$rs1),
-                                           vti.RegClass:$rs2,
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VXM_"#vti.LMul.MX#"_TU")
-                 vti.RegClass:$rs2, vti.RegClass:$rs2, GPR:$rs1,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
-
-  def : Pat<(vti.Vector (riscv_vp_merge_vl (vti.Mask V0),
-                                           (SplatPat_simm5 simm5:$rs1),
-                                           vti.RegClass:$rs2,
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VIM_"#vti.LMul.MX#"_TU")
-                 vti.RegClass:$rs2, vti.RegClass:$rs2, simm5:$rs1,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(vti.Vector (riscv_vselect_vl (vti.Mask V0),
+                                            vti.RegClass:$rs1,
+                                            vti.RegClass:$rs2,
+                                            VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VVM_"#vti.LMul.MX)
+                   vti.RegClass:$rs2, vti.RegClass:$rs1, (vti.Mask V0),
+                   GPR:$vl, vti.Log2SEW)>;
+
+    def : Pat<(vti.Vector (riscv_vselect_vl (vti.Mask V0),
+                                            (SplatPat XLenVT:$rs1),
+                                            vti.RegClass:$rs2,
+                                            VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VXM_"#vti.LMul.MX)
+                   vti.RegClass:$rs2, GPR:$rs1, (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
+
+    def : Pat<(vti.Vector (riscv_vselect_vl (vti.Mask V0),
+                                            (SplatPat_simm5 simm5:$rs1),
+                                            vti.RegClass:$rs2,
+                                            VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VIM_"#vti.LMul.MX)
+                   vti.RegClass:$rs2, simm5:$rs1, (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
+
+    def : Pat<(vti.Vector (riscv_vp_merge_vl (vti.Mask V0),
+                                             vti.RegClass:$rs1,
+                                             vti.RegClass:$rs2,
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VVM_"#vti.LMul.MX#"_TU")
+                   vti.RegClass:$rs2, vti.RegClass:$rs2, vti.RegClass:$rs1,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
+
+    def : Pat<(vti.Vector (riscv_vp_merge_vl (vti.Mask V0),
+                                             (SplatPat XLenVT:$rs1),
+                                             vti.RegClass:$rs2,
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VXM_"#vti.LMul.MX#"_TU")
+                   vti.RegClass:$rs2, vti.RegClass:$rs2, GPR:$rs1,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
+
+    def : Pat<(vti.Vector (riscv_vp_merge_vl (vti.Mask V0),
+                                             (SplatPat_simm5 simm5:$rs1),
+                                             vti.RegClass:$rs2,
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VIM_"#vti.LMul.MX#"_TU")
+                   vti.RegClass:$rs2, vti.RegClass:$rs2, simm5:$rs1,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW)>;
+  }
 }
 
 // 11.16. Vector Integer Move Instructions
 foreach vti = AllIntegerVectors in {
-  def : Pat<(vti.Vector (riscv_vmv_v_x_vl (vti.Vector undef), GPR:$rs2, VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_V_X_"#vti.LMul.MX)
-             $rs2, GPR:$vl, vti.Log2SEW)>;
-  def : Pat<(vti.Vector (riscv_vmv_v_x_vl vti.Vector:$passthru, GPR:$rs2, VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_V_X_"#vti.LMul.MX#"_TU")
-             $passthru, $rs2, GPR:$vl, vti.Log2SEW)>;
-  defvar ImmPat = !cast<ComplexPattern>("sew"#vti.SEW#"simm5");
-  def : Pat<(vti.Vector (riscv_vmv_v_x_vl (vti.Vector undef), (ImmPat XLenVT:$imm5),
-                                          VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_V_I_"#vti.LMul.MX)
-             XLenVT:$imm5, GPR:$vl, vti.Log2SEW)>;
-  def : Pat<(vti.Vector (riscv_vmv_v_x_vl vti.Vector:$passthru, (ImmPat XLenVT:$imm5),
-                                              VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_V_I_"#vti.LMul.MX#"_TU")
-             $passthru, XLenVT:$imm5, GPR:$vl, vti.Log2SEW)>;
-}
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(vti.Vector (riscv_vmv_v_x_vl (vti.Vector undef), GPR:$rs2, VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_V_X_"#vti.LMul.MX)
+               $rs2, GPR:$vl, vti.Log2SEW)>;
+    def : Pat<(vti.Vector (riscv_vmv_v_x_vl vti.Vector:$passthru, GPR:$rs2, VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_V_X_"#vti.LMul.MX#"_TU")
+               $passthru, $rs2, GPR:$vl, vti.Log2SEW)>;
+    defvar ImmPat = !cast<ComplexPattern>("sew"#vti.SEW#"simm5");
+    def : Pat<(vti.Vector (riscv_vmv_v_x_vl (vti.Vector undef), (ImmPat XLenVT:$imm5),
+                                            VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_V_I_"#vti.LMul.MX)
+               XLenVT:$imm5, GPR:$vl, vti.Log2SEW)>;
+    def : Pat<(vti.Vector (riscv_vmv_v_x_vl vti.Vector:$passthru, (ImmPat XLenVT:$imm5),
+                                                VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_V_I_"#vti.LMul.MX#"_TU")
+               $passthru, XLenVT:$imm5, GPR:$vl, vti.Log2SEW)>;
+  }
+}  
 
 // 12. Vector Fixed-Point Arithmetic Instructions
 
@@ -1797,12 +1900,8 @@ defm : VPatBinaryVL_VV_VX_VI<riscv_uaddsat_vl, "PseudoVSADDU">;
 defm : VPatBinaryVL_VV_VX<riscv_ssubsat_vl, "PseudoVSSUB">;
 defm : VPatBinaryVL_VV_VX<riscv_usubsat_vl, "PseudoVSSUBU">;
 
-} // Predicates = [HasVInstructions]
-
 // 13. Vector Floating-Point Instructions
 
-let Predicates = [HasVInstructionsAnyF] in {
-
 // 13.2. Vector Single-Width Floating-Point Add/Subtract Instructions
 defm : VPatBinaryFPVL_VV_VF<any_riscv_fadd_vl, "PseudoVFADD">;
 defm : VPatBinaryFPVL_VV_VF<any_riscv_fsub_vl, "PseudoVFSUB">;
@@ -1859,159 +1958,163 @@ defm : VPatFPSetCCVL_VV_VF_FV<any_riscv_fsetccs_vl, SETOLE,
                               "PseudoVMFLE", "PseudoVMFGE">;
 
 foreach vti = AllFloatVectors in {
-  // 13.8. Vector Floating-Point Square-Root Instruction
-  def : Pat<(any_riscv_fsqrt_vl (vti.Vector vti.RegClass:$rs2), (vti.Mask V0),
-                            VLOpFrag),
-            (!cast<Instruction>("PseudoVFSQRT_V_"# vti.LMul.MX # "_E" # vti.SEW # "_MASK")
-                 (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs2,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
-
-  // 13.12. Vector Floating-Point Sign-Injection Instructions
-  def : Pat<(riscv_fabs_vl (vti.Vector vti.RegClass:$rs), (vti.Mask V0),
-                           VLOpFrag),
-            (!cast<Instruction>("PseudoVFSGNJX_VV_"# vti.LMul.MX #"_MASK")
-                 (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs,
-                 vti.RegClass:$rs, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
-                 TA_MA)>;
-  // Handle fneg with VFSGNJN using the same input for both operands.
-  def : Pat<(riscv_fneg_vl (vti.Vector vti.RegClass:$rs), (vti.Mask V0),
-                           VLOpFrag),
-            (!cast<Instruction>("PseudoVFSGNJN_VV_"# vti.LMul.MX #"_MASK")
-                 (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs,
-                 vti.RegClass:$rs, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
-                 TA_MA)>;
-
-  def : Pat<(riscv_fcopysign_vl (vti.Vector vti.RegClass:$rs1),
-                                (vti.Vector vti.RegClass:$rs2),
-                                vti.RegClass:$merge,
-                                (vti.Mask V0),
-                                VLOpFrag),
-            (!cast<Instruction>("PseudoVFSGNJ_VV_"# vti.LMul.MX#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs1,
-                 vti.RegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
-                 TAIL_AGNOSTIC)>;
-
-  def : Pat<(riscv_fcopysign_vl (vti.Vector vti.RegClass:$rs1),
-                                (riscv_fneg_vl vti.RegClass:$rs2,
-                                               (vti.Mask true_mask),
-                                               VLOpFrag),
-                                srcvalue,
-                                (vti.Mask true_mask),
-                                VLOpFrag),
-            (!cast<Instruction>("PseudoVFSGNJN_VV_"# vti.LMul.MX)
-                 vti.RegClass:$rs1, vti.RegClass:$rs2, GPR:$vl, vti.Log2SEW)>;
-
-  def : Pat<(riscv_fcopysign_vl (vti.Vector vti.RegClass:$rs1),
-                                (SplatFPOp vti.ScalarRegClass:$rs2),
-                                vti.RegClass:$merge,
-                                (vti.Mask V0),
-                                VLOpFrag),
-            (!cast<Instruction>("PseudoVFSGNJ_V"#vti.ScalarSuffix#"_"# vti.LMul.MX#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs1,
-                 vti.ScalarRegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
-                 TAIL_AGNOSTIC)>;
-
-  // Rounding without exception to implement nearbyint.
-  def : Pat<(any_riscv_vfround_noexcept_vl (vti.Vector vti.RegClass:$rs1),
-                                           (vti.Mask V0), VLOpFrag),
-            (!cast<Instruction>("PseudoVFROUND_NOEXCEPT_V_" # vti.LMul.MX #"_MASK")
-                  (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs1,
-                  (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    // 13.8. Vector Floating-Point Square-Root Instruction
+    def : Pat<(any_riscv_fsqrt_vl (vti.Vector vti.RegClass:$rs2), (vti.Mask V0),
+                              VLOpFrag),
+              (!cast<Instruction>("PseudoVFSQRT_V_"# vti.LMul.MX # "_E" # vti.SEW # "_MASK")
+                   (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs2,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
+
+    // 13.12. Vector Floating-Point Sign-Injection Instructions
+    def : Pat<(riscv_fabs_vl (vti.Vector vti.RegClass:$rs), (vti.Mask V0),
+                             VLOpFrag),
+              (!cast<Instruction>("PseudoVFSGNJX_VV_"# vti.LMul.MX #"_MASK")
+                   (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs,
+                   vti.RegClass:$rs, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
+                   TA_MA)>;
+    // Handle fneg with VFSGNJN using the same input for both operands.
+    def : Pat<(riscv_fneg_vl (vti.Vector vti.RegClass:$rs), (vti.Mask V0),
+                             VLOpFrag),
+              (!cast<Instruction>("PseudoVFSGNJN_VV_"# vti.LMul.MX #"_MASK")
+                   (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs,
+                   vti.RegClass:$rs, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
+                   TA_MA)>;
+
+    def : Pat<(riscv_fcopysign_vl (vti.Vector vti.RegClass:$rs1),
+                                  (vti.Vector vti.RegClass:$rs2),
+                                  vti.RegClass:$merge,
+                                  (vti.Mask V0),
+                                  VLOpFrag),
+              (!cast<Instruction>("PseudoVFSGNJ_VV_"# vti.LMul.MX#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs1,
+                   vti.RegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
+                   TAIL_AGNOSTIC)>;
+
+    def : Pat<(riscv_fcopysign_vl (vti.Vector vti.RegClass:$rs1),
+                                  (riscv_fneg_vl vti.RegClass:$rs2,
+                                                 (vti.Mask true_mask),
+                                                 VLOpFrag),
+                                  srcvalue,
+                                  (vti.Mask true_mask),
+                                  VLOpFrag),
+              (!cast<Instruction>("PseudoVFSGNJN_VV_"# vti.LMul.MX)
+                   vti.RegClass:$rs1, vti.RegClass:$rs2, GPR:$vl, vti.Log2SEW)>;
+
+    def : Pat<(riscv_fcopysign_vl (vti.Vector vti.RegClass:$rs1),
+                                  (SplatFPOp vti.ScalarRegClass:$rs2),
+                                  vti.RegClass:$merge,
+                                  (vti.Mask V0),
+                                  VLOpFrag),
+              (!cast<Instruction>("PseudoVFSGNJ_V"#vti.ScalarSuffix#"_"# vti.LMul.MX#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs1,
+                   vti.ScalarRegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW,
+                   TAIL_AGNOSTIC)>;
+
+    // Rounding without exception to implement nearbyint.
+    def : Pat<(any_riscv_vfround_noexcept_vl (vti.Vector vti.RegClass:$rs1),
+                                             (vti.Mask V0), VLOpFrag),
+              (!cast<Instruction>("PseudoVFROUND_NOEXCEPT_V_" # vti.LMul.MX #"_MASK")
+                    (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs1,
+                    (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>;
+  }
 }
 
 foreach fvti = AllFloatVectors in {
   // Floating-point vselects:
   // 11.15. Vector Integer Merge Instructions
   // 13.15. Vector Floating-Point Merge Instruction
-  def : Pat<(fvti.Vector (riscv_vselect_vl (fvti.Mask V0),
-                                           fvti.RegClass:$rs1,
-                                           fvti.RegClass:$rs2,
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VVM_"#fvti.LMul.MX)
-                 fvti.RegClass:$rs2, fvti.RegClass:$rs1, (fvti.Mask V0),
-                 GPR:$vl, fvti.Log2SEW)>;
-
-  def : Pat<(fvti.Vector (riscv_vselect_vl (fvti.Mask V0),
-                                           (SplatFPOp fvti.ScalarRegClass:$rs1),
-                                           fvti.RegClass:$rs2,
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVFMERGE_V"#fvti.ScalarSuffix#"M_"#fvti.LMul.MX)
-                 fvti.RegClass:$rs2,
-                 (fvti.Scalar fvti.ScalarRegClass:$rs1),
-                 (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>;
-
-  def : Pat<(fvti.Vector (riscv_vselect_vl (fvti.Mask V0),
-                                           (SplatFPOp (SelectFPImm (XLenVT GPR:$imm))),
-                                           fvti.RegClass:$rs2,
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VXM_"#fvti.LMul.MX)
-                 fvti.RegClass:$rs2,
-                 GPR:$imm,
-                 (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>;
-
-  def : Pat<(fvti.Vector (riscv_vselect_vl (fvti.Mask V0),
-                                           (SplatFPOp (fvti.Scalar fpimm0)),
-                                           fvti.RegClass:$rs2,
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VIM_"#fvti.LMul.MX)
-                 fvti.RegClass:$rs2, 0, (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>;
-
-  def : Pat<(fvti.Vector (riscv_vp_merge_vl (fvti.Mask V0),
-                                            fvti.RegClass:$rs1,
-                                            fvti.RegClass:$rs2,
-                                            VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VVM_"#fvti.LMul.MX#"_TU")
-                 fvti.RegClass:$rs2, fvti.RegClass:$rs2, fvti.RegClass:$rs1, (fvti.Mask V0),
-                 GPR:$vl, fvti.Log2SEW)>;
+  let Predicates = GetVTypePredicates<fvti>.Predicates in {
+    def : Pat<(fvti.Vector (riscv_vselect_vl (fvti.Mask V0),
+                                             fvti.RegClass:$rs1,
+                                             fvti.RegClass:$rs2,
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VVM_"#fvti.LMul.MX)
+                   fvti.RegClass:$rs2, fvti.RegClass:$rs1, (fvti.Mask V0),
+                   GPR:$vl, fvti.Log2SEW)>;
 
-  def : Pat<(fvti.Vector (riscv_vp_merge_vl (fvti.Mask V0),
-                                            (SplatFPOp fvti.ScalarRegClass:$rs1),
-                                            fvti.RegClass:$rs2,
-                                            VLOpFrag)),
-            (!cast<Instruction>("PseudoVFMERGE_V"#fvti.ScalarSuffix#"M_"#fvti.LMul.MX#"_TU")
-                 fvti.RegClass:$rs2, fvti.RegClass:$rs2,
-                 (fvti.Scalar fvti.ScalarRegClass:$rs1),
-                 (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>;
-
-  def : Pat<(fvti.Vector (riscv_vp_merge_vl (fvti.Mask V0),
-                                            (SplatFPOp (fvti.Scalar fpimm0)),
-                                            fvti.RegClass:$rs2,
-                                            VLOpFrag)),
-            (!cast<Instruction>("PseudoVMERGE_VIM_"#fvti.LMul.MX#"_TU")
-                 fvti.RegClass:$rs2, fvti.RegClass:$rs2, 0, (fvti.Mask V0),
-                 GPR:$vl, fvti.Log2SEW)>;
-
-  // 13.16. Vector Floating-Point Move Instruction
-  // If we're splatting fpimm0, use vmv.v.x vd, x0.
-  def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
-                         (fvti.Vector undef), (fvti.Scalar (fpimm0)), VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_V_I_"#fvti.LMul.MX)
-             0, GPR:$vl, fvti.Log2SEW)>;
-  def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
-                         fvti.Vector:$passthru, (fvti.Scalar (fpimm0)), VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_V_I_"#fvti.LMul.MX#"_TU")
-             $passthru, 0, GPR:$vl, fvti.Log2SEW)>;
-  def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
-                         (fvti.Vector undef), (fvti.Scalar (SelectFPImm (XLenVT GPR:$imm))), VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_V_X_"#fvti.LMul.MX)
-             GPR:$imm, GPR:$vl, fvti.Log2SEW)>;
-  def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
-                         fvti.Vector:$passthru, (fvti.Scalar (SelectFPImm (XLenVT GPR:$imm))), VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_V_X_"#fvti.LMul.MX#"_TU")
-             $passthru, GPR:$imm, GPR:$vl, fvti.Log2SEW)>;
-
-  def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
-                         (fvti.Vector undef), (fvti.Scalar fvti.ScalarRegClass:$rs2), VLOpFrag)),
-            (!cast<Instruction>("PseudoVFMV_V_" # fvti.ScalarSuffix # "_" #
-                                fvti.LMul.MX)
-             (fvti.Scalar fvti.ScalarRegClass:$rs2),
-             GPR:$vl, fvti.Log2SEW)>;
-  def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
-                         fvti.Vector:$passthru, (fvti.Scalar fvti.ScalarRegClass:$rs2), VLOpFrag)),
-            (!cast<Instruction>("PseudoVFMV_V_" # fvti.ScalarSuffix # "_" #
-                                fvti.LMul.MX # "_TU")
-             $passthru, (fvti.Scalar fvti.ScalarRegClass:$rs2),
-             GPR:$vl, fvti.Log2SEW)>;
+    def : Pat<(fvti.Vector (riscv_vselect_vl (fvti.Mask V0),
+                                             (SplatFPOp fvti.ScalarRegClass:$rs1),
+                                             fvti.RegClass:$rs2,
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVFMERGE_V"#fvti.ScalarSuffix#"M_"#fvti.LMul.MX)
+                   fvti.RegClass:$rs2,
+                   (fvti.Scalar fvti.ScalarRegClass:$rs1),
+                   (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>;
+
+    def : Pat<(fvti.Vector (riscv_vselect_vl (fvti.Mask V0),
+                                             (SplatFPOp (SelectFPImm (XLenVT GPR:$imm))),
+                                             fvti.RegClass:$rs2,
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VXM_"#fvti.LMul.MX)
+                   fvti.RegClass:$rs2,
+                   GPR:$imm,
+                   (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>;
+
+    def : Pat<(fvti.Vector (riscv_vselect_vl (fvti.Mask V0),
+                                             (SplatFPOp (fvti.Scalar fpimm0)),
+                                             fvti.RegClass:$rs2,
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VIM_"#fvti.LMul.MX)
+                   fvti.RegClass:$rs2, 0, (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>;
+
+    def : Pat<(fvti.Vector (riscv_vp_merge_vl (fvti.Mask V0),
+                                              fvti.RegClass:$rs1,
+                                              fvti.RegClass:$rs2,
+                                              VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VVM_"#fvti.LMul.MX#"_TU")
+                   fvti.RegClass:$rs2, fvti.RegClass:$rs2, fvti.RegClass:$rs1, (fvti.Mask V0),
+                   GPR:$vl, fvti.Log2SEW)>;
+
+    def : Pat<(fvti.Vector (riscv_vp_merge_vl (fvti.Mask V0),
+                                              (SplatFPOp fvti.ScalarRegClass:$rs1),
+                                              fvti.RegClass:$rs2,
+                                              VLOpFrag)),
+              (!cast<Instruction>("PseudoVFMERGE_V"#fvti.ScalarSuffix#"M_"#fvti.LMul.MX#"_TU")
+                   fvti.RegClass:$rs2, fvti.RegClass:$rs2,
+                   (fvti.Scalar fvti.ScalarRegClass:$rs1),
+                   (fvti.Mask V0), GPR:$vl, fvti.Log2SEW)>;
+
+    def : Pat<(fvti.Vector (riscv_vp_merge_vl (fvti.Mask V0),
+                                              (SplatFPOp (fvti.Scalar fpimm0)),
+                                              fvti.RegClass:$rs2,
+                                              VLOpFrag)),
+              (!cast<Instruction>("PseudoVMERGE_VIM_"#fvti.LMul.MX#"_TU")
+                   fvti.RegClass:$rs2, fvti.RegClass:$rs2, 0, (fvti.Mask V0),
+                   GPR:$vl, fvti.Log2SEW)>;
+
+    // 13.16. Vector Floating-Point Move Instruction
+    // If we're splatting fpimm0, use vmv.v.x vd, x0.
+    def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
+                           (fvti.Vector undef), (fvti.Scalar (fpimm0)), VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_V_I_"#fvti.LMul.MX)
+               0, GPR:$vl, fvti.Log2SEW)>;
+    def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
+                           fvti.Vector:$passthru, (fvti.Scalar (fpimm0)), VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_V_I_"#fvti.LMul.MX#"_TU")
+               $passthru, 0, GPR:$vl, fvti.Log2SEW)>;
+    def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
+                           (fvti.Vector undef), (fvti.Scalar (SelectFPImm (XLenVT GPR:$imm))), VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_V_X_"#fvti.LMul.MX)
+               GPR:$imm, GPR:$vl, fvti.Log2SEW)>;
+    def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
+                           fvti.Vector:$passthru, (fvti.Scalar (SelectFPImm (XLenVT GPR:$imm))), VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_V_X_"#fvti.LMul.MX#"_TU")
+               $passthru, GPR:$imm, GPR:$vl, fvti.Log2SEW)>;
+
+    def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
+                           (fvti.Vector undef), (fvti.Scalar fvti.ScalarRegClass:$rs2), VLOpFrag)),
+              (!cast<Instruction>("PseudoVFMV_V_" # fvti.ScalarSuffix # "_" #
+                                  fvti.LMul.MX)
+               (fvti.Scalar fvti.ScalarRegClass:$rs2),
+               GPR:$vl, fvti.Log2SEW)>;
+    def : Pat<(fvti.Vector (riscv_vfmv_v_f_vl
+                           fvti.Vector:$passthru, (fvti.Scalar fvti.ScalarRegClass:$rs2), VLOpFrag)),
+              (!cast<Instruction>("PseudoVFMV_V_" # fvti.ScalarSuffix # "_" #
+                                  fvti.LMul.MX # "_TU")
+               $passthru, (fvti.Scalar fvti.ScalarRegClass:$rs2),
+               GPR:$vl, fvti.Log2SEW)>;
+  }
 }
 
 // 13.17. Vector Single-Width Floating-Point/Integer Type-Convert Instructions
@@ -2047,6 +2150,8 @@ defm : VPatWConvertI2FP_RM_VL_V<riscv_vfcvt_rm_f_x_vl, "PseudoVFWCVT_RM_F_X_V">;
 foreach fvtiToFWti = AllWidenableFloatVectors in {
   defvar fvti = fvtiToFWti.Vti;
   defvar fwti = fvtiToFWti.Wti;
+  let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                               GetVTypePredicates<fwti>.Predicates) in
   def : Pat<(fwti.Vector (any_riscv_fpextend_vl
                              (fvti.Vector fvti.RegClass:$rs1),
                              (fvti.Mask V0),
@@ -2074,27 +2179,27 @@ defm : VPatNConvertI2FP_RM_VL_W<riscv_vfcvt_rm_f_x_vl, "PseudoVFNCVT_RM_F_X_W">;
 foreach fvtiToFWti = AllWidenableFloatVectors in {
   defvar fvti = fvtiToFWti.Vti;
   defvar fwti = fvtiToFWti.Wti;
-  def : Pat<(fvti.Vector (any_riscv_fpround_vl
-                             (fwti.Vector fwti.RegClass:$rs1),
-                             (fwti.Mask V0), VLOpFrag)),
-            (!cast<Instruction>("PseudoVFNCVT_F_F_W_"#fvti.LMul.MX#"_MASK")
-                (fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
-                (fwti.Mask V0), GPR:$vl, fvti.Log2SEW, TA_MA)>;
-
-  def : Pat<(fvti.Vector (any_riscv_fncvt_rod_vl
-                             (fwti.Vector fwti.RegClass:$rs1),
-                             (fwti.Mask V0), VLOpFrag)),
-            (!cast<Instruction>("PseudoVFNCVT_ROD_F_F_W_"#fvti.LMul.MX#"_MASK")
-                (fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
-                (fwti.Mask V0), GPR:$vl, fvti.Log2SEW, TA_MA)>;
+  let Predicates = !listconcat(GetVTypePredicates<fvti>.Predicates,
+                               GetVTypePredicates<fwti>.Predicates) in {
+    def : Pat<(fvti.Vector (any_riscv_fpround_vl
+                               (fwti.Vector fwti.RegClass:$rs1),
+                               (fwti.Mask V0), VLOpFrag)),
+              (!cast<Instruction>("PseudoVFNCVT_F_F_W_"#fvti.LMul.MX#"_MASK")
+                  (fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
+                  (fwti.Mask V0), GPR:$vl, fvti.Log2SEW, TA_MA)>;
+
+    def : Pat<(fvti.Vector (any_riscv_fncvt_rod_vl
+                               (fwti.Vector fwti.RegClass:$rs1),
+                               (fwti.Mask V0), VLOpFrag)),
+              (!cast<Instruction>("PseudoVFNCVT_ROD_F_F_W_"#fvti.LMul.MX#"_MASK")
+                  (fvti.Vector (IMPLICIT_DEF)), fwti.RegClass:$rs1,
+                  (fwti.Mask V0), GPR:$vl, fvti.Log2SEW, TA_MA)>;
+  }
 }
 
-} // Predicates = [HasVInstructionsAnyF]
-
 // 14. Vector Reduction Operations
 
 // 14.1. Vector Single-Width Integer Reduction Instructions
-let Predicates = [HasVInstructions] in {
 defm : VPatReductionVL<rvv_vecreduce_ADD_vl,  "PseudoVREDSUM", /*is_float*/0>;
 defm : VPatReductionVL<rvv_vecreduce_UMAX_vl, "PseudoVREDMAXU", /*is_float*/0>;
 defm : VPatReductionVL<rvv_vecreduce_SMAX_vl, "PseudoVREDMAX", /*is_float*/0>;
@@ -2110,10 +2215,8 @@ defm : VPatWidenReductionVL<rvv_vecreduce_ADD_vl, zext_oneuse, "PseudoVWREDSUMU"
 defm : VPatWidenReductionVL_Ext_VL<rvv_vecreduce_ADD_vl, riscv_zext_vl_oneuse, "PseudoVWREDSUMU", /*is_float*/0>;
 defm : VPatWidenReductionVL<rvv_vecreduce_ADD_vl, sext_oneuse, "PseudoVWREDSUM", /*is_float*/0>;
 defm : VPatWidenReductionVL_Ext_VL<rvv_vecreduce_ADD_vl, riscv_sext_vl_oneuse, "PseudoVWREDSUM", /*is_float*/0>;
-} // Predicates = [HasVInstructions]
 
 // 14.3. Vector Single-Width Floating-Point Reduction Instructions
-let Predicates = [HasVInstructionsAnyF] in {
 defm : VPatReductionVL<rvv_vecreduce_SEQ_FADD_vl, "PseudoVFREDOSUM", /*is_float*/1>;
 defm : VPatReductionVL<rvv_vecreduce_FADD_vl,     "PseudoVFREDUSUM", /*is_float*/1>;
 defm : VPatReductionVL<rvv_vecreduce_FMIN_vl,     "PseudoVFREDMIN", /*is_float*/1>;
@@ -2124,126 +2227,124 @@ defm : VPatWidenReductionVL<rvv_vecreduce_SEQ_FADD_vl, fpext_oneuse, "PseudoVFWR
 defm : VPatWidenReductionVL_Ext_VL<rvv_vecreduce_SEQ_FADD_vl, riscv_fpextend_vl_oneuse, "PseudoVFWREDOSUM", /*is_float*/1>;
 defm : VPatWidenReductionVL<rvv_vecreduce_FADD_vl, fpext_oneuse, "PseudoVFWREDUSUM", /*is_float*/1>;
 defm : VPatWidenReductionVL_Ext_VL<rvv_vecreduce_FADD_vl, riscv_fpextend_vl_oneuse, "PseudoVFWREDUSUM", /*is_float*/1>;
-} // Predicates = [HasVInstructionsAnyF]
 
 // 15. Vector Mask Instructions
 
-let Predicates = [HasVInstructions] in {
-
 foreach mti = AllMasks in {
-  // 15.1 Vector Mask-Register Logical Instructions
-  def : Pat<(mti.Mask (riscv_vmset_vl VLOpFrag)),
-            (!cast<Instruction>("PseudoVMSET_M_" # mti.BX) GPR:$vl, mti.Log2SEW)>;
-  def : Pat<(mti.Mask (riscv_vmclr_vl VLOpFrag)),
-            (!cast<Instruction>("PseudoVMCLR_M_" # mti.BX) GPR:$vl, mti.Log2SEW)>;
-
-  def : Pat<(mti.Mask (riscv_vmand_vl VR:$rs1, VR:$rs2, VLOpFrag)),
-            (!cast<Instruction>("PseudoVMAND_MM_" # mti.LMul.MX)
-                 VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-  def : Pat<(mti.Mask (riscv_vmor_vl VR:$rs1, VR:$rs2, VLOpFrag)),
-            (!cast<Instruction>("PseudoVMOR_MM_" # mti.LMul.MX)
-                 VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-  def : Pat<(mti.Mask (riscv_vmxor_vl VR:$rs1, VR:$rs2, VLOpFrag)),
-            (!cast<Instruction>("PseudoVMXOR_MM_" # mti.LMul.MX)
-                 VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-
-  def : Pat<(mti.Mask (riscv_vmand_vl VR:$rs1,
-                                      (riscv_vmnot_vl VR:$rs2, VLOpFrag),
+  let Predicates = [HasVInstructions] in {
+    // 15.1 Vector Mask-Register Logical Instructions
+    def : Pat<(mti.Mask (riscv_vmset_vl VLOpFrag)),
+              (!cast<Instruction>("PseudoVMSET_M_" # mti.BX) GPR:$vl, mti.Log2SEW)>;
+    def : Pat<(mti.Mask (riscv_vmclr_vl VLOpFrag)),
+              (!cast<Instruction>("PseudoVMCLR_M_" # mti.BX) GPR:$vl, mti.Log2SEW)>;
+
+    def : Pat<(mti.Mask (riscv_vmand_vl VR:$rs1, VR:$rs2, VLOpFrag)),
+              (!cast<Instruction>("PseudoVMAND_MM_" # mti.LMul.MX)
+                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+    def : Pat<(mti.Mask (riscv_vmor_vl VR:$rs1, VR:$rs2, VLOpFrag)),
+              (!cast<Instruction>("PseudoVMOR_MM_" # mti.LMul.MX)
+                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+    def : Pat<(mti.Mask (riscv_vmxor_vl VR:$rs1, VR:$rs2, VLOpFrag)),
+              (!cast<Instruction>("PseudoVMXOR_MM_" # mti.LMul.MX)
+                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+
+    def : Pat<(mti.Mask (riscv_vmand_vl VR:$rs1,
+                                        (riscv_vmnot_vl VR:$rs2, VLOpFrag),
+                                        VLOpFrag)),
+              (!cast<Instruction>("PseudoVMANDN_MM_" # mti.LMul.MX)
+                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+    def : Pat<(mti.Mask (riscv_vmor_vl VR:$rs1,
+                                       (riscv_vmnot_vl VR:$rs2, VLOpFrag),
+                                       VLOpFrag)),
+              (!cast<Instruction>("PseudoVMORN_MM_" # mti.LMul.MX)
+                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+    // XOR is associative so we need 2 patterns for VMXNOR.
+    def : Pat<(mti.Mask (riscv_vmxor_vl (riscv_vmnot_vl VR:$rs1,
+                                                        VLOpFrag),
+                                       VR:$rs2, VLOpFrag)),
+              (!cast<Instruction>("PseudoVMXNOR_MM_" # mti.LMul.MX)
+                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+
+    def : Pat<(mti.Mask (riscv_vmnot_vl (riscv_vmand_vl VR:$rs1, VR:$rs2,
+                                                        VLOpFrag),
+                                        VLOpFrag)),
+              (!cast<Instruction>("PseudoVMNAND_MM_" # mti.LMul.MX)
+                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+    def : Pat<(mti.Mask (riscv_vmnot_vl (riscv_vmor_vl VR:$rs1, VR:$rs2,
+                                                       VLOpFrag),
+                                        VLOpFrag)),
+              (!cast<Instruction>("PseudoVMNOR_MM_" # mti.LMul.MX)
+                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+    def : Pat<(mti.Mask (riscv_vmnot_vl (riscv_vmxor_vl VR:$rs1, VR:$rs2,
+                                                        VLOpFrag),
+                                        VLOpFrag)),
+              (!cast<Instruction>("PseudoVMXNOR_MM_" # mti.LMul.MX)
+                   VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+
+    // Match the not idiom to the vmnot.m pseudo.
+    def : Pat<(mti.Mask (riscv_vmnot_vl VR:$rs, VLOpFrag)),
+              (!cast<Instruction>("PseudoVMNAND_MM_" # mti.LMul.MX)
+                   VR:$rs, VR:$rs, GPR:$vl, mti.Log2SEW)>;
+
+    // 15.2 Vector count population in mask vcpop.m
+    def : Pat<(XLenVT (riscv_vcpop_vl (mti.Mask VR:$rs2), (mti.Mask true_mask),
                                       VLOpFrag)),
-            (!cast<Instruction>("PseudoVMANDN_MM_" # mti.LMul.MX)
-                 VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-  def : Pat<(mti.Mask (riscv_vmor_vl VR:$rs1,
-                                     (riscv_vmnot_vl VR:$rs2, VLOpFrag),
-                                     VLOpFrag)),
-            (!cast<Instruction>("PseudoVMORN_MM_" # mti.LMul.MX)
-                 VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-  // XOR is associative so we need 2 patterns for VMXNOR.
-  def : Pat<(mti.Mask (riscv_vmxor_vl (riscv_vmnot_vl VR:$rs1,
-                                                      VLOpFrag),
-                                     VR:$rs2, VLOpFrag)),
-            (!cast<Instruction>("PseudoVMXNOR_MM_" # mti.LMul.MX)
-                 VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-
-  def : Pat<(mti.Mask (riscv_vmnot_vl (riscv_vmand_vl VR:$rs1, VR:$rs2,
-                                                      VLOpFrag),
+              (!cast<Instruction>("PseudoVCPOP_M_" # mti.BX)
+                   VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+    def : Pat<(XLenVT (riscv_vcpop_vl (mti.Mask VR:$rs2), (mti.Mask V0),
                                       VLOpFrag)),
-            (!cast<Instruction>("PseudoVMNAND_MM_" # mti.LMul.MX)
-                 VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-  def : Pat<(mti.Mask (riscv_vmnot_vl (riscv_vmor_vl VR:$rs1, VR:$rs2,
-                                                     VLOpFrag),
+              (!cast<Instruction>("PseudoVCPOP_M_" # mti.BX # "_MASK")
+                   VR:$rs2, (mti.Mask V0), GPR:$vl, mti.Log2SEW)>;
+
+    // 15.3 vfirst find-first-set mask bit
+    def : Pat<(XLenVT (riscv_vfirst_vl (mti.Mask VR:$rs2), (mti.Mask true_mask),
                                       VLOpFrag)),
-            (!cast<Instruction>("PseudoVMNOR_MM_" # mti.LMul.MX)
-                 VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-  def : Pat<(mti.Mask (riscv_vmnot_vl (riscv_vmxor_vl VR:$rs1, VR:$rs2,
-                                                      VLOpFrag),
+              (!cast<Instruction>("PseudoVFIRST_M_" # mti.BX)
+                   VR:$rs2, GPR:$vl, mti.Log2SEW)>;
+    def : Pat<(XLenVT (riscv_vfirst_vl (mti.Mask VR:$rs2), (mti.Mask V0),
                                       VLOpFrag)),
-            (!cast<Instruction>("PseudoVMXNOR_MM_" # mti.LMul.MX)
-                 VR:$rs1, VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-
-  // Match the not idiom to the vmnot.m pseudo.
-  def : Pat<(mti.Mask (riscv_vmnot_vl VR:$rs, VLOpFrag)),
-            (!cast<Instruction>("PseudoVMNAND_MM_" # mti.LMul.MX)
-                 VR:$rs, VR:$rs, GPR:$vl, mti.Log2SEW)>;
-
-  // 15.2 Vector count population in mask vcpop.m
-  def : Pat<(XLenVT (riscv_vcpop_vl (mti.Mask VR:$rs2), (mti.Mask true_mask),
-                                    VLOpFrag)),
-            (!cast<Instruction>("PseudoVCPOP_M_" # mti.BX)
-                 VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-  def : Pat<(XLenVT (riscv_vcpop_vl (mti.Mask VR:$rs2), (mti.Mask V0),
-                                    VLOpFrag)),
-            (!cast<Instruction>("PseudoVCPOP_M_" # mti.BX # "_MASK")
-                 VR:$rs2, (mti.Mask V0), GPR:$vl, mti.Log2SEW)>;
-
-  // 15.3 vfirst find-first-set mask bit
-  def : Pat<(XLenVT (riscv_vfirst_vl (mti.Mask VR:$rs2), (mti.Mask true_mask),
-                                    VLOpFrag)),
-            (!cast<Instruction>("PseudoVFIRST_M_" # mti.BX)
-                 VR:$rs2, GPR:$vl, mti.Log2SEW)>;
-  def : Pat<(XLenVT (riscv_vfirst_vl (mti.Mask VR:$rs2), (mti.Mask V0),
-                                    VLOpFrag)),
-            (!cast<Instruction>("PseudoVFIRST_M_" # mti.BX # "_MASK")
-                 VR:$rs2, (mti.Mask V0), GPR:$vl, mti.Log2SEW)>;
-}
-
-} // Predicates = [HasVInstructions]
+              (!cast<Instruction>("PseudoVFIRST_M_" # mti.BX # "_MASK")
+                   VR:$rs2, (mti.Mask V0), GPR:$vl, mti.Log2SEW)>;
+  }
+}
 
 // 16. Vector Permutation Instructions
 
-let Predicates = [HasVInstructions] in {
 // 16.1. Integer Scalar Move Instructions
 // 16.4. Vector Register Gather Instruction
 foreach vti = AllIntegerVectors in {
-  def : Pat<(vti.Vector (riscv_vmv_s_x_vl (vti.Vector vti.RegClass:$merge),
-                                          vti.ScalarRegClass:$rs1,
-                                          VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_S_X_"#vti.LMul.MX)
-                vti.RegClass:$merge,
-                (vti.Scalar vti.ScalarRegClass:$rs1), GPR:$vl, vti.Log2SEW)>;
-
-  def : Pat<(vti.Vector (riscv_vrgather_vv_vl vti.RegClass:$rs2,
-                                              vti.RegClass:$rs1,
-                                              vti.RegClass:$merge,
-                                              (vti.Mask V0),
-                                              VLOpFrag)),
-            (!cast<Instruction>("PseudoVRGATHER_VV_"# vti.LMul.MX#"_E"# vti.SEW#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs2, vti.RegClass:$rs1,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
-  def : Pat<(vti.Vector (riscv_vrgather_vx_vl vti.RegClass:$rs2, GPR:$rs1,
-                                              vti.RegClass:$merge,
-                                              (vti.Mask V0),
-                                              VLOpFrag)),
-            (!cast<Instruction>("PseudoVRGATHER_VX_"# vti.LMul.MX#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs2, GPR:$rs1,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
-  def : Pat<(vti.Vector (riscv_vrgather_vx_vl vti.RegClass:$rs2,
-                                              uimm5:$imm,
-                                              vti.RegClass:$merge,
-                                              (vti.Mask V0),
-                                              VLOpFrag)),
-            (!cast<Instruction>("PseudoVRGATHER_VI_"# vti.LMul.MX#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs2, uimm5:$imm,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(vti.Vector (riscv_vmv_s_x_vl (vti.Vector vti.RegClass:$merge),
+                                            vti.ScalarRegClass:$rs1,
+                                            VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_S_X_"#vti.LMul.MX)
+                  vti.RegClass:$merge,
+                  (vti.Scalar vti.ScalarRegClass:$rs1), GPR:$vl, vti.Log2SEW)>;
+  
+    def : Pat<(vti.Vector (riscv_vrgather_vv_vl vti.RegClass:$rs2,
+                                                vti.RegClass:$rs1,
+                                                vti.RegClass:$merge,
+                                                (vti.Mask V0),
+                                                VLOpFrag)),
+              (!cast<Instruction>("PseudoVRGATHER_VV_"# vti.LMul.MX#"_E"# vti.SEW#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs2, vti.RegClass:$rs1,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    def : Pat<(vti.Vector (riscv_vrgather_vx_vl vti.RegClass:$rs2, GPR:$rs1,
+                                                vti.RegClass:$merge,
+                                                (vti.Mask V0),
+                                                VLOpFrag)),
+              (!cast<Instruction>("PseudoVRGATHER_VX_"# vti.LMul.MX#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs2, GPR:$rs1,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    def : Pat<(vti.Vector (riscv_vrgather_vx_vl vti.RegClass:$rs2,
+                                                uimm5:$imm,
+                                                vti.RegClass:$merge,
+                                                (vti.Mask V0),
+                                                VLOpFrag)),
+              (!cast<Instruction>("PseudoVRGATHER_VI_"# vti.LMul.MX#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs2, uimm5:$imm,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+  }
 
   // emul = lmul * 16 / sew
   defvar vlmul = vti.LMul;
@@ -2253,7 +2354,7 @@ foreach vti = AllIntegerVectors in {
     defvar emul_str = octuple_to_str<octuple_emul>.ret;
     defvar ivti = !cast<VTypeInfo>("VI16" # emul_str);
     defvar inst = "PseudoVRGATHEREI16_VV_" # vti.LMul.MX # "_E" # vti.SEW # "_" # emul_str;
-
+    let Predicates = GetVTypePredicates<vti>.Predicates in
     def : Pat<(vti.Vector
                (riscv_vrgatherei16_vv_vl vti.RegClass:$rs2,
                                          (ivti.Vector ivti.RegClass:$rs1),
@@ -2266,55 +2367,55 @@ foreach vti = AllIntegerVectors in {
   }
 }
 
-} // Predicates = [HasVInstructions]
-
-let Predicates = [HasVInstructionsAnyF] in {
-
 // 16.2. Floating-Point Scalar Move Instructions
 foreach vti = AllFloatVectors in {
-  def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
-                                           (vti.Scalar (fpimm0)),
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_S_X_"#vti.LMul.MX)
-                vti.RegClass:$merge, X0, GPR:$vl, vti.Log2SEW)>;
-  def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
-                                           (vti.Scalar (SelectFPImm (XLenVT GPR:$imm))),
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVMV_S_X_"#vti.LMul.MX)
-                vti.RegClass:$merge, GPR:$imm, GPR:$vl, vti.Log2SEW)>;
-  def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
-                                           vti.ScalarRegClass:$rs1,
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVFMV_S_"#vti.ScalarSuffix#"_"#vti.LMul.MX)
-                vti.RegClass:$merge,
-                (vti.Scalar vti.ScalarRegClass:$rs1), GPR:$vl, vti.Log2SEW)>;
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
+                                             (vti.Scalar (fpimm0)),
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_S_X_"#vti.LMul.MX)
+                  vti.RegClass:$merge, X0, GPR:$vl, vti.Log2SEW)>;
+    def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
+                                             (vti.Scalar (SelectFPImm (XLenVT GPR:$imm))),
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVMV_S_X_"#vti.LMul.MX)
+                  vti.RegClass:$merge, GPR:$imm, GPR:$vl, vti.Log2SEW)>;
+    def : Pat<(vti.Vector (riscv_vfmv_s_f_vl (vti.Vector vti.RegClass:$merge),
+                                             vti.ScalarRegClass:$rs1,
+                                             VLOpFrag)),
+              (!cast<Instruction>("PseudoVFMV_S_"#vti.ScalarSuffix#"_"#vti.LMul.MX)
+                  vti.RegClass:$merge,
+                  (vti.Scalar vti.ScalarRegClass:$rs1), GPR:$vl, vti.Log2SEW)>;
+  }
   defvar ivti = GetIntVTypeInfo<vti>.Vti;
-
-  def : Pat<(vti.Vector
-             (riscv_vrgather_vv_vl vti.RegClass:$rs2,
-                                   (ivti.Vector vti.RegClass:$rs1),
-                                   vti.RegClass:$merge,
-                                   (vti.Mask V0),
-                                   VLOpFrag)),
-            (!cast<Instruction>("PseudoVRGATHER_VV_"# vti.LMul.MX#"_E"# vti.SEW#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs2, vti.RegClass:$rs1,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
-  def : Pat<(vti.Vector (riscv_vrgather_vx_vl vti.RegClass:$rs2, GPR:$rs1,
-                                              vti.RegClass:$merge,
-                                              (vti.Mask V0),
-                                              VLOpFrag)),
-            (!cast<Instruction>("PseudoVRGATHER_VX_"# vti.LMul.MX#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs2, GPR:$rs1,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
-  def : Pat<(vti.Vector
-             (riscv_vrgather_vx_vl vti.RegClass:$rs2,
-                                   uimm5:$imm,
-                                   vti.RegClass:$merge,
-                                   (vti.Mask V0),
-                                   VLOpFrag)),
-            (!cast<Instruction>("PseudoVRGATHER_VI_"# vti.LMul.MX#"_MASK")
-                 vti.RegClass:$merge, vti.RegClass:$rs2, uimm5:$imm,
-                 (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+  let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                               GetVTypePredicates<ivti>.Predicates) in {
+    def : Pat<(vti.Vector
+               (riscv_vrgather_vv_vl vti.RegClass:$rs2,
+                                     (ivti.Vector vti.RegClass:$rs1),
+                                     vti.RegClass:$merge,
+                                     (vti.Mask V0),
+                                     VLOpFrag)),
+              (!cast<Instruction>("PseudoVRGATHER_VV_"# vti.LMul.MX#"_E"# vti.SEW#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs2, vti.RegClass:$rs1,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    def : Pat<(vti.Vector (riscv_vrgather_vx_vl vti.RegClass:$rs2, GPR:$rs1,
+                                                vti.RegClass:$merge,
+                                                (vti.Mask V0),
+                                                VLOpFrag)),
+              (!cast<Instruction>("PseudoVRGATHER_VX_"# vti.LMul.MX#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs2, GPR:$rs1,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+    def : Pat<(vti.Vector
+               (riscv_vrgather_vx_vl vti.RegClass:$rs2,
+                                     uimm5:$imm,
+                                     vti.RegClass:$merge,
+                                     (vti.Mask V0),
+                                     VLOpFrag)),
+              (!cast<Instruction>("PseudoVRGATHER_VI_"# vti.LMul.MX#"_MASK")
+                   vti.RegClass:$merge, vti.RegClass:$rs2, uimm5:$imm,
+                   (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>;
+  }
 
   defvar vlmul = vti.LMul;
   defvar octuple_lmul = vlmul.octuple;
@@ -2323,7 +2424,8 @@ foreach vti = AllFloatVectors in {
     defvar emul_str = octuple_to_str<octuple_emul>.ret;
     defvar ivti = !cast<VTypeInfo>("VI16" # emul_str);
     defvar inst = "PseudoVRGATHEREI16_VV_" # vti.LMul.MX # "_E" # vti.SEW # "_" # emul_str;
-
+    let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
+                                 GetVTypePredicates<ivti>.Predicates) in
     def : Pat<(vti.Vector
                (riscv_vrgatherei16_vv_vl vti.RegClass:$rs2,
                                          (ivti.Vector ivti.RegClass:$rs1),
@@ -2336,8 +2438,6 @@ foreach vti = AllFloatVectors in {
   }
 }
 
-} // Predicates = [HasVInstructionsAnyF]
-
 //===----------------------------------------------------------------------===//
 // Miscellaneous RISCVISD SDNodes
 //===----------------------------------------------------------------------===//
@@ -2362,71 +2462,71 @@ def riscv_slide1up_vl  : SDNode<"RISCVISD::VSLIDE1UP_VL", SDTRVVSlide1, []>;
 def riscv_slidedown_vl : SDNode<"RISCVISD::VSLIDEDOWN_VL", SDTRVVSlide, []>;
 def riscv_slide1down_vl  : SDNode<"RISCVISD::VSLIDE1DOWN_VL", SDTRVVSlide1, []>;
 
-let Predicates = [HasVInstructions] in {
-
 foreach vti = AllIntegerVectors in {
-  def : Pat<(vti.Vector (riscv_vid_vl (vti.Mask true_mask),
-                                      VLOpFrag)),
-            (!cast<Instruction>("PseudoVID_V_"#vti.LMul.MX) GPR:$vl, vti.Log2SEW)>;
-
-  def : Pat<(vti.Vector (riscv_slide1up_vl (vti.Vector undef),
-                                           (vti.Vector vti.RegClass:$rs1),
-                                           GPR:$rs2, (vti.Mask true_mask),
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVSLIDE1UP_VX_"#vti.LMul.MX)
-                vti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
-  def : Pat<(vti.Vector (riscv_slide1up_vl (vti.Vector vti.RegClass:$rd),
-                                           (vti.Vector vti.RegClass:$rs1),
-                                           GPR:$rs2, (vti.Mask true_mask),
-                                           VLOpFrag)),
-            (!cast<Instruction>("PseudoVSLIDE1UP_VX_"#vti.LMul.MX#"_TU")
-                vti.RegClass:$rd, vti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
-  def : Pat<(vti.Vector (riscv_slide1down_vl (vti.Vector undef),
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(vti.Vector (riscv_vid_vl (vti.Mask true_mask),
+                                        VLOpFrag)),
+              (!cast<Instruction>("PseudoVID_V_"#vti.LMul.MX) GPR:$vl, vti.Log2SEW)>;
+
+    def : Pat<(vti.Vector (riscv_slide1up_vl (vti.Vector undef),
                                              (vti.Vector vti.RegClass:$rs1),
                                              GPR:$rs2, (vti.Mask true_mask),
                                              VLOpFrag)),
-            (!cast<Instruction>("PseudoVSLIDE1DOWN_VX_"#vti.LMul.MX)
-                vti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
-  def : Pat<(vti.Vector (riscv_slide1down_vl (vti.Vector vti.RegClass:$rd),
+              (!cast<Instruction>("PseudoVSLIDE1UP_VX_"#vti.LMul.MX)
+                  vti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
+    def : Pat<(vti.Vector (riscv_slide1up_vl (vti.Vector vti.RegClass:$rd),
                                              (vti.Vector vti.RegClass:$rs1),
                                              GPR:$rs2, (vti.Mask true_mask),
                                              VLOpFrag)),
-            (!cast<Instruction>("PseudoVSLIDE1DOWN_VX_"#vti.LMul.MX#"_TU")
-                vti.RegClass:$rd, vti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
+              (!cast<Instruction>("PseudoVSLIDE1UP_VX_"#vti.LMul.MX#"_TU")
+                  vti.RegClass:$rd, vti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
+    def : Pat<(vti.Vector (riscv_slide1down_vl (vti.Vector undef),
+                                               (vti.Vector vti.RegClass:$rs1),
+                                               GPR:$rs2, (vti.Mask true_mask),
+                                               VLOpFrag)),
+              (!cast<Instruction>("PseudoVSLIDE1DOWN_VX_"#vti.LMul.MX)
+                  vti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
+    def : Pat<(vti.Vector (riscv_slide1down_vl (vti.Vector vti.RegClass:$rd),
+                                               (vti.Vector vti.RegClass:$rs1),
+                                               GPR:$rs2, (vti.Mask true_mask),
+                                               VLOpFrag)),
+              (!cast<Instruction>("PseudoVSLIDE1DOWN_VX_"#vti.LMul.MX#"_TU")
+                  vti.RegClass:$rd, vti.RegClass:$rs1, GPR:$rs2, GPR:$vl, vti.Log2SEW)>;
+  }
 }
 
 foreach vti = AllVectors in {
-  def : Pat<(vti.Vector (riscv_slideup_vl (vti.Vector vti.RegClass:$rs3),
-                                          (vti.Vector vti.RegClass:$rs1),
-                                          uimm5:$rs2, (vti.Mask true_mask),
-                                          VLOpFrag, (XLenVT timm:$policy))),
-            (!cast<Instruction>("PseudoVSLIDEUP_VI_"#vti.LMul.MX)
-                vti.RegClass:$rs3, vti.RegClass:$rs1, uimm5:$rs2,
-                GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
-
-  def : Pat<(vti.Vector (riscv_slideup_vl (vti.Vector vti.RegClass:$rs3),
-                                          (vti.Vector vti.RegClass:$rs1),
-                                          GPR:$rs2, (vti.Mask true_mask),
-                                          VLOpFrag, (XLenVT timm:$policy))),
-            (!cast<Instruction>("PseudoVSLIDEUP_VX_"#vti.LMul.MX)
-                vti.RegClass:$rs3, vti.RegClass:$rs1, GPR:$rs2,
-                GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
-
-  def : Pat<(vti.Vector (riscv_slidedown_vl (vti.Vector vti.RegClass:$rs3),
+  let Predicates = GetVTypePredicates<vti>.Predicates in {
+    def : Pat<(vti.Vector (riscv_slideup_vl (vti.Vector vti.RegClass:$rs3),
                                             (vti.Vector vti.RegClass:$rs1),
                                             uimm5:$rs2, (vti.Mask true_mask),
                                             VLOpFrag, (XLenVT timm:$policy))),
-            (!cast<Instruction>("PseudoVSLIDEDOWN_VI_"#vti.LMul.MX)
-                vti.RegClass:$rs3, vti.RegClass:$rs1, uimm5:$rs2,
-                GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
+              (!cast<Instruction>("PseudoVSLIDEUP_VI_"#vti.LMul.MX)
+                  vti.RegClass:$rs3, vti.RegClass:$rs1, uimm5:$rs2,
+                  GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
 
-  def : Pat<(vti.Vector (riscv_slidedown_vl (vti.Vector vti.RegClass:$rs3),
+    def : Pat<(vti.Vector (riscv_slideup_vl (vti.Vector vti.RegClass:$rs3),
                                             (vti.Vector vti.RegClass:$rs1),
                                             GPR:$rs2, (vti.Mask true_mask),
                                             VLOpFrag, (XLenVT timm:$policy))),
-            (!cast<Instruction>("PseudoVSLIDEDOWN_VX_"#vti.LMul.MX)
-                vti.RegClass:$rs3, vti.RegClass:$rs1, GPR:$rs2,
-                GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
+              (!cast<Instruction>("PseudoVSLIDEUP_VX_"#vti.LMul.MX)
+                  vti.RegClass:$rs3, vti.RegClass:$rs1, GPR:$rs2,
+                  GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
+
+    def : Pat<(vti.Vector (riscv_slidedown_vl (vti.Vector vti.RegClass:$rs3),
+                                              (vti.Vector vti.RegClass:$rs1),
+                                              uimm5:$rs2, (vti.Mask true_mask),
+                                              VLOpFrag, (XLenVT timm:$policy))),
+              (!cast<Instruction>("PseudoVSLIDEDOWN_VI_"#vti.LMul.MX)
+                  vti.RegClass:$rs3, vti.RegClass:$rs1, uimm5:$rs2,
+                  GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
+
+    def : Pat<(vti.Vector (riscv_slidedown_vl (vti.Vector vti.RegClass:$rs3),
+                                              (vti.Vector vti.RegClass:$rs1),
+                                              GPR:$rs2, (vti.Mask true_mask),
+                                              VLOpFrag, (XLenVT timm:$policy))),
+              (!cast<Instruction>("PseudoVSLIDEDOWN_VX_"#vti.LMul.MX)
+                  vti.RegClass:$rs3, vti.RegClass:$rs1, GPR:$rs2,
+                  GPR:$vl, vti.Log2SEW, (XLenVT timm:$policy))>;
+  }
 }
-
-} // Predicates = [HasVInstructions]


        


More information about the llvm-commits mailing list