summaryrefslogtreecommitdiff
path: root/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-05-18 21:02:10 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-05-18 21:02:10 +0000
commit90255a85172a560da73e05dad6cdb77d8e9480e1 (patch)
tree20619d25896f15f71bb948d4a58a3e6f0ab3b233 /lib/Analysis/LazyValueInfo.cpp
parent3e96531186ba574b0c25a4be62d24b8b7d752c9f (diff)
downloadllvm-90255a85172a560da73e05dad6cdb77d8e9480e1.tar.gz
llvm-90255a85172a560da73e05dad6cdb77d8e9480e1.tar.bz2
llvm-90255a85172a560da73e05dad6cdb77d8e9480e1.tar.xz
allow LazyValueInfo::getEdgeValue() to reason about multiple edges from the same switch instruction by doing union of ranges (which may still be conservative, but it's more aggressive than before)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--lib/Analysis/LazyValueInfo.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp
index 83e021295b..7539d93862 100644
--- a/lib/Analysis/LazyValueInfo.cpp
+++ b/lib/Analysis/LazyValueInfo.cpp
@@ -862,21 +862,16 @@ bool LazyValueInfoCache::getEdgeValue(Value *Val, BasicBlock *BBFrom,
return true;
}
- // We only know something if there is exactly one value that goes from
- // BBFrom to BBTo.
- unsigned NumEdges = 0;
- ConstantInt *EdgeVal = 0;
+ unsigned BitWidth = Val->getType()->getIntegerBitWidth();
+ ConstantRange EdgesVals(BitWidth, false/*isFullSet*/);
for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end();
i != e; ++i) {
if (i.getCaseSuccessor() != BBTo) continue;
- if (NumEdges++) break;
- EdgeVal = i.getCaseValue();
- }
- assert(EdgeVal && "Missing successor?");
- if (NumEdges == 1) {
- Result = LVILatticeVal::get(EdgeVal);
- return true;
+ ConstantRange EdgeVal(i.getCaseValue()->getValue());
+ EdgesVals = EdgesVals.unionWith(EdgeVal);
}
+ Result = LVILatticeVal::getRange(EdgesVals);
+ return true;
}
}