oops, forgot to commit this.
[oota-llvm.git] / test / Transforms / InstCombine / 2004-11-27-SetCCForCastLargerAndConstant.ll
1 ; This test case tests the InstructionCombining optimization that
2 ; reduces things like:
3 ;   %Y = cast sbyte %X to uint
4 ;   %C = setlt uint %Y, 1024
5 ; to
6 ;   %C = bool true
7 ; It includes test cases for different constant values, signedness of the
8 ; cast operands, and types of setCC operators. In all cases, the cast should
9 ; be eliminated. In many cases the setCC is also eliminated based on the
10 ; constant value and the range of the casted value.
11 ;
12 ; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | \
13 ; RUN:    notcast .*int
14 ; END.
15
16 implementation   ; Functions:
17
18 bool %lt_signed_to_large_unsigned(sbyte %SB) {
19   %Y = cast sbyte %SB to uint           ; <uint> [#uses=1]
20   %C = setlt uint %Y, 1024              ; <bool> [#uses=1]
21   ret bool %C
22 }
23
24 bool %lt_signed_to_large_signed(sbyte %SB) {
25   %Y = cast sbyte %SB to int
26   %C = setlt int %Y, 1024
27   ret bool %C
28 }
29
30 bool %lt_signed_to_large_negative(sbyte %SB) {
31   %Y = cast sbyte %SB to int
32   %C = setlt int %Y, -1024
33   ret bool %C
34 }
35
36 bool %lt_signed_to_small_signed(sbyte %SB) {
37   %Y = cast sbyte %SB to int
38   %C = setlt int %Y, 17
39   ret bool %C
40 }
41
42 bool %lt_signed_to_small_negative(sbyte %SB) {
43   %Y = cast sbyte %SB to int
44   %C = setlt int %Y, -17
45   ret bool %C
46 }
47
48 bool %lt_unsigned_to_large_unsigned(ubyte %SB) {
49   %Y = cast ubyte %SB to uint           ; <uint> [#uses=1]
50   %C = setlt uint %Y, 1024              ; <bool> [#uses=1]
51   ret bool %C
52 }
53
54 bool %lt_unsigned_to_large_signed(ubyte %SB) {
55   %Y = cast ubyte %SB to int
56   %C = setlt int %Y, 1024
57   ret bool %C
58 }
59
60 bool %lt_unsigned_to_large_negative(ubyte %SB) {
61   %Y = cast ubyte %SB to int
62   %C = setlt int %Y, -1024
63   ret bool %C
64 }
65
66 bool %lt_unsigned_to_small_unsigned(ubyte %SB) {
67   %Y = cast ubyte %SB to uint           ; <uint> [#uses=1]
68   %C = setlt uint %Y, 17                ; <bool> [#uses=1]
69   ret bool %C
70 }
71
72 bool %lt_unsigned_to_small_negative(ubyte %SB) {
73   %Y = cast ubyte %SB to int
74   %C = setlt int %Y, -17
75   ret bool %C
76 }
77
78 bool %gt_signed_to_large_unsigned(sbyte %SB) {
79   %Y = cast sbyte %SB to uint           ; <uint> [#uses=1]
80   %C = setgt uint %Y, 1024              ; <bool> [#uses=1]
81   ret bool %C
82 }
83
84 bool %gt_signed_to_large_signed(sbyte %SB) {
85   %Y = cast sbyte %SB to int
86   %C = setgt int %Y, 1024
87   ret bool %C
88 }
89
90 bool %gt_signed_to_large_negative(sbyte %SB) {
91   %Y = cast sbyte %SB to int
92   %C = setgt int %Y, -1024
93   ret bool %C
94 }
95
96 bool %gt_signed_to_small_signed(sbyte %SB) {
97   %Y = cast sbyte %SB to int
98   %C = setgt int %Y, 17
99   ret bool %C
100 }
101
102 bool %gt_signed_to_small_negative(sbyte %SB) {
103   %Y = cast sbyte %SB to int
104   %C = setgt int %Y, -17
105   ret bool %C
106 }
107
108 bool %gt_unsigned_to_large_unsigned(ubyte %SB) {
109   %Y = cast ubyte %SB to uint           ; <uint> [#uses=1]
110   %C = setgt uint %Y, 1024              ; <bool> [#uses=1]
111   ret bool %C
112 }
113
114 bool %gt_unsigned_to_large_signed(ubyte %SB) {
115   %Y = cast ubyte %SB to int
116   %C = setgt int %Y, 1024
117   ret bool %C
118 }
119
120 bool %gt_unsigned_to_large_negative(ubyte %SB) {
121   %Y = cast ubyte %SB to int
122   %C = setgt int %Y, -1024
123   ret bool %C
124 }
125
126 bool %gt_unsigned_to_small_unsigned(ubyte %SB) {
127   %Y = cast ubyte %SB to uint           ; <uint> [#uses=1]
128   %C = setgt uint %Y, 17                ; <bool> [#uses=1]
129   ret bool %C
130 }
131
132 bool %gt_unsigned_to_small_negative(ubyte %SB) {
133   %Y = cast ubyte %SB to int
134   %C = setgt int %Y, -17
135   ret bool %C
136 }