93e3753cf50234e760006330d2de0aa0392515d0
[oota-llvm.git] / test / Transforms / InstCombine / trunc-mask-ext.ll
1 ; RUN: opt < %s -instcombine -S > %t
2 ; RUN: not grep zext %t
3 ; RUN: not grep sext %t
4
5 ; Instcombine should be able to eliminate all of these ext casts.
6
7 declare void @use(i32)
8
9 define i64 @foo(i64 %a) {
10   %b = trunc i64 %a to i32
11   %c = and i32 %b, 15
12   %d = zext i32 %c to i64
13   call void @use(i32 %b)
14   ret i64 %d
15 }
16 define i64 @bar(i64 %a) {
17   %b = trunc i64 %a to i32
18   %c = shl i32 %b, 4
19   %q = ashr i32 %c, 4
20   %d = sext i32 %q to i64
21   call void @use(i32 %b)
22   ret i64 %d
23 }
24 define i64 @goo(i64 %a) {
25   %b = trunc i64 %a to i32
26   %c = and i32 %b, 8
27   %d = zext i32 %c to i64
28   call void @use(i32 %b)
29   ret i64 %d
30 }
31 define i64 @hoo(i64 %a) {
32   %b = trunc i64 %a to i32
33   %c = and i32 %b, 8
34   %x = xor i32 %c, 8
35   %d = zext i32 %x to i64
36   call void @use(i32 %b)
37   ret i64 %d
38 }