[llvm] [GVN] Look through select/phi when determining underlying object (PR #99509)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 10:19:22 PDT 2024


================
@@ -6609,6 +6609,47 @@ void llvm::getUnderlyingObjects(const Value *V,
   } while (!Worklist.empty());
 }
 
+const Value *llvm::getUnderlyingObjectAggressive(const Value *V,
+                                                 unsigned MaxLookup) {
+  const unsigned MaxVisited = 8;
+
+  SmallPtrSet<const Value *, 8> Visited;
+  SmallVector<const Value *, 8> Worklist;
+  Worklist.push_back(V);
+  const Value *Object = nullptr, *FirstObject = nullptr;
+  do {
+    const Value *P = Worklist.pop_back_val();
+    P = getUnderlyingObject(P, MaxLookup);
----------------
tschuett wrote:

Do you need a budget for the second parameter? We could end up with `MaxVisited * MaxLookup` .

https://github.com/llvm/llvm-project/pull/99509


More information about the llvm-commits mailing list