Skip to content

Commit 20e6166

Browse files
committed
[RISCV] Don't increase vslide or splat vl if +minimize-vl is present
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 2f06e88 commit 20e6166

File tree

3 files changed

+683
-312
lines changed

3 files changed

+683
-312
lines changed

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,12 @@ 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 +vl-dependent-latency
426427
if (RISCVInstrInfo::isVSlideInstr(MI) && VLOp.isImm() &&
427-
VLOp.getImm() == 1 && hasUndefinedPassthru(MI)) {
428+
VLOp.getImm() == 1 && hasUndefinedPassthru(MI) &&
429+
!ST->hasVLDependentLatency()) {
428430
Res.VLAny = false;
429431
Res.VLZeroness = true;
430432
Res.LMUL = DemandedFields::LMULLessThanOrEqualToM1;
@@ -438,7 +440,8 @@ DemandedFields getDemanded(const MachineInstr &MI, const RISCVSubtarget *ST) {
438440
// careful to not increase the number of active vector registers (unlike for
439441
// vmv.s.x.)
440442
if (RISCVInstrInfo::isScalarSplatInstr(MI) && VLOp.isImm() &&
441-
VLOp.getImm() == 1 && hasUndefinedPassthru(MI)) {
443+
VLOp.getImm() == 1 && hasUndefinedPassthru(MI) &&
444+
!ST->hasVLDependentLatency()) {
442445
Res.LMUL = DemandedFields::LMULLessThanOrEqualToM1;
443446
Res.SEWLMULRatio = false;
444447
Res.VLAny = false;

0 commit comments

Comments
 (0)