1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
6 define i1 @slt_positive_multip_rem_zero(i8 %x) {
7 ; CHECK-LABEL: @slt_positive_multip_rem_zero(
8 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], 7
9 ; CHECK-NEXT: [[B:%.*]] = icmp slt i8 [[A]], 21
10 ; CHECK-NEXT: ret i1 [[B]]
13 %b = icmp slt i8 %a, 21
17 define i1 @slt_negative_multip_rem_zero(i8 %x) {
18 ; CHECK-LABEL: @slt_negative_multip_rem_zero(
19 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], -7
20 ; CHECK-NEXT: [[B:%.*]] = icmp slt i8 [[A]], 21
21 ; CHECK-NEXT: ret i1 [[B]]
23 %a = mul nsw i8 %x, -7
24 %b = icmp slt i8 %a, 21
28 define i1 @slt_positive_multip_rem_nz(i8 %x) {
29 ; CHECK-LABEL: @slt_positive_multip_rem_nz(
30 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], 5
31 ; CHECK-NEXT: [[B:%.*]] = icmp slt i8 [[A]], 21
32 ; CHECK-NEXT: ret i1 [[B]]
35 %b = icmp slt i8 %a, 21
39 define i1 @ult_rem_zero(i8 %x) {
40 ; CHECK-LABEL: @ult_rem_zero(
41 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 7
42 ; CHECK-NEXT: [[B:%.*]] = icmp ult i8 [[A]], 21
43 ; CHECK-NEXT: ret i1 [[B]]
46 %b = icmp ult i8 %a, 21
50 define i1 @ult_rem_nz(i8 %x) {
51 ; CHECK-LABEL: @ult_rem_nz(
52 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 5
53 ; CHECK-NEXT: [[B:%.*]] = icmp ult i8 [[A]], 21
54 ; CHECK-NEXT: ret i1 [[B]]
57 %b = icmp ult i8 %a, 21
63 define i1 @sgt_positive_multip_rem_zero(i8 %x) {
64 ; CHECK-LABEL: @sgt_positive_multip_rem_zero(
65 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], 7
66 ; CHECK-NEXT: [[B:%.*]] = icmp sgt i8 [[A]], 21
67 ; CHECK-NEXT: ret i1 [[B]]
70 %b = icmp sgt i8 %a, 21
74 define i1 @sgt_negative_multip_rem_zero(i8 %x) {
75 ; CHECK-LABEL: @sgt_negative_multip_rem_zero(
76 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], -7
77 ; CHECK-NEXT: [[B:%.*]] = icmp sgt i8 [[A]], 21
78 ; CHECK-NEXT: ret i1 [[B]]
80 %a = mul nsw i8 %x, -7
81 %b = icmp sgt i8 %a, 21
85 define i1 @sgt_positive_multip_rem_nz(i8 %x) {
86 ; CHECK-LABEL: @sgt_positive_multip_rem_nz(
87 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], 5
88 ; CHECK-NEXT: [[B:%.*]] = icmp sgt i8 [[A]], 21
89 ; CHECK-NEXT: ret i1 [[B]]
92 %b = icmp sgt i8 %a, 21
96 define i1 @ugt_rem_zero(i8 %x) {
97 ; CHECK-LABEL: @ugt_rem_zero(
98 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 7
99 ; CHECK-NEXT: [[B:%.*]] = icmp ugt i8 [[A]], 21
100 ; CHECK-NEXT: ret i1 [[B]]
102 %a = mul nuw i8 %x, 7
103 %b = icmp ugt i8 %a, 21
107 define i1 @ugt_rem_nz(i8 %x) {
108 ; CHECK-LABEL: @ugt_rem_nz(
109 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 5
110 ; CHECK-NEXT: [[B:%.*]] = icmp ugt i8 [[A]], 21
111 ; CHECK-NEXT: ret i1 [[B]]
113 %a = mul nuw i8 %x, 5
114 %b = icmp ugt i8 %a, 21
120 define i1 @eq_rem_zero(i8 %x) {
121 ; CHECK-LABEL: @eq_rem_zero(
122 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 5
123 ; CHECK-NEXT: [[B:%.*]] = icmp eq i8 [[A]], 20
124 ; CHECK-NEXT: ret i1 [[B]]
126 %a = mul nuw i8 %x, 5
127 %b = icmp eq i8 %a, 20
131 define i1 @ne_rem_zero(i8 %x) {
132 ; CHECK-LABEL: @ne_rem_zero(
133 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 5
134 ; CHECK-NEXT: [[B:%.*]] = icmp ne i8 [[A]], 30
135 ; CHECK-NEXT: ret i1 [[B]]
137 %a = mul nuw i8 %x, 5
138 %b = icmp ne i8 %a, 30
142 define i1 @eq_rem_nz(i8 %x) {
143 ; CHECK-LABEL: @eq_rem_nz(
144 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 5
145 ; CHECK-NEXT: [[B:%.*]] = icmp eq i8 [[A]], 31
146 ; CHECK-NEXT: ret i1 [[B]]
148 %a = mul nuw i8 %x, 5
149 %b = icmp eq i8 %a, 31
153 define i1 @ne_rem_nz(i8 %x) {
154 ; CHECK-LABEL: @ne_rem_nz(
155 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 5
156 ; CHECK-NEXT: [[B:%.*]] = icmp ne i8 [[A]], 31
157 ; CHECK-NEXT: ret i1 [[B]]
159 %a = mul nuw i8 %x, 5
160 %b = icmp ne i8 %a, 31
164 ; Negative tests for the icmp mul folds
166 define i1 @sgt_positive_multip_rem_zero_nonsw(i8 %x) {
167 ; CHECK-LABEL: @sgt_positive_multip_rem_zero_nonsw(
168 ; CHECK-NEXT: [[A:%.*]] = mul i8 [[X:%.*]], 7
169 ; CHECK-NEXT: [[B:%.*]] = icmp sgt i8 [[A]], 21
170 ; CHECK-NEXT: ret i1 [[B]]
173 %b = icmp sgt i8 %a, 21
177 define i1 @ult_multip_rem_zero_nonsw(i8 %x) {
178 ; CHECK-LABEL: @ult_multip_rem_zero_nonsw(
179 ; CHECK-NEXT: [[A:%.*]] = mul i8 [[X:%.*]], 7
180 ; CHECK-NEXT: [[B:%.*]] = icmp ult i8 [[A]], 21
181 ; CHECK-NEXT: ret i1 [[B]]
184 %b = icmp ult i8 %a, 21
188 define i1 @ugt_rem_zero_nonuw(i8 %x) {
189 ; CHECK-LABEL: @ugt_rem_zero_nonuw(
190 ; CHECK-NEXT: [[A:%.*]] = mul i8 [[X:%.*]], 7
191 ; CHECK-NEXT: [[B:%.*]] = icmp ugt i8 [[A]], 21
192 ; CHECK-NEXT: ret i1 [[B]]
195 %b = icmp ugt i8 %a, 21
199 define i1 @sgt_minnum(i8 %x) {
200 ; CHECK-LABEL: @sgt_minnum(
201 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], 7
202 ; CHECK-NEXT: [[B:%.*]] = icmp ne i8 [[A]], -128
203 ; CHECK-NEXT: ret i1 [[B]]
205 %a = mul nsw i8 %x, 7
206 %b = icmp sgt i8 %a, -128
210 define i1 @ule_bignum(i8 %x) {
211 ; CHECK-LABEL: @ule_bignum(
212 ; CHECK-NEXT: [[B:%.*]] = icmp eq i8 [[X:%.*]], 0
213 ; CHECK-NEXT: ret i1 [[B]]
215 %a = mul i8 %x, 2147483647
216 %b = icmp ule i8 %a, 0
220 define i1 @sgt_mulzero(i8 %x) {
221 ; CHECK-LABEL: @sgt_mulzero(
222 ; CHECK-NEXT: ret i1 false
224 %a = mul nsw i8 %x, 0
225 %b = icmp sgt i8 %a, 21
229 define i1 @eq_rem_zero_nonuw(i8 %x) {
230 ; CHECK-LABEL: @eq_rem_zero_nonuw(
231 ; CHECK-NEXT: [[A:%.*]] = mul i8 [[X:%.*]], 5
232 ; CHECK-NEXT: [[B:%.*]] = icmp eq i8 [[A]], 20
233 ; CHECK-NEXT: ret i1 [[B]]
236 %b = icmp eq i8 %a, 20
240 define i1 @ne_rem_zero_nonuw(i8 %x) {
241 ; CHECK-LABEL: @ne_rem_zero_nonuw(
242 ; CHECK-NEXT: [[A:%.*]] = mul i8 [[X:%.*]], 5
243 ; CHECK-NEXT: [[B:%.*]] = icmp ne i8 [[A]], 30
244 ; CHECK-NEXT: ret i1 [[B]]
247 %b = icmp ne i8 %a, 30