From 75047577d6518bad5be84ec75ece8f8425148d33 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 29 Mar 2022 07:43:30 +0100 Subject: [PATCH] [RISCV] Trim RVV isel pats matchable via DAG post-process In D122512, several masked patterns were added to support lowering of vector-predicated float-to-int and int-to-float conversions. With the introduction of these patterns, all of the old "unmasked" patterns are matchable via the DAG post-process introduced in D118810, once the relevant opcode entries are set up in the helper table. Locally this reduces the generated isel table by 4%. Reviewed By: arcbbb Differential Revision: https://reviews.llvm.org/D122637 --- llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td | 6 ++- llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td | 44 ---------------------- 2 files changed, 5 insertions(+), 45 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td index b6b3226..687ccd5 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -2102,6 +2102,7 @@ multiclass PseudoVEXT_VF2 { Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; def "_" # m.MX # "_MASK" : VPseudoUnaryMaskTA, + RISCVMaskedPseudo, Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; } } @@ -2118,6 +2119,7 @@ multiclass PseudoVEXT_VF4 { Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; def "_" # m.MX # "_MASK" : VPseudoUnaryMaskTA, + RISCVMaskedPseudo, Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; } } @@ -2134,6 +2136,7 @@ multiclass PseudoVEXT_VF8 { Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; def "_" # m.MX # "_MASK" : VPseudoUnaryMaskTA, + RISCVMaskedPseudo, Sched<[WriteVExtV, ReadVExtV, ReadVMask]>; } } @@ -2669,7 +2672,8 @@ multiclass VPseudoConversion; def "_" # MInfo.MX # "_TU": VPseudoUnaryNoMaskTU; def "_" # MInfo.MX # "_MASK" : VPseudoUnaryMaskTA; + Constraint>, + RISCVMaskedPseudo; } } diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td index 03fce13..5b54fd8 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td @@ -550,10 +550,6 @@ multiclass VPatExtendSDNode_V_VL(inst_name#"_"#suffix#"_"#vti.LMul.MX) - fti.RegClass:$rs2, GPR:$vl, vti.Log2SEW)>; - def : Pat<(vti.Vector (vop (fti.Vector fti.RegClass:$rs2), (fti.Mask V0), VLOpFrag)), (!cast(inst_name#"_"#suffix#"_"#vti.LMul.MX#"_MASK") (vti.Vector (IMPLICIT_DEF)), @@ -566,11 +562,6 @@ multiclass VPatConvertFP2ISDNode_V_VL { foreach fvti = AllFloatVectors in { defvar ivti = GetIntVTypeInfo.Vti; def : Pat<(ivti.Vector (vop (fvti.Vector fvti.RegClass:$rs1), - (fvti.Mask true_mask), - VLOpFrag)), - (!cast(instruction_name#"_"#ivti.LMul.MX) - fvti.RegClass:$rs1, GPR:$vl, ivti.Log2SEW)>; - def : Pat<(ivti.Vector (vop (fvti.Vector fvti.RegClass:$rs1), (fvti.Mask V0), VLOpFrag)), (!cast(instruction_name#"_"#ivti.LMul.MX#"_MASK") @@ -583,11 +574,6 @@ multiclass VPatConvertI2FPSDNode_V_VL { foreach fvti = AllFloatVectors in { defvar ivti = GetIntVTypeInfo.Vti; def : Pat<(fvti.Vector (vop (ivti.Vector ivti.RegClass:$rs1), - (ivti.Mask true_mask), - VLOpFrag)), - (!cast(instruction_name#"_"#fvti.LMul.MX) - ivti.RegClass:$rs1, GPR:$vl, fvti.Log2SEW)>; - def : Pat<(fvti.Vector (vop (ivti.Vector ivti.RegClass:$rs1), (ivti.Mask V0), VLOpFrag)), (!cast(instruction_name#"_"#fvti.LMul.MX#"_MASK") @@ -601,11 +587,6 @@ multiclass VPatWConvertFP2ISDNode_V_VL { defvar fvti = fvtiToFWti.Vti; defvar iwti = GetIntVTypeInfo.Vti; def : Pat<(iwti.Vector (vop (fvti.Vector fvti.RegClass:$rs1), - (fvti.Mask true_mask), - VLOpFrag)), - (!cast(instruction_name#"_"#fvti.LMul.MX) - fvti.RegClass:$rs1, GPR:$vl, fvti.Log2SEW)>; - def : Pat<(iwti.Vector (vop (fvti.Vector fvti.RegClass:$rs1), (fvti.Mask V0), VLOpFrag)), (!cast(instruction_name#"_"#fvti.LMul.MX#"_MASK") @@ -619,11 +600,6 @@ multiclass VPatWConvertI2FPSDNode_V_VL { defvar ivti = vtiToWti.Vti; defvar fwti = vtiToWti.Wti; def : Pat<(fwti.Vector (vop (ivti.Vector ivti.RegClass:$rs1), - (ivti.Mask true_mask), - VLOpFrag)), - (!cast(instruction_name#"_"#ivti.LMul.MX) - ivti.RegClass:$rs1, GPR:$vl, ivti.Log2SEW)>; - def : Pat<(fwti.Vector (vop (ivti.Vector ivti.RegClass:$rs1), (ivti.Mask V0), VLOpFrag)), (!cast(instruction_name#"_"#ivti.LMul.MX#"_MASK") @@ -637,11 +613,6 @@ multiclass VPatNConvertFP2ISDNode_V_VL { defvar vti = vtiToWti.Vti; defvar fwti = vtiToWti.Wti; def : Pat<(vti.Vector (vop (fwti.Vector fwti.RegClass:$rs1), - (fwti.Mask true_mask), - VLOpFrag)), - (!cast(instruction_name#"_"#vti.LMul.MX) - fwti.RegClass:$rs1, GPR:$vl, vti.Log2SEW)>; - def : Pat<(vti.Vector (vop (fwti.Vector fwti.RegClass:$rs1), (fwti.Mask V0), VLOpFrag)), (!cast(instruction_name#"_"#vti.LMul.MX#"_MASK") @@ -655,11 +626,6 @@ multiclass VPatNConvertI2FPSDNode_V_VL { defvar fvti = fvtiToFWti.Vti; defvar iwti = GetIntVTypeInfo.Vti; def : Pat<(fvti.Vector (vop (iwti.Vector iwti.RegClass:$rs1), - (iwti.Mask true_mask), - VLOpFrag)), - (!cast(instruction_name#"_"#fvti.LMul.MX) - iwti.RegClass:$rs1, GPR:$vl, fvti.Log2SEW)>; - def : Pat<(fvti.Vector (vop (iwti.Vector iwti.RegClass:$rs1), (iwti.Mask V0), VLOpFrag)), (!cast(instruction_name#"_"#fvti.LMul.MX#"_MASK") @@ -1548,11 +1514,6 @@ foreach fvti = AllFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar fwti = fvtiToFWti.Wti; def : Pat<(fwti.Vector (riscv_fpextend_vl (fvti.Vector fvti.RegClass:$rs1), - (fvti.Mask true_mask), - VLOpFrag)), - (!cast("PseudoVFWCVT_F_F_V_"#fvti.LMul.MX) - fvti.RegClass:$rs1, GPR:$vl, fvti.Log2SEW)>; - def : Pat<(fwti.Vector (riscv_fpextend_vl (fvti.Vector fvti.RegClass:$rs1), (fvti.Mask V0), VLOpFrag)), (!cast("PseudoVFWCVT_F_F_V_"#fvti.LMul.MX#"_MASK") @@ -1569,11 +1530,6 @@ foreach fvti = AllFloatVectors in { defvar fvti = fvtiToFWti.Vti; defvar fwti = fvtiToFWti.Wti; def : Pat<(fvti.Vector (riscv_fpround_vl (fwti.Vector fwti.RegClass:$rs1), - (fwti.Mask true_mask), - VLOpFrag)), - (!cast("PseudoVFNCVT_F_F_W_"#fvti.LMul.MX) - fwti.RegClass:$rs1, GPR:$vl, fvti.Log2SEW)>; - def : Pat<(fvti.Vector (riscv_fpround_vl (fwti.Vector fwti.RegClass:$rs1), (fwti.Mask V0), VLOpFrag)), (!cast("PseudoVFNCVT_F_F_W_"#fvti.LMul.MX#"_MASK") -- 2.7.4