1 ; This test case tests the InstructionCombining optimization that
3 ; %Y = cast sbyte %X to uint
4 ; %C = setlt uint %Y, 1024
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.
12 ; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | not grep 'cast.*int'
14 implementation ; Functions:
16 bool %lt_signed_to_large_unsigned(sbyte %SB) {
17 %Y = cast sbyte %SB to uint ; <uint> [#uses=1]
18 %C = setlt uint %Y, 1024 ; <bool> [#uses=1]
22 bool %lt_signed_to_large_signed(sbyte %SB) {
23 %Y = cast sbyte %SB to int
24 %C = setlt int %Y, 1024
28 bool %lt_signed_to_large_negative(sbyte %SB) {
29 %Y = cast sbyte %SB to int
30 %C = setlt int %Y, -1024
34 bool %lt_signed_to_small_unsigned(sbyte %SB) {
35 %Y = cast sbyte %SB to uint ; <uint> [#uses=1]
36 %C = setlt uint %Y, 17 ; <bool> [#uses=1]
40 bool %lt_signed_to_small_signed(sbyte %SB) {
41 %Y = cast sbyte %SB to int
46 bool %lt_signed_to_small_negative(sbyte %SB) {
47 %Y = cast sbyte %SB to int
48 %C = setlt int %Y, -17
52 bool %lt_unsigned_to_large_unsigned(ubyte %SB) {
53 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
54 %C = setlt uint %Y, 1024 ; <bool> [#uses=1]
58 bool %lt_unsigned_to_large_signed(ubyte %SB) {
59 %Y = cast ubyte %SB to int
60 %C = setlt int %Y, 1024
64 bool %lt_unsigned_to_large_negative(ubyte %SB) {
65 %Y = cast ubyte %SB to int
66 %C = setlt int %Y, -1024
70 bool %lt_unsigned_to_small_unsigned(ubyte %SB) {
71 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
72 %C = setlt uint %Y, 17 ; <bool> [#uses=1]
76 bool %lt_unsigned_to_small_signed(ubyte %SB) {
77 %Y = cast ubyte %SB to int
82 bool %lt_unsigned_to_small_negative(ubyte %SB) {
83 %Y = cast ubyte %SB to int
84 %C = setlt int %Y, -17
88 bool %gt_signed_to_large_unsigned(sbyte %SB) {
89 %Y = cast sbyte %SB to uint ; <uint> [#uses=1]
90 %C = setgt uint %Y, 1024 ; <bool> [#uses=1]
94 bool %gt_signed_to_large_signed(sbyte %SB) {
95 %Y = cast sbyte %SB to int
96 %C = setgt int %Y, 1024
100 bool %gt_signed_to_large_negative(sbyte %SB) {
101 %Y = cast sbyte %SB to int
102 %C = setgt int %Y, -1024
106 bool %gt_signed_to_small_unsigned(sbyte %SB) {
107 %Y = cast sbyte %SB to uint ; <uint> [#uses=1]
108 %C = setgt uint %Y, 17 ; <bool> [#uses=1]
112 bool %gt_signed_to_small_signed(sbyte %SB) {
113 %Y = cast sbyte %SB to int
114 %C = setgt int %Y, 17
118 bool %gt_signed_to_small_negative(sbyte %SB) {
119 %Y = cast sbyte %SB to int
120 %C = setgt int %Y, -17
124 bool %gt_unsigned_to_large_unsigned(ubyte %SB) {
125 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
126 %C = setgt uint %Y, 1024 ; <bool> [#uses=1]
130 bool %gt_unsigned_to_large_signed(ubyte %SB) {
131 %Y = cast ubyte %SB to int
132 %C = setgt int %Y, 1024
136 bool %gt_unsigned_to_large_negative(ubyte %SB) {
137 %Y = cast ubyte %SB to int
138 %C = setgt int %Y, -1024
142 bool %gt_unsigned_to_small_unsigned(ubyte %SB) {
143 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
144 %C = setgt uint %Y, 17 ; <bool> [#uses=1]
148 bool %gt_unsigned_to_small_signed(ubyte %SB) {
149 %Y = cast ubyte %SB to int
150 %C = setgt int %Y, 17
154 bool %gt_unsigned_to_small_negative(ubyte %SB) {
155 %Y = cast ubyte %SB to int
156 %C = setgt int %Y, -17