Reorganize tests because we no longer cannonicalize X != 0 -> cast X to bool
[oota-llvm.git] / test / Transforms / InstCombine / cast.ll
1 ; Tests to make sure elimination of casts is working correctly
2
3 ; RUN: as < %s | opt -instcombine -die | dis | grep '%c' | not grep cast
4
5 implementation
6
7 int %test1(int %A) {
8         %c1 = cast int %A to uint
9         %c2 = cast uint %c1 to int
10         ret int %c2
11 }
12
13 ulong %test2(ubyte %A) {
14         %c1 = cast ubyte %A to ushort
15         %c2 = cast ushort %c1 to uint
16         %Ret = cast uint %c2 to ulong
17         ret ulong %Ret
18 }
19
20 ulong %test3(ulong %A) {    ; This function should just use bitwise AND
21         %c1 = cast ulong %A to ubyte
22         %c2 = cast ubyte %c1 to ulong
23         ret ulong %c2
24 }
25
26 uint %test4(int %A, int %B) {
27         %COND = setlt int %A, %B
28         %c = cast bool %COND to ubyte     ; Booleans are unsigned integrals
29         %result = cast ubyte %c to uint   ; for the cast elim purpose
30         ret uint %result
31 }
32
33 int %test5(bool %B) {
34         %c = cast bool %B to ubyte       ; This cast should get folded into
35         %result = cast ubyte %c to int   ; this cast
36         ret int %result
37 }
38
39 int %test6(ulong %A) {
40         %c1 = cast ulong %A to uint
41         %res = cast uint %c1 to int
42         ret int %res
43 }
44
45 long %test7(bool %A) {
46         %c1 = cast bool %A to int
47         %res = cast int %c1 to long
48         ret long %res
49 }
50
51 long %test8(sbyte %A) {
52         %c1 = cast sbyte %A to ulong
53         %res = cast ulong %c1 to long
54         ret long %res
55 }
56
57 short %test9(short %A) {
58         %c1 = cast short %A to int
59         %c2 = cast int %c1 to short
60         ret short %c2
61 }
62
63 short %test10(short %A) {
64         %c1 = cast short %A to uint
65         %c2 = cast uint %c1 to short
66         ret short %c2
67 }
68