Skip to content

Commit 18d41ba

Browse files
committed
Merge r98416 from mainline.
Fix a typo in ValueTracking that's causing instcombine to delete needed shift instructions. llvm-svn: 99289
1 parent 6fa2343 commit 18d41ba

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ unsigned llvm::ComputeNumSignBits(Value *V, const TargetData *TD,
779779
for (unsigned i = 1, e = PN->getNumIncomingValues(); i != e; ++i) {
780780
if (Tmp == 1) return Tmp;
781781
Tmp = std::min(Tmp,
782-
ComputeNumSignBits(PN->getIncomingValue(1), TD, Depth+1));
782+
ComputeNumSignBits(PN->getIncomingValue(i), TD, Depth+1));
783783
}
784784
return Tmp;
785785
}

llvm/test/Transforms/InstCombine/shift-sra.ll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,23 @@ C:
5656
; CHECK: %P = phi i64
5757
; CHECK-NEXT: ret i64 %P
5858
}
59+
60+
; rdar://7732987
61+
define i32 @test5(i32 %Y) {
62+
br i1 undef, label %A, label %C
63+
A:
64+
br i1 undef, label %B, label %D
65+
B:
66+
br label %D
67+
C:
68+
br i1 undef, label %D, label %E
69+
D:
70+
%P = phi i32 [0, %A], [0, %B], [%Y, %C]
71+
%S = ashr i32 %P, 16
72+
ret i32 %S
73+
; CHECK: @test5
74+
; CHECK: %P = phi i32
75+
; CHECK-NEXT: ashr i32 %P, 16
76+
E:
77+
ret i32 0
78+
}

0 commit comments

Comments
 (0)