Skip to content

Commit 8ca7e24

Browse files
committed
[RISCV] Add more vector setcc VI isel patterns.
Add more patterns isel patterns for vmseq.vi and friends with the constant splat on the left hand side. We can't trust the canonicalization in SimplifySetCC to keep constants to the RHS when the splat is VMV_V_X_VL for i64 on RV32.
1 parent 6d26e57 commit 8ca7e24

File tree

2 files changed

+128
-200
lines changed

2 files changed

+128
-200
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,6 @@ multiclass VPatIntegerSetCCSDNode_VV_Swappable<string instruction_name,
306306
}
307307
}
308308

309-
multiclass VPatIntegerSetCCSDNode_XI<
310-
string instruction_name,
311-
CondCode cc,
312-
string kind,
313-
ComplexPattern SplatPatKind,
314-
DAGOperand xop_kind> {
315-
foreach vti = AllIntegerVectors in {
316-
defvar instruction = !cast<Instruction>(instruction_name#_#kind#_#vti.LMul.MX);
317-
let Predicates = GetVTypePredicates<vti>.Predicates in
318-
def : Pat<(vti.Mask (setcc (vti.Vector vti.RegClass:$rs1),
319-
(vti.Vector (SplatPatKind (XLenVT xop_kind:$rs2))), cc)),
320-
(instruction vti.RegClass:$rs1, xop_kind:$rs2, vti.AVL, vti.Log2SEW)>;
321-
}
322-
}
323-
324309
multiclass VPatIntegerSetCCSDNode_XI_Swappable<string instruction_name,
325310
CondCode cc, CondCode invcc,
326311
string kind,
@@ -344,19 +329,28 @@ multiclass VPatIntegerSetCCSDNode_VX_Swappable<string instruction_name,
344329
: VPatIntegerSetCCSDNode_XI_Swappable<instruction_name, cc, invcc, "VX",
345330
SplatPat, GPR>;
346331

347-
multiclass VPatIntegerSetCCSDNode_VI<string instruction_name, CondCode cc>
348-
: VPatIntegerSetCCSDNode_XI<instruction_name, cc, "VI", SplatPat_simm5, simm5>;
332+
multiclass VPatIntegerSetCCSDNode_VI_Swappable<string instruction_name,
333+
CondCode cc, CondCode invcc>
334+
: VPatIntegerSetCCSDNode_XI_Swappable<instruction_name, cc, invcc, "VI",
335+
SplatPat_simm5, simm5>;
349336

350-
multiclass VPatIntegerSetCCSDNode_VIPlus1<string instruction_name, CondCode cc,
351-
ComplexPattern splatpat_kind> {
337+
multiclass VPatIntegerSetCCSDNode_VIPlus1_Swappable<string instruction_name,
338+
CondCode cc, CondCode invcc,
339+
ComplexPattern splatpat_kind> {
352340
foreach vti = AllIntegerVectors in {
353341
defvar instruction = !cast<Instruction>(instruction_name#"_VI_"#vti.LMul.MX);
354-
let Predicates = GetVTypePredicates<vti>.Predicates in
355-
def : Pat<(vti.Mask (setcc (vti.Vector vti.RegClass:$rs1),
356-
(vti.Vector (splatpat_kind simm5:$rs2)),
357-
cc)),
358-
(instruction vti.RegClass:$rs1, (DecImm simm5:$rs2),
359-
vti.AVL, vti.Log2SEW)>;
342+
let Predicates = GetVTypePredicates<vti>.Predicates in {
343+
def : Pat<(vti.Mask (setcc (vti.Vector vti.RegClass:$rs1),
344+
(vti.Vector (splatpat_kind simm5:$rs2)),
345+
cc)),
346+
(instruction vti.RegClass:$rs1, (DecImm simm5:$rs2),
347+
vti.AVL, vti.Log2SEW)>;
348+
def : Pat<(vti.Mask (setcc (vti.Vector (splatpat_kind simm5:$rs2)),
349+
(vti.Vector vti.RegClass:$rs1),
350+
invcc)),
351+
(instruction vti.RegClass:$rs1, (DecImm simm5:$rs2),
352+
vti.AVL, vti.Log2SEW)>;
353+
}
360354
}
361355
}
362356

@@ -1045,21 +1039,21 @@ defm : VPatIntegerSetCCSDNode_VX_Swappable<"PseudoVMSGT", SETGT, SETLT>;
10451039
defm : VPatIntegerSetCCSDNode_VX_Swappable<"PseudoVMSGTU", SETUGT, SETULT>;
10461040
// There is no VMSGE(U)_VX instruction
10471041

1048-
defm : VPatIntegerSetCCSDNode_VI<"PseudoVMSEQ", SETEQ>;
1049-
defm : VPatIntegerSetCCSDNode_VI<"PseudoVMSNE", SETNE>;
1050-
defm : VPatIntegerSetCCSDNode_VI<"PseudoVMSLE", SETLE>;
1051-
defm : VPatIntegerSetCCSDNode_VI<"PseudoVMSLEU", SETULE>;
1052-
defm : VPatIntegerSetCCSDNode_VI<"PseudoVMSGT", SETGT>;
1053-
defm : VPatIntegerSetCCSDNode_VI<"PseudoVMSGTU", SETUGT>;
1054-
1055-
defm : VPatIntegerSetCCSDNode_VIPlus1<"PseudoVMSLE", SETLT,
1056-
SplatPat_simm5_plus1>;
1057-
defm : VPatIntegerSetCCSDNode_VIPlus1<"PseudoVMSLEU", SETULT,
1058-
SplatPat_simm5_plus1_nonzero>;
1059-
defm : VPatIntegerSetCCSDNode_VIPlus1<"PseudoVMSGT", SETGE,
1060-
SplatPat_simm5_plus1>;
1061-
defm : VPatIntegerSetCCSDNode_VIPlus1<"PseudoVMSGTU", SETUGE,
1062-
SplatPat_simm5_plus1_nonzero>;
1042+
defm : VPatIntegerSetCCSDNode_VI_Swappable<"PseudoVMSEQ", SETEQ, SETEQ>;
1043+
defm : VPatIntegerSetCCSDNode_VI_Swappable<"PseudoVMSNE", SETNE, SETNE>;
1044+
defm : VPatIntegerSetCCSDNode_VI_Swappable<"PseudoVMSLE", SETLE, SETGE>;
1045+
defm : VPatIntegerSetCCSDNode_VI_Swappable<"PseudoVMSLEU", SETULE, SETUGE>;
1046+
defm : VPatIntegerSetCCSDNode_VI_Swappable<"PseudoVMSGT", SETGT, SETLT>;
1047+
defm : VPatIntegerSetCCSDNode_VI_Swappable<"PseudoVMSGTU", SETUGT, SETULT>;
1048+
1049+
defm : VPatIntegerSetCCSDNode_VIPlus1_Swappable<"PseudoVMSLE", SETLT, SETGT,
1050+
SplatPat_simm5_plus1>;
1051+
defm : VPatIntegerSetCCSDNode_VIPlus1_Swappable<"PseudoVMSLEU", SETULT, SETUGT,
1052+
SplatPat_simm5_plus1_nonzero>;
1053+
defm : VPatIntegerSetCCSDNode_VIPlus1_Swappable<"PseudoVMSGT", SETGE, SETLE,
1054+
SplatPat_simm5_plus1>;
1055+
defm : VPatIntegerSetCCSDNode_VIPlus1_Swappable<"PseudoVMSGTU", SETUGE, SETULE,
1056+
SplatPat_simm5_plus1_nonzero>;
10631057

10641058
// 11.9. Vector Integer Min/Max Instructions
10651059
defm : VPatBinarySDNode_VV_VX<umin, "PseudoVMINU">;

0 commit comments

Comments
 (0)