Skip to content

Commit f9b45f0

Browse files
committed
[RISCV] Don't increase vslide or splat vl if +minimize-vl is present
Stacked on #146746 If the subtarget's latency is dependent on vl, then we shouldn't try to fold away vsetvli toggles if it means increasing vl.
1 parent 3787cad commit f9b45f0

File tree

3 files changed

+681
-312
lines changed

3 files changed

+681
-312
lines changed

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,11 @@ DemandedFields getDemanded(const MachineInstr &MI, const RISCVSubtarget *ST) {
421421
// * We can't modify SEW here since the slide amount is in units of SEW.
422422
// * VL=1 is special only because we have existing support for zero vs
423423
// non-zero VL. We could generalize this if we had a VL > C predicate.
424-
// * The LMUL1 restriction is for machines whose latency may depend on VL.
424+
// * The LMUL1 restriction is for machines whose latency may depend on LMUL.
425425
// * As above, this is only legal for tail "undefined" not "agnostic".
426+
// * We avoid increasing vl if the subtarget has +minimize-vl
426427
if (RISCVInstrInfo::isVSlideInstr(MI) && VLOp.isImm() &&
427-
VLOp.getImm() == 1 && hasUndefinedPassthru(MI)) {
428+
VLOp.getImm() == 1 && hasUndefinedPassthru(MI) && !ST->minimizeVL()) {
428429
Res.VLAny = false;
429430
Res.VLZeroness = true;
430431
Res.LMUL = DemandedFields::LMULLessThanOrEqualToM1;
@@ -438,7 +439,7 @@ DemandedFields getDemanded(const MachineInstr &MI, const RISCVSubtarget *ST) {
438439
// careful to not increase the number of active vector registers (unlike for
439440
// vmv.s.x.)
440441
if (RISCVInstrInfo::isScalarSplatInstr(MI) && VLOp.isImm() &&
441-
VLOp.getImm() == 1 && hasUndefinedPassthru(MI)) {
442+
VLOp.getImm() == 1 && hasUndefinedPassthru(MI) && !ST->minimizeVL()) {
442443
Res.LMUL = DemandedFields::LMULLessThanOrEqualToM1;
443444
Res.SEWLMULRatio = false;
444445
Res.VLAny = false;

0 commit comments

Comments
 (0)