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 | notcast '.*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_signed(sbyte %SB) {
35 %Y = cast sbyte %SB to int
40 bool %lt_signed_to_small_negative(sbyte %SB) {
41 %Y = cast sbyte %SB to int
42 %C = setlt int %Y, -17
46 bool %lt_unsigned_to_large_unsigned(ubyte %SB) {
47 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
48 %C = setlt uint %Y, 1024 ; <bool> [#uses=1]
52 bool %lt_unsigned_to_large_signed(ubyte %SB) {
53 %Y = cast ubyte %SB to int
54 %C = setlt int %Y, 1024
58 bool %lt_unsigned_to_large_negative(ubyte %SB) {
59 %Y = cast ubyte %SB to int
60 %C = setlt int %Y, -1024
64 bool %lt_unsigned_to_small_unsigned(ubyte %SB) {
65 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
66 %C = setlt uint %Y, 17 ; <bool> [#uses=1]
70 bool %lt_unsigned_to_small_negative(ubyte %SB) {
71 %Y = cast ubyte %SB to int
72 %C = setlt int %Y, -17
76 bool %gt_signed_to_large_unsigned(sbyte %SB) {
77 %Y = cast sbyte %SB to uint ; <uint> [#uses=1]
78 %C = setgt uint %Y, 1024 ; <bool> [#uses=1]
82 bool %gt_signed_to_large_signed(sbyte %SB) {
83 %Y = cast sbyte %SB to int
84 %C = setgt int %Y, 1024
88 bool %gt_signed_to_large_negative(sbyte %SB) {
89 %Y = cast sbyte %SB to int
90 %C = setgt int %Y, -1024
94 bool %gt_signed_to_small_signed(sbyte %SB) {
95 %Y = cast sbyte %SB to int
100 bool %gt_signed_to_small_negative(sbyte %SB) {
101 %Y = cast sbyte %SB to int
102 %C = setgt int %Y, -17
106 bool %gt_unsigned_to_large_unsigned(ubyte %SB) {
107 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
108 %C = setgt uint %Y, 1024 ; <bool> [#uses=1]
112 bool %gt_unsigned_to_large_signed(ubyte %SB) {
113 %Y = cast ubyte %SB to int
114 %C = setgt int %Y, 1024
118 bool %gt_unsigned_to_large_negative(ubyte %SB) {
119 %Y = cast ubyte %SB to int
120 %C = setgt int %Y, -1024
124 bool %gt_unsigned_to_small_unsigned(ubyte %SB) {
125 %Y = cast ubyte %SB to uint ; <uint> [#uses=1]
126 %C = setgt uint %Y, 17 ; <bool> [#uses=1]
130 bool %gt_unsigned_to_small_negative(ubyte %SB) {
131 %Y = cast ubyte %SB to int
132 %C = setgt int %Y, -17