[PATCH] D131989: [VPlan] Verify that header only contains header phi recipes.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 27 14:06:31 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7743badafa68: [VPlan] Verify that header only contains header phi recipes. (authored by fhahn).
Herald added a subscriber: pcwang-thead.

Changed prior to commit:
  https://reviews.llvm.org/D131989?vs=453099&id=456149#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131989/new/

https://reviews.llvm.org/D131989

Files:
  llvm/lib/Transforms/Vectorize/VPlan.h
  llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp


Index: llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
+++ llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
@@ -133,17 +133,38 @@
   verifyRegionRec(TopRegion);
 }
 
-static bool
-verifyVPBasicBlock(const VPBasicBlock *VPBB,
-                   DenseMap<const VPBlockBase *, unsigned> &BlockNumbering) {
-  // Verify that phi-like recipes are at the beginning of the block, with no
-  // other recipes in between.
+// Verify that phi-like recipes are at the beginning of \p VPBB, with no
+// other recipes in between. Also check that only header blocks contain
+// VPHeaderPHIRecipes.
+static bool verifyPhiRecipes(const VPBasicBlock *VPBB) {
   auto RecipeI = VPBB->begin();
   auto End = VPBB->end();
   unsigned NumActiveLaneMaskPhiRecipes = 0;
+  const VPRegionBlock *ParentR = VPBB->getParent();
+  bool IsHeaderVPBB = ParentR && !ParentR->isReplicator() &&
+                      ParentR->getEntryBasicBlock() == VPBB;
   while (RecipeI != End && RecipeI->isPhi()) {
     if (isa<VPActiveLaneMaskPHIRecipe>(RecipeI))
       NumActiveLaneMaskPhiRecipes++;
+
+    if (IsHeaderVPBB && !isa<VPHeaderPHIRecipe>(*RecipeI)) {
+      errs() << "Found non-header PHI recipe in header VPBB";
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+      errs() << ": ";
+      RecipeI->dump();
+#endif
+      return false;
+    }
+
+    if (!IsHeaderVPBB && isa<VPHeaderPHIRecipe>(*RecipeI)) {
+      errs() << "Found header PHI recipe in non-header VPBB";
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+      errs() << ": ";
+      RecipeI->dump();
+#endif
+      return false;
+    }
+
     RecipeI++;
   }
 
@@ -166,6 +187,14 @@
     }
     RecipeI++;
   }
+  return true;
+}
+
+static bool
+verifyVPBasicBlock(const VPBasicBlock *VPBB,
+                   DenseMap<const VPBlockBase *, unsigned> &BlockNumbering) {
+  if (!verifyPhiRecipes(VPBB))
+    return false;
 
   // Verify that defs in VPBB dominate all their uses. The current
   // implementation is still incomplete.
Index: llvm/lib/Transforms/Vectorize/VPlan.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlan.h
+++ llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1139,6 +1139,7 @@
            B->getVPDefID() == VPRecipeBase::VPFirstOrderRecurrencePHISC ||
            B->getVPDefID() == VPRecipeBase::VPReductionPHISC ||
            B->getVPDefID() == VPRecipeBase::VPWidenIntOrFpInductionSC ||
+           B->getVPDefID() == VPRecipeBase::VPWidenPointerInductionSC ||
            B->getVPDefID() == VPRecipeBase::VPWidenPHISC;
   }
   static inline bool classof(const VPValue *V) {
@@ -1147,6 +1148,7 @@
            V->getVPValueID() == VPValue::VPVFirstOrderRecurrencePHISC ||
            V->getVPValueID() == VPValue::VPVReductionPHISC ||
            V->getVPValueID() == VPValue::VPVWidenIntOrFpInductionSC ||
+           V->getVPValueID() == VPValue::VPVWidenPointerInductionSC ||
            V->getVPValueID() == VPValue::VPVWidenPHISC;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131989.456149.patch
Type: text/x-patch
Size: 3087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220827/31c9ea2e/attachment.bin>


More information about the llvm-commits mailing list