[PATCH] D92281: [VPlan] Add getOutOfScopeIRValue accessor to VPValue.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 5 06:02:43 PST 2021


fhahn updated this revision to Diff 314583.
fhahn added a comment.

Thanks for taking a look!

In D92281#2479130 <https://reviews.llvm.org/D92281#2479130>, @Ayal wrote:

>> This currently requires giving access to VPValue to those classes, so we
>> can call the protected constructor. But most of them can be removed in
>> the future, once the remaining single value def recipes inherit from
>> VPValue.
>
> Such access seems unneeded as commented below; but in general may have been better to handle these remaining recipes first and avoid multiple befriendings, albeit temporary.

Yes, originally this was not checking for VPDef, because when I posted the patch initially I did not want to block it on completing the transition. But that is done now, so just checking `Def` is much simpler.

I updated the code to just check VPDef (no need to befriend classes) and removed the function to getLiveInIRValue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92281

Files:
  llvm/lib/Transforms/Vectorize/VPlan.h
  llvm/lib/Transforms/Vectorize/VPlanValue.h


Index: llvm/lib/Transforms/Vectorize/VPlanValue.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -35,7 +35,6 @@
 class VPSlotTracker;
 class VPUser;
 class VPRecipeBase;
-class VPPredInstPHIRecipe;
 class VPWidenMemoryInstructionRecipe;
 
 // This is the base class of the VPlan Def/Use graph, used for modeling the data
@@ -51,7 +50,6 @@
   friend class VPInterleavedAccessInfo;
   friend class VPSlotTracker;
   friend class VPRecipeBase;
-  friend class VPPredInstPHIRecipe;
   friend class VPWidenMemoryInstructionRecipe;
 
   const unsigned char SubclassID; ///< Subclass identifier (for isa/dyn_cast).
@@ -168,6 +166,13 @@
   void replaceAllUsesWith(VPValue *New);
 
   VPDef *getDef() { return Def; }
+
+  /// 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() {
+    return !getDef() ? getUnderlyingValue() : nullptr;
+  }
 };
 
 typedef DenseMap<Value *, VPValue *> Value2VPValueTy;
Index: llvm/lib/Transforms/Vectorize/VPlan.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlan.h
+++ llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1224,7 +1224,7 @@
   /// nodes after merging back from a Branch-on-Mask.
   VPPredInstPHIRecipe(VPValue *PredV)
       : VPRecipeBase(VPPredInstPHISC), VPUser(PredV) {
-    new VPValue(VPValue::VPValueSC, PredV->getUnderlyingValue(), this);
+    new VPValue(PredV->getUnderlyingValue(), this);
   }
   ~VPPredInstPHIRecipe() override = default;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92281.314583.patch
Type: text/x-patch
Size: 1707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210105/6f352eb2/attachment.bin>


More information about the llvm-commits mailing list