aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2010-03-23 16:58:02 +0000
committerTanya Lattner <tonic@nondot.org>2010-03-23 16:58:02 +0000
commit434622b0d1a25a8675a80cf3b8f16114027e5cee (patch)
tree3b6c73cf77f80818121c35396444c7d2f5d18085
parent4fb33339923a8ba101b8b6d8bb8b1d1225aec46b (diff)
Merge r98416 from mainline.
Fix a typo in ValueTracking that's causing instcombine to delete needed shift instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_27@99289 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/ValueTracking.cpp2
-rw-r--r--test/Transforms/InstCombine/shift-sra.ll20
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index 92cbb7c95c..5ae72f7aba 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -779,7 +779,7 @@ unsigned llvm::ComputeNumSignBits(Value *V, const TargetData *TD,
for (unsigned i = 1, e = PN->getNumIncomingValues(); i != e; ++i) {
if (Tmp == 1) return Tmp;
Tmp = std::min(Tmp,
- ComputeNumSignBits(PN->getIncomingValue(1), TD, Depth+1));
+ ComputeNumSignBits(PN->getIncomingValue(i), TD, Depth+1));
}
return Tmp;
}
diff --git a/test/Transforms/InstCombine/shift-sra.ll b/test/Transforms/InstCombine/shift-sra.ll
index 58f322635c..a578bbe4d4 100644
--- a/test/Transforms/InstCombine/shift-sra.ll
+++ b/test/Transforms/InstCombine/shift-sra.ll
@@ -56,3 +56,23 @@ C:
; CHECK: %P = phi i64
; CHECK-NEXT: ret i64 %P
}
+
+; rdar://7732987
+define i32 @test5(i32 %Y) {
+ br i1 undef, label %A, label %C
+A:
+ br i1 undef, label %B, label %D
+B:
+ br label %D
+C:
+ br i1 undef, label %D, label %E
+D:
+ %P = phi i32 [0, %A], [0, %B], [%Y, %C]
+ %S = ashr i32 %P, 16
+ ret i32 %S
+; CHECK: @test5
+; CHECK: %P = phi i32
+; CHECK-NEXT: ashr i32 %P, 16
+E:
+ ret i32 0
+}