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-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | \
16 implementation ; Functions:
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]
24 bool %lt_signed_to_large_signed(sbyte %SB) {
25 %Y = cast sbyte %SB to int
26 %C = setlt int %Y, 1024
30 bool %lt_signed_to_large_negative(sbyte %SB) {
31 %Y = cast sbyte %SB to int
32 %C = setlt int %Y, -1024
36 bool %lt_signed_to_small_signed(sbyte %SB) {
37 %Y = cast sbyte %SB to int
42 bool %lt_signed_to_small_negative(sbyte %SB) {
43 %Y = cast sbyte %SB to int
44 %C = setlt int %Y, -17
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]
54 bool %lt_unsigned_to_large_signed(ubyte %SB) {
55 %Y = cast ubyte %SB to int
56 %C = setlt int %Y, 1024
60 bool %lt_unsigned_to_large_negative(ubyte %SB) {
61 %Y = cast ubyte %SB to int
62 %C = setlt int %Y, -1024
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]
72 bool %lt_unsigned_to_small_negative(ubyte %SB) {
73 %Y = cast ubyte %SB to int
74 %C = setlt int %Y, -17
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]
84 bool %gt_signed_to_large_signed(sbyte %SB) {
85 %Y = cast sbyte %SB to int
86 %C = setgt int %Y, 1024
90 bool %gt_signed_to_large_negative(sbyte %SB) {
91 %Y = cast sbyte %SB to int
92 %C = setgt int %Y, -1024
96 bool %gt_signed_to_small_signed(sbyte %SB) {
97 %Y = cast sbyte %SB to int
102 bool %gt_signed_to_small_negative(sbyte %SB) {
103 %Y = cast sbyte %SB to int
104 %C = setgt int %Y, -17
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]
114 bool %gt_unsigned_to_large_signed(ubyte %SB) {
115 %Y = cast ubyte %SB to int
116 %C = setgt int %Y, 1024
120 bool %gt_unsigned_to_large_negative(ubyte %SB) {
121 %Y = cast ubyte %SB to int
122 %C = setgt int %Y, -1024
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]
132 bool %gt_unsigned_to_small_negative(ubyte %SB) {
133 %Y = cast ubyte %SB to int
134 %C = setgt int %Y, -17