[RISCV] Inline one copy of needVSETVLI into the other [NFC]

Calling the non-MI version directly was unsound (as fixed in dcdb0bf2), so remove that version to decrease likelyhood of future mistakes.
This commit is contained in:
Philip Reames 2022-06-02 13:04:13 -07:00 committed by Philip Reames
parent 6bea9ff913
commit 76ac916d63
1 changed files with 18 additions and 27 deletions

View File

@ -453,8 +453,6 @@ public:
StringRef getPassName() const override { return RISCV_INSERT_VSETVLI_NAME; } StringRef getPassName() const override { return RISCV_INSERT_VSETVLI_NAME; }
private: private:
bool needVSETVLI(const VSETVLIInfo &Require,
const VSETVLIInfo &CurInfo) const;
bool needVSETVLI(const MachineInstr &MI, const VSETVLIInfo &Require, bool needVSETVLI(const MachineInstr &MI, const VSETVLIInfo &Require,
const VSETVLIInfo &CurInfo) const; const VSETVLIInfo &CurInfo) const;
bool needVSETVLIPHI(const VSETVLIInfo &Require, bool needVSETVLIPHI(const VSETVLIInfo &Require,
@ -718,30 +716,6 @@ static VSETVLIInfo getInfoForVSETVLI(const MachineInstr &MI) {
return NewInfo; return NewInfo;
} }
bool RISCVInsertVSETVLI::needVSETVLI(const VSETVLIInfo &Require,
const VSETVLIInfo &CurInfo) const {
if (CurInfo.isCompatible(Require))
return false;
// We didn't find a compatible value. If our AVL is a virtual register,
// it might be defined by a VSET(I)VLI. If it has the same VLMAX we need
// and the last VL/VTYPE we observed is the same, we don't need a
// VSETVLI here.
if (!CurInfo.isUnknown() && Require.hasAVLReg() &&
Require.getAVLReg().isVirtual() && !CurInfo.hasSEWLMULRatioOnly() &&
CurInfo.hasCompatibleVTYPE(Require)) {
if (MachineInstr *DefMI = MRI->getVRegDef(Require.getAVLReg())) {
if (isVectorConfigInstr(*DefMI)) {
VSETVLIInfo DefInfo = getInfoForVSETVLI(*DefMI);
if (DefInfo.hasSameAVL(CurInfo) && DefInfo.hasSameVLMAX(CurInfo))
return false;
}
}
}
return true;
}
bool canSkipVSETVLIForLoadStore(const MachineInstr &MI, bool canSkipVSETVLIForLoadStore(const MachineInstr &MI,
const VSETVLIInfo &Require, const VSETVLIInfo &Require,
const VSETVLIInfo &CurInfo) { const VSETVLIInfo &CurInfo) {
@ -940,8 +914,25 @@ bool canSkipVSETVLIForLoadStore(const MachineInstr &MI,
bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI, const VSETVLIInfo &Require, bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI, const VSETVLIInfo &Require,
const VSETVLIInfo &CurInfo) const { const VSETVLIInfo &CurInfo) const {
if (!needVSETVLI(Require, CurInfo)) if (CurInfo.isCompatible(Require))
return false; return false;
// We didn't find a compatible value. If our AVL is a virtual register,
// it might be defined by a VSET(I)VLI. If it has the same VLMAX we need
// and the last VL/VTYPE we observed is the same, we don't need a
// VSETVLI here.
if (!CurInfo.isUnknown() && Require.hasAVLReg() &&
Require.getAVLReg().isVirtual() && !CurInfo.hasSEWLMULRatioOnly() &&
CurInfo.hasCompatibleVTYPE(Require)) {
if (MachineInstr *DefMI = MRI->getVRegDef(Require.getAVLReg())) {
if (isVectorConfigInstr(*DefMI)) {
VSETVLIInfo DefInfo = getInfoForVSETVLI(*DefMI);
if (DefInfo.hasSameAVL(CurInfo) && DefInfo.hasSameVLMAX(CurInfo))
return false;
}
}
}
// If this is a unit-stride or strided load/store, we may be able to use the // If this is a unit-stride or strided load/store, we may be able to use the
// EMUL=(EEW/SEW)*LMUL relationship to avoid changing VTYPE. // EMUL=(EEW/SEW)*LMUL relationship to avoid changing VTYPE.
return !canSkipVSETVLIForLoadStore(MI, Require, CurInfo); return !canSkipVSETVLIForLoadStore(MI, Require, CurInfo);