Skip to content

Commit a621896

Browse files
committed
Rebase, carry over the EEW check added in llvm#101152
Since we don't have access to the MVTs, we can also do the same thing by checking the VLMAXs are the same (i.e. the sew/lmul ratio)
1 parent 957d7f5 commit a621896

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

llvm/lib/Target/RISCV/RISCVVectorPeephole.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ lookupActiveElementsAffectsResult(const MachineInstr &MI) {
373373
return Info->ActiveElementsAffectResult;
374374
}
375375

376+
static unsigned getSEWLMULRatio(const MachineInstr &MI) {
377+
RISCVII::VLMUL LMUL = RISCVII::getLMul(MI.getDesc().TSFlags);
378+
unsigned Log2SEW = MI.getOperand(RISCVII::getSEWOpNum(MI.getDesc())).getImm();
379+
return RISCVVType::getSEWLMULRatio(1 << Log2SEW, LMUL);
380+
}
381+
376382
/// If a PseudoVMV_V_V is the only user of its input, fold its passthru and VL
377383
/// into it.
378384
///
@@ -399,6 +405,10 @@ bool RISCVVectorPeephole::foldVMV_V_V(MachineInstr &MI) {
399405
!RISCVII::hasVecPolicyOp(Src->getDesc().TSFlags))
400406
return false;
401407

408+
// Src needs to have the same VLMAX as MI
409+
if (getSEWLMULRatio(MI) != getSEWLMULRatio(*Src))
410+
return false;
411+
402412
// Src needs to have the same passthru as VMV_V_V
403413
if (Src->getOperand(1).getReg() != RISCV::NoRegister &&
404414
Src->getOperand(1).getReg() != Passthru.getReg())

0 commit comments

Comments
 (0)