1 ; This test case tests the InstructionCombining optimization that
3 ; %Y = sext i8 %X to i32
4 ; %C = icmp ult i32 %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: opt < %s -instcombine -S | \
15 define i1 @lt_signed_to_large_unsigned(i8 %SB) {
16 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
17 %C = icmp ult i32 %Y, 1024 ; <i1> [#uses=1]
21 define i1 @lt_signed_to_large_signed(i8 %SB) {
22 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
23 %C = icmp slt i32 %Y, 1024 ; <i1> [#uses=1]
27 define i1 @lt_signed_to_large_negative(i8 %SB) {
28 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
29 %C = icmp slt i32 %Y, -1024 ; <i1> [#uses=1]
33 define i1 @lt_signed_to_small_signed(i8 %SB) {
34 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
35 %C = icmp slt i32 %Y, 17 ; <i1> [#uses=1]
38 define i1 @lt_signed_to_small_negative(i8 %SB) {
39 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
40 %C = icmp slt i32 %Y, -17 ; <i1> [#uses=1]
44 define i1 @lt_unsigned_to_large_unsigned(i8 %SB) {
45 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
46 %C = icmp ult i32 %Y, 1024 ; <i1> [#uses=1]
50 define i1 @lt_unsigned_to_large_signed(i8 %SB) {
51 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
52 %C = icmp slt i32 %Y, 1024 ; <i1> [#uses=1]
56 define i1 @lt_unsigned_to_large_negative(i8 %SB) {
57 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
58 %C = icmp slt i32 %Y, -1024 ; <i1> [#uses=1]
62 define i1 @lt_unsigned_to_small_unsigned(i8 %SB) {
63 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
64 %C = icmp ult i32 %Y, 17 ; <i1> [#uses=1]
68 define i1 @lt_unsigned_to_small_negative(i8 %SB) {
69 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
70 %C = icmp slt i32 %Y, -17 ; <i1> [#uses=1]
74 define i1 @gt_signed_to_large_unsigned(i8 %SB) {
75 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
76 %C = icmp ugt i32 %Y, 1024 ; <i1> [#uses=1]
80 define i1 @gt_signed_to_large_signed(i8 %SB) {
81 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
82 %C = icmp sgt i32 %Y, 1024 ; <i1> [#uses=1]
86 define i1 @gt_signed_to_large_negative(i8 %SB) {
87 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
88 %C = icmp sgt i32 %Y, -1024 ; <i1> [#uses=1]
91 define i1 @gt_signed_to_small_signed(i8 %SB) {
92 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
93 %C = icmp sgt i32 %Y, 17 ; <i1> [#uses=1]
97 define i1 @gt_signed_to_small_negative(i8 %SB) {
98 %Y = sext i8 %SB to i32 ; <i32> [#uses=1]
99 %C = icmp sgt i32 %Y, -17 ; <i1> [#uses=1]
103 define i1 @gt_unsigned_to_large_unsigned(i8 %SB) {
104 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
105 %C = icmp ugt i32 %Y, 1024 ; <i1> [#uses=1]
109 define i1 @gt_unsigned_to_large_signed(i8 %SB) {
110 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
111 %C = icmp sgt i32 %Y, 1024 ; <i1> [#uses=1]
115 define i1 @gt_unsigned_to_large_negative(i8 %SB) {
116 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
117 %C = icmp sgt i32 %Y, -1024 ; <i1> [#uses=1]
121 define i1 @gt_unsigned_to_small_unsigned(i8 %SB) {
122 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
123 %C = icmp ugt i32 %Y, 17 ; <i1> [#uses=1]
127 define i1 @gt_unsigned_to_small_negative(i8 %SB) {
128 %Y = zext i8 %SB to i32 ; <i32> [#uses=1]
129 %C = icmp sgt i32 %Y, -17 ; <i1> [#uses=1]