diff options
author | Yingwei Zheng <dtcxzyw2333@gmail.com> | 2025-02-23 17:52:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-23 17:52:38 +0800 |
commit | 2071ea24a27c7009feac699e3e70ee50f185134f (patch) | |
tree | a31fd87cc6cf255d0487471fba2deee94f2a83d7 /llvm/lib/Analysis/LazyValueInfo.cpp | |
parent | 96c723374a28c0f81e4a9512a48b784db0bf4cd0 (diff) | |
download | llvm-2071ea24a27c7009feac699e3e70ee50f185134f.zip llvm-2071ea24a27c7009feac699e3e70ee50f185134f.tar.gz llvm-2071ea24a27c7009feac699e3e70ee50f185134f.tar.bz2 |
[LVI] Skip self loops in `solveBlockValueNonLocal` (#127763)
We cannot infer more information from backedges in
`solveBlockValueNonLocal`. However, since DT is unavailable in LVI,
there is not a precise way to check whether a BB edge is a backedge.
This patch only skips self loops to unblock the range analysis.
The motivating case is extracted from
https://github.com/llvm/llvm-project/pull/127663.
Compile-time impact is high:
https://llvm-compile-time-tracker.com/compare.php?from=84ddda58c870681dd12ed765e9d59d5e00567f94&to=af032f1351358f2f5b5d9f4e87c5601c23b9bd37&stat=instructions:u
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LazyValueInfo.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 5cd179d..581358a 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -694,6 +694,9 @@ LazyValueInfoImpl::solveBlockValueNonLocal(Value *Val, BasicBlock *BB) { // canonicalizing to make this true rather than relying on this happy // accident. for (BasicBlock *Pred : predecessors(BB)) { + // Skip self loops. + if (Pred == BB) + continue; std::optional<ValueLatticeElement> EdgeResult = getEdgeValue(Val, Pred, BB); if (!EdgeResult) // Explore that input, then return here |