For PR950:
[oota-llvm.git] / test / Transforms / InstCombine / cast-set.ll
1 ; This tests for various complex cast elimination cases instcombine should
2 ; handle.
3
4 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast
5
6 bool %test1(int %X) {
7         %A = cast int %X to uint
8         %c = setne uint %A, 12        ; Convert to setne int %X, 12
9         ret bool %c
10 }
11
12 bool %test2(int %X, int %Y) {
13         %A = cast int %X to uint
14         %B = cast int %Y to uint
15         %c = setne uint %A, %B       ; Convert to setne int %X, %Y
16         ret bool %c
17 }
18
19 int %test4(int %A) {
20         %B = cast int %A to uint
21         %C = shl uint %B, ubyte 2
22         %D = cast uint %C to int
23         ret int %D
24 }
25
26 short %test5(short %A) {
27         %B = cast short %A to uint
28         %C = and uint %B, 15
29         %D = cast uint %C to short
30         ret short %D
31 }
32
33 bool %test6(bool %A) {
34         %B = cast bool %A to int
35         %C = setne int %B, 0
36         ret bool %C
37 }
38
39 bool %test6a(bool %A) {
40         %B = cast bool %A to int
41         %C = setne int %B, -1    ; Always true!
42         ret bool %C
43 }
44
45 bool %test7(sbyte* %A) {
46         %B = cast sbyte* %A to int*
47         %C = seteq int* %B, null
48         ret bool %C
49 }