1 ; Tests to make sure elimination of casts is working correctly
3 ; RUN: llvm-as < %s | opt -instcombine -die | llvm-dis | grep '%c' | not grep cast
8 %c1 = cast int %A to uint
9 %c2 = cast uint %c1 to int
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
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
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
34 %c = cast bool %B to ubyte ; This cast should get folded into
35 %result = cast ubyte %c to int ; this cast
39 int %test6(ulong %A) {
40 %c1 = cast ulong %A to uint
41 %res = cast uint %c1 to int
45 long %test7(bool %A) {
46 %c1 = cast bool %A to int
47 %res = cast int %c1 to long
51 long %test8(sbyte %A) {
52 %c1 = cast sbyte %A to ulong
53 %res = cast ulong %c1 to long
57 short %test9(short %A) {
58 %c1 = cast short %A to int
59 %c2 = cast int %c1 to short
63 short %test10(short %A) {
64 %c1 = cast short %A to uint
65 %c2 = cast uint %c1 to short
69 declare void %varargs(int, ...)
71 void %test11(int* %P) {
72 %c = cast int* %P to short*
73 call void(int, ...)* %varargs(int 5, short* %c)