[llvm] [GVN] Look through select/phi when determining underlying object (PR #99509)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 02:04:19 PDT 2024
================
@@ -6609,6 +6609,46 @@ void llvm::getUnderlyingObjects(const Value *V,
} while (!Worklist.empty());
}
+const Value *llvm::getUnderlyingObjectAggressive(const Value *V) {
+ 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);
+
+ if (!FirstObject)
+ FirstObject = P;
----------------
goldsteinn wrote:
Not the nicest but:
```
auto SetNextP = [&]() -> bool {
if(Worklist.empty())
return false;
P = getUnderlyingObject(Worklist.pop_back_val());
return true;
};
FirstObject = P = getUnderlyingObject(V);
do {
if (!Visited.insert(P).second)
...
} while(SetNextP());
```
https://github.com/llvm/llvm-project/pull/99509
More information about the llvm-commits
mailing list