From 23f4f66da7c0ed83f3435cb8e87f54740c9fb3c3 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Thu, 15 Dec 2022 11:09:49 -0800 Subject: [PATCH] [RISCV][InsertVSETVL] Incorporate demanded fields into compatibility interface [nfc] This reworks the API to explicitly pass in the demanded fields instead of requering them internally. At the moment, this is NFC, but it will stop being so in future changes which adjust the demanded bits in the caller. --- llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp index 62a92ab26bd7..dddcd5dcf7fa 100644 --- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp +++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp @@ -399,16 +399,15 @@ public: MaskAgnostic == Other.MaskAgnostic; } - bool hasCompatibleVTYPE(const MachineInstr &MI, + bool hasCompatibleVTYPE(const DemandedFields &Used, const VSETVLIInfo &Require) const { - const DemandedFields Used = getDemanded(MI); return areCompatibleVTYPEs(encodeVTYPE(), Require.encodeVTYPE(), Used); } // Determine whether the vector instructions requirements represented by // Require are compatible with the previous vsetvli instruction represented // by this. MI is the instruction whose requirements we're considering. - bool isCompatible(const MachineInstr &MI, const VSETVLIInfo &Require) const { + bool isCompatible(const DemandedFields &Used, const VSETVLIInfo &Require) const { assert(isValid() && Require.isValid() && "Can't compare invalid VSETVLIInfos"); assert(!Require.SEWLMULRatioOnly && @@ -427,7 +426,10 @@ public: if (SEW == Require.SEW) return true; - return hasSameAVL(Require) && hasCompatibleVTYPE(MI, Require); + // TODO: Check Used.VL here + if (!hasSameAVL(Require)) + return false; + return areCompatibleVTYPEs(encodeVTYPE(), Require.encodeVTYPE(), Used); } bool operator==(const VSETVLIInfo &Other) const { @@ -774,7 +776,8 @@ bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI, if (!CurInfo.isValid() || CurInfo.isUnknown() || CurInfo.hasSEWLMULRatioOnly()) return true; - if (CurInfo.isCompatible(MI, Require)) + const DemandedFields Used = getDemanded(MI); + if (CurInfo.isCompatible(Used, Require)) return false; // For vmv.s.x and vfmv.s.f, there is only two behaviors, VL = 0 and VL > 0. @@ -795,7 +798,7 @@ bool RISCVInsertVSETVLI::needVSETVLI(const MachineInstr &MI, // and the last VL/VTYPE we observed is the same, we don't need a // VSETVLI here. if (Require.hasAVLReg() && Require.getAVLReg().isVirtual() && - CurInfo.hasCompatibleVTYPE(MI, Require)) { + CurInfo.hasCompatibleVTYPE(Used, Require)) { if (MachineInstr *DefMI = MRI->getVRegDef(Require.getAVLReg())) { if (isVectorConfigInstr(*DefMI)) { VSETVLIInfo DefInfo = getInfoForVSETVLI(*DefMI); -- 2.34.1