[PATCH] D78133: [PredicateInfo] Optionally set OriginalOp to renamed value it refers to.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 10:48:43 PDT 2020


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

Rebase and add new option the PredicateInfo to configure renaming behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78133

Files:
  llvm/include/llvm/Transforms/Utils/PredicateInfo.h
  llvm/lib/Transforms/Utils/PredicateInfo.cpp


Index: llvm/lib/Transforms/Utils/PredicateInfo.cpp
===================================================================
--- llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -271,6 +271,11 @@
   // edges.
   DenseSet<std::pair<BasicBlock *, BasicBlock *>> EdgeUsesOnly;
 
+  // If set to true, the directly renamed value is used as OriginalOp, rather
+  // than the original IR value that has been renamed. This is only relevant for
+  // nested predicates of the same value.
+  bool UseDirectRenamedValue;
+
   ValueInfo &getOrCreateValueInfo(Value *);
   const ValueInfo &getValueInfo(Value *) const;
 
@@ -292,8 +297,9 @@
 
 public:
   PredicateInfoBuilder(PredicateInfo &PI, Function &F, DominatorTree &DT,
-                       AssumptionCache &AC)
-      : PI(PI), F(F), DT(DT), AC(AC) {
+                       AssumptionCache &AC, bool UseDirectRenamedValue)
+      : PI(PI), F(F), DT(DT), AC(AC),
+        UseDirectRenamedValue(UseDirectRenamedValue) {
     // Push an empty operand info so that we can detect 0 as not finding one
     ValueInfos.resize(1);
   }
@@ -600,6 +606,11 @@
         RenameIter == RenameStack.begin() ? OrigOp : (RenameIter - 1)->Def;
     ValueDFS &Result = *RenameIter;
     auto *ValInfo = Result.PInfo;
+    // Update OriginalOp to latest entry on the rename stack.
+    if (UseDirectRenamedValue)
+      ValInfo->OriginalOp = (RenameStack.end() - Start) == RenameStack.begin()
+                                ? OrigOp
+                                : (RenameStack.end() - Start - 1)->Def;
     // For edge predicates, we can just place the operand in the block before
     // the terminator.  For assume, we have to place it right before the assume
     // to ensure we dominate all of our uses.  Always insert right before the
@@ -794,9 +805,9 @@
 }
 
 PredicateInfo::PredicateInfo(Function &F, DominatorTree &DT,
-                             AssumptionCache &AC)
+                             AssumptionCache &AC, bool UseDirectRenamedValue)
     : F(F) {
-  PredicateInfoBuilder Builder(*this, F, DT, AC);
+  PredicateInfoBuilder Builder(*this, F, DT, AC, UseDirectRenamedValue);
   Builder.buildPredicateInfo();
 }
 
Index: llvm/include/llvm/Transforms/Utils/PredicateInfo.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/PredicateInfo.h
+++ llvm/include/llvm/Transforms/Utils/PredicateInfo.h
@@ -169,7 +169,8 @@
 /// accesses.
 class PredicateInfo {
 public:
-  PredicateInfo(Function &, DominatorTree &, AssumptionCache &);
+  PredicateInfo(Function &, DominatorTree &, AssumptionCache &,
+                bool UseDirectRenamedValue = false);
   ~PredicateInfo();
 
   void verifyPredicateInfo() const;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78133.274866.patch
Type: text/x-patch
Size: 2759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200701/728a77e2/attachment-0001.bin>


More information about the llvm-commits mailing list