Skip to content

Commit 766d27d

Browse files
committed
[RISCV] Add isel patterns to handle vrsub intrinsic with 2 vector operands.
This occurs when we type legalize an i64 scalar input on RV32. We need to manually splat, which requires a vector input. Rather than special case this in lowering just pattern match it.
1 parent 17800f9 commit 766d27d

File tree

2 files changed

+398
-0
lines changed

2 files changed

+398
-0
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3279,6 +3279,30 @@ defm PseudoVSUB : VPseudoBinaryV_VV_VX;
32793279
defm PseudoVRSUB : VPseudoBinaryV_VX_VI;
32803280

32813281
foreach vti = AllIntegerVectors in {
3282+
// Match vrsub with 2 vector operands to vsub.vv by swapping operands. This
3283+
// Occurs when legalizing vrsub.vx intrinsics for i64 on RV32 since we need
3284+
// to use a more complex splat sequence. Add the pattern for all VTs for
3285+
// consistency.
3286+
def : Pat<(vti.Vector (int_riscv_vrsub (vti.Vector vti.RegClass:$rs2),
3287+
(vti.Vector vti.RegClass:$rs1),
3288+
(XLenVT (VLOp GPR:$vl)))),
3289+
(!cast<Instruction>("PseudoVSUB_VV_"#vti.LMul.MX) vti.RegClass:$rs1,
3290+
vti.RegClass:$rs2,
3291+
GPR:$vl,
3292+
vti.SEW)>;
3293+
def : Pat<(vti.Vector (int_riscv_vrsub_mask (vti.Vector vti.RegClass:$merge),
3294+
(vti.Vector vti.RegClass:$rs2),
3295+
(vti.Vector vti.RegClass:$rs1),
3296+
(vti.Mask V0),
3297+
(XLenVT (VLOp GPR:$vl)))),
3298+
(!cast<Instruction>("PseudoVSUB_VV_"#vti.LMul.MX#"_MASK")
3299+
vti.RegClass:$merge,
3300+
vti.RegClass:$rs1,
3301+
vti.RegClass:$rs2,
3302+
(vti.Mask V0),
3303+
GPR:$vl,
3304+
vti.SEW)>;
3305+
32823306
// Match VSUB with a small immediate to vadd.vi by negating the immediate.
32833307
def : Pat<(vti.Vector (int_riscv_vsub (vti.Vector vti.RegClass:$rs1),
32843308
(vti.Scalar simm5_plus1:$rs2),

0 commit comments

Comments
 (0)