[VPlan] Introduce VPValue::hasDefiningRecipe helper (NFC).
authorFlorian Hahn <flo@fhahn.com>
Wed, 16 Nov 2022 23:12:40 +0000 (23:12 +0000)
committerFlorian Hahn <flo@fhahn.com>
Wed, 16 Nov 2022 23:12:40 +0000 (23:12 +0000)
This clarifies the intention of code that uses the helper.

Suggested by @Ayal during review of D136068, thanks!

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
llvm/lib/Transforms/Vectorize/VPlanValue.h

index 99e7f59..ba10a47 100644 (file)
@@ -9656,7 +9656,7 @@ void VPReplicateRecipe::execute(VPTransformState &State) {
 
   // A store of a loop varying value to a loop invariant address only
   // needs only the last copy of the store.
-  if (isa<StoreInst>(UI) && !getOperand(1)->getDefiningRecipe()) {
+  if (isa<StoreInst>(UI) && !getOperand(1)->hasDefiningRecipe()) {
     auto Lane = VPLane::getLastLaneForVF(State.VF);
     State.ILV->scalarizeInstruction(UI, this, VPIteration(State.UF - 1, Lane), IsPredicated,
                                     State);
index d4e8d86..01b616f 100644 (file)
@@ -210,7 +210,7 @@ VPBasicBlock::iterator VPBasicBlock::getFirstNonPhi() {
 }
 
 Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {
-  if (!Def->getDefiningRecipe())
+  if (!Def->hasDefiningRecipe())
     return Def->getLiveInIRValue();
 
   if (hasScalarValue(Def, Instance)) {
index 010ada4..39f28f8 100644 (file)
@@ -723,7 +723,7 @@ bool VPScalarIVStepsRecipe::isCanonical() const {
   if (CanIV->getStartValue() != getStartValue())
     return false;
   auto *StepVPV = getStepValue();
-  if (StepVPV->getDefiningRecipe())
+  if (StepVPV->hasDefiningRecipe())
     return false;
   auto *StepC = dyn_cast_or_null<ConstantInt>(StepVPV->getLiveInIRValue());
   return StepC && StepC->isOne();
index 35d8854..7df99dd 100644 (file)
@@ -187,16 +187,19 @@ public:
   VPRecipeBase *getDefiningRecipe();
   const VPRecipeBase *getDefiningRecipe() const;
 
+  /// Returns true if this VPValue is defined by a recipe.
+  bool hasDefiningRecipe() const { return getDefiningRecipe(); }
+
   /// Returns the underlying IR value, if this VPValue is defined outside the
   /// scope of VPlan. Returns nullptr if the VPValue is defined by a VPDef
   /// inside a VPlan.
   Value *getLiveInIRValue() {
-    assert(!getDefiningRecipe() &&
+    assert(!hasDefiningRecipe() &&
            "VPValue is not a live-in; it is defined by a VPDef inside a VPlan");
     return getUnderlyingValue();
   }
   const Value *getLiveInIRValue() const {
-    assert(!getDefiningRecipe() &&
+    assert(!hasDefiningRecipe() &&
            "VPValue is not a live-in; it is defined by a VPDef inside a VPlan");
     return getUnderlyingValue();
   }
@@ -204,7 +207,7 @@ public:
   /// Returns true if the VPValue is defined outside any vector regions, i.e. it
   /// is a live-in value.
   /// TODO: Also handle recipes defined in pre-header blocks.
-  bool isDefinedOutsideVectorRegions() const { return !getDefiningRecipe(); }
+  bool isDefinedOutsideVectorRegions() const { return !hasDefiningRecipe(); }
 };
 
 typedef DenseMap<Value *, VPValue *> Value2VPValueTy;