[llvm] 23f4f66 - [RISCV][InsertVSETVL] Incorporate demanded fields into compatibility interface [nfc]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 11:11:23 PST 2022


Author: Philip Reames
Date: 2022-12-15T11:11:09-08:00
New Revision: 23f4f66da7c0ed83f3435cb8e87f54740c9fb3c3

URL: https://github.com/llvm/llvm-project/commit/23f4f66da7c0ed83f3435cb8e87f54740c9fb3c3
DIFF: https://github.com/llvm/llvm-project/commit/23f4f66da7c0ed83f3435cb8e87f54740c9fb3c3.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Removed: 
    


################################################################################
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 @@ class VSETVLIInfo {
            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 @@ class VSETVLIInfo {
       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);


        


More information about the llvm-commits mailing list