[SimplifyLibCalls] Remove useless bits of this tests.
[oota-llvm.git] / test / Transforms / InstCombine / lshr-phi.ll
1 ; RUN: opt < %s -instcombine -S > %t
2 ; RUN: not grep lshr %t
3 ; RUN: grep add %t | count 1
4
5 ; Instcombine should be able to eliminate the lshr, because only
6 ; bits in the operand which might be non-zero will be shifted
7 ; off the end.
8
9 define i32 @hash_string(i8* nocapture %key) nounwind readonly {
10 entry:
11         %t0 = load i8, i8* %key, align 1                ; <i8> [#uses=1]
12         %t1 = icmp eq i8 %t0, 0         ; <i1> [#uses=1]
13         br i1 %t1, label %bb2, label %bb
14
15 bb:             ; preds = %bb, %entry
16         %indvar = phi i64 [ 0, %entry ], [ %tmp, %bb ]          ; <i64> [#uses=2]
17         %k.04 = phi i32 [ 0, %entry ], [ %t8, %bb ]             ; <i32> [#uses=2]
18         %cp.05 = getelementptr i8, i8* %key, i64 %indvar                ; <i8*> [#uses=1]
19         %t2 = shl i32 %k.04, 1          ; <i32> [#uses=1]
20         %t3 = lshr i32 %k.04, 14                ; <i32> [#uses=1]
21         %t4 = add i32 %t2, %t3          ; <i32> [#uses=1]
22         %t5 = load i8, i8* %cp.05, align 1              ; <i8> [#uses=1]
23         %t6 = sext i8 %t5 to i32                ; <i32> [#uses=1]
24         %t7 = xor i32 %t6, %t4          ; <i32> [#uses=1]
25         %t8 = and i32 %t7, 16383                ; <i32> [#uses=2]
26         %tmp = add i64 %indvar, 1               ; <i64> [#uses=2]
27         %scevgep = getelementptr i8, i8* %key, i64 %tmp         ; <i8*> [#uses=1]
28         %t9 = load i8, i8* %scevgep, align 1            ; <i8> [#uses=1]
29         %t10 = icmp eq i8 %t9, 0                ; <i1> [#uses=1]
30         br i1 %t10, label %bb2, label %bb
31
32 bb2:            ; preds = %bb, %entry
33         %k.0.lcssa = phi i32 [ 0, %entry ], [ %t8, %bb ]                ; <i32> [#uses=1]
34         ret i32 %k.0.lcssa
35 }