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 | \
15 implementation ; Functions:
17 bool %lt_signed_to_large_unsigned(sbyte %SB) {
18 %Y = cast sbyte %SB to uint ; <uint> [#uses=1]
19 %C = setlt uint %Y, 1024 ; <bool> [#uses=1]
23 bool %lt_signed_to_large_signed(sbyte %SB) {
24 %Y = cast sbyte %SB to int
25 %C = setlt int %Y, 1024
29 bool %lt_signed_to_large_negative(sbyte %SB) {
30 %Y = cast sbyte %SB to int
31 %C = setlt int %Y, -1024
35 bool %lt_signed_to_small_signed(sbyte %SB) {
36 %Y = cast sbyte %SB to int
41 bool %lt_signed_to_small_negative(sbyte %SB) {
42 %Y = cast sbyte %SB to int
43 %C = setlt int %Y, -17
47 bool %lt_unsigned_to_large_unsigned(ubyte %SB) {
48 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
49 %C = setlt uint %Y, 1024 ; <bool> [#uses=1]
53 bool %lt_unsigned_to_large_signed(ubyte %SB) {
54 %Y = cast ubyte %SB to int
55 %C = setlt int %Y, 1024
59 bool %lt_unsigned_to_large_negative(ubyte %SB) {
60 %Y = cast ubyte %SB to int
61 %C = setlt int %Y, -1024
65 bool %lt_unsigned_to_small_unsigned(ubyte %SB) {
66 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
67 %C = setlt uint %Y, 17 ; <bool> [#uses=1]
71 bool %lt_unsigned_to_small_negative(ubyte %SB) {
72 %Y = cast ubyte %SB to int
73 %C = setlt int %Y, -17
77 bool %gt_signed_to_large_unsigned(sbyte %SB) {
78 %Y = cast sbyte %SB to uint ; <uint> [#uses=1]
79 %C = setgt uint %Y, 1024 ; <bool> [#uses=1]
83 bool %gt_signed_to_large_signed(sbyte %SB) {
84 %Y = cast sbyte %SB to int
85 %C = setgt int %Y, 1024
89 bool %gt_signed_to_large_negative(sbyte %SB) {
90 %Y = cast sbyte %SB to int
91 %C = setgt int %Y, -1024
95 bool %gt_signed_to_small_signed(sbyte %SB) {
96 %Y = cast sbyte %SB to int
101 bool %gt_signed_to_small_negative(sbyte %SB) {
102 %Y = cast sbyte %SB to int
103 %C = setgt int %Y, -17
107 bool %gt_unsigned_to_large_unsigned(ubyte %SB) {
108 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
109 %C = setgt uint %Y, 1024 ; <bool> [#uses=1]
113 bool %gt_unsigned_to_large_signed(ubyte %SB) {
114 %Y = cast ubyte %SB to int
115 %C = setgt int %Y, 1024
119 bool %gt_unsigned_to_large_negative(ubyte %SB) {
120 %Y = cast ubyte %SB to int
121 %C = setgt int %Y, -1024
125 bool %gt_unsigned_to_small_unsigned(ubyte %SB) {
126 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
127 %C = setgt uint %Y, 17 ; <bool> [#uses=1]
131 bool %gt_unsigned_to_small_negative(ubyte %SB) {
132 %Y = cast ubyte %SB to int
133 %C = setgt int %Y, -17