summaryrefslogtreecommitdiff
path: root/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-09-05 23:45:58 +0000
committerManman Ren <mren@apple.com>2012-09-05 23:45:58 +0000
commit408853ea162b6b68d3e8defc7f96afad1942dd11 (patch)
tree14430b8ff00bb49d4f3a09a909130da5b023e990 /lib/Analysis/LazyValueInfo.cpp
parentec65be84cd630d53233e7a37f0ef9d2303ac5153 (diff)
downloadllvm-408853ea162b6b68d3e8defc7f96afad1942dd11.tar.gz
llvm-408853ea162b6b68d3e8defc7f96afad1942dd11.tar.bz2
llvm-408853ea162b6b68d3e8defc7f96afad1942dd11.tar.xz
JumpThreading: when default destination is the destination of some cases in a
switch, make sure we include the value for the cases when calculating edge value from switch to the default destination. rdar://12241132 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163270 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--lib/Analysis/LazyValueInfo.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp
index c2306b4e9c..ec618fad22 100644
--- a/lib/Analysis/LazyValueInfo.cpp
+++ b/lib/Analysis/LazyValueInfo.cpp
@@ -847,9 +847,12 @@ static bool getEdgeValueLocal(Value *Val, BasicBlock *BBFrom,
for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end();
i != e; ++i) {
ConstantRange EdgeVal(i.getCaseValue()->getValue());
- if (DefaultCase)
- EdgesVals = EdgesVals.difference(EdgeVal);
- else if (i.getCaseSuccessor() == BBTo)
+ if (DefaultCase) {
+ // It is possible that the default destination is the destination of
+ // some cases. There is no need to perform difference for those cases.
+ if (i.getCaseSuccessor() != BBTo)
+ EdgesVals = EdgesVals.difference(EdgeVal);
+ } else if (i.getCaseSuccessor() == BBTo)
EdgesVals = EdgesVals.unionWith(EdgeVal);
}
Result = LVILatticeVal::getRange(EdgesVals);