diff options
author | Jiangning Liu <jiangning.liu@arm.com> | 2014-08-11 05:02:04 +0000 |
---|---|---|
committer | Jiangning Liu <jiangning.liu@arm.com> | 2014-08-11 05:02:04 +0000 |
commit | 40b04fd9943857f5e17287ef517a92b59d69a0fe (patch) | |
tree | 22e6ff916416cc197a86df88a6d4f17352136bf1 /llvm/lib/Analysis/LazyValueInfo.cpp | |
parent | 941a5709dc4f03ed00273cb2ea7dca91e960de45 (diff) | |
download | bcm5719-llvm-40b04fd9943857f5e17287ef517a92b59d69a0fe.tar.gz bcm5719-llvm-40b04fd9943857f5e17287ef517a92b59d69a0fe.zip |
In LVI(Lazy Value Info), originally value on a BB can only be caculated once,
and the lattice will be updated to be a state other than "undefined". This
limiation could miss some opportunities of lowering "overdefined" to be an
even accurate value. So this patch ask the algorithm to try to lower the
lattice value again even if the value has been lowered to be "overdefined".
llvm-svn: 215343
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LazyValueInfo.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 9f919f7644a..281ff89bfe4 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -500,8 +500,23 @@ bool LazyValueInfoCache::solveBlockValue(Value *Val, BasicBlock *BB) { // cache needs updating, i.e. if we have solve a new value or not. OverDefinedCacheUpdater ODCacheUpdater(Val, BB, BBLV, this); - // If we've already computed this block's value, return it. - if (!BBLV.isUndefined()) { + // Once this BB is encountered, Val's value for this BB will not be Undefined + // any longer. When we encounter this BB again, if Val's value is Overdefined, + // we need to compute its value again. + // + // For example, considering this control flow, + // BB1->BB2, BB1->BB3, BB2->BB3, BB2->BB4 + // + // Suppose we have "icmp slt %v, 0" in BB1, and "icmp sgt %v, 0" in BB3. At + // the very beginning, when analyzing edge BB2->BB3, we don't know %v's value + // in BB2, and the data flow algorithm tries to compute BB2's predecessors, so + // then we know %v has negative value on edge BB1->BB2. And then we return to + // check BB2 again, and at this moment BB2 has Overdefined value for %v in + // BB2. So we should have to follow data flow propagation algorithm to get the + // value on edge BB1->BB2 propagated to BB2, and finally %v on BB2 has a + // constant range describing a negative value. + + if (!BBLV.isUndefined() && !BBLV.isOverdefined()) { DEBUG(dbgs() << " reuse BB '" << BB->getName() << "' val=" << BBLV <<'\n'); // Since we're reusing a cached value here, we don't need to update the |