1 ; Tests to make sure elimination of casts is working correctly
3 ; RUN: if as < %s | opt -instcombine -die | dis | grep '%c' | grep cast
11 %c1 = cast int %A to uint
12 %c2 = cast uint %c1 to int
16 ulong %test2(ubyte %A) {
17 %c1 = cast ubyte %A to ushort
18 %c2 = cast ushort %c1 to uint
19 %Ret = cast uint %c2 to ulong
23 ulong %test3(ulong %A) { ; This function should just use bitwise AND
24 %c1 = cast ulong %A to ubyte
25 %c2 = cast ubyte %c1 to ulong
29 uint %test4(int %A, int %B) {
30 %COND = setlt int %A, %B
31 %c = cast bool %COND to ubyte ; Booleans are unsigned integrals
32 %result = cast ubyte %c to uint ; for the cast elim purpose
37 %c = cast bool %B to ubyte ; This cast should get folded into
38 %result = cast ubyte %c to int ; this cast
42 int %test6(ulong %A) {
43 %c1 = cast ulong %A to uint
44 %res = cast uint %c1 to int
48 long %test7(bool %A) {
49 %c1 = cast bool %A to int
50 %res = cast int %c1 to long
54 long %test8(sbyte %A) {
55 %c1 = cast sbyte %A to ulong
56 %res = cast ulong %c1 to long
60 short %test9(short %A) {
61 %c1 = cast short %A to int
62 %c2 = cast int %c1 to short
66 short %test10(short %A) {
67 %c1 = cast short %A to uint
68 %c2 = cast uint %c1 to short
72 bool %test11(ubyte %A, ubyte %B) {
74 %D = cast ubyte %C to bool ; == setne A, B
78 bool %test12(ubyte %A) {
79 %B = add ubyte %A, 255
80 %C = cast ubyte %B to bool ; === A != 1
84 bool %test13(ubyte %A, ubyte %b) {
86 %C = cast ubyte %B to bool ; === A != -b