1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 declare void @use32(i32)
5 declare void @use64(i64)
7 define i1 @highest_bit_test_via_lshr(i32 %data, i32 %nbits) {
8 ; CHECK-LABEL: @highest_bit_test_via_lshr(
9 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP:%.*]] = sub i32 32, [[NBITS:%.*]]
10 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED:%.*]] = lshr i32 [[DATA:%.*]], [[NUM_LOW_BITS_TO_SKIP]]
11 ; CHECK-NEXT: [[SKIP_ALL_BITS_TILL_SIGNBIT:%.*]] = add i32 [[NBITS]], -1
12 ; CHECK-NEXT: [[SIGNBIT:%.*]] = lshr i32 [[DATA]], 31
13 ; CHECK-NEXT: call void @use32(i32 [[NUM_LOW_BITS_TO_SKIP]])
14 ; CHECK-NEXT: call void @use32(i32 [[HIGH_BITS_EXTRACTED]])
15 ; CHECK-NEXT: call void @use32(i32 [[SKIP_ALL_BITS_TILL_SIGNBIT]])
16 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
17 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i32 [[DATA]], 0
18 ; CHECK-NEXT: ret i1 [[ISNEG]]
20 %num_low_bits_to_skip = sub i32 32, %nbits
21 %high_bits_extracted = lshr i32 %data, %num_low_bits_to_skip
22 %skip_all_bits_till_signbit = sub i32 %nbits, 1
23 %signbit = lshr i32 %high_bits_extracted, %skip_all_bits_till_signbit
25 call void @use32(i32 %num_low_bits_to_skip)
26 call void @use32(i32 %high_bits_extracted)
27 call void @use32(i32 %skip_all_bits_till_signbit)
28 call void @use32(i32 %signbit)
30 %isneg = icmp ne i32 %signbit, 0
34 define i1 @highest_bit_test_via_lshr_with_truncation(i64 %data, i32 %nbits) {
35 ; CHECK-LABEL: @highest_bit_test_via_lshr_with_truncation(
36 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP:%.*]] = sub i32 64, [[NBITS:%.*]]
37 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP_WIDE:%.*]] = zext i32 [[NUM_LOW_BITS_TO_SKIP]] to i64
38 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED:%.*]] = lshr i64 [[DATA:%.*]], [[NUM_LOW_BITS_TO_SKIP_WIDE]]
39 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED_NARROW:%.*]] = trunc i64 [[HIGH_BITS_EXTRACTED]] to i32
40 ; CHECK-NEXT: [[SKIP_ALL_BITS_TILL_SIGNBIT:%.*]] = add i32 [[NBITS]], -1
41 ; CHECK-NEXT: [[SIGNBIT:%.*]] = lshr i32 [[HIGH_BITS_EXTRACTED_NARROW]], [[SKIP_ALL_BITS_TILL_SIGNBIT]]
42 ; CHECK-NEXT: call void @use32(i32 [[NUM_LOW_BITS_TO_SKIP]])
43 ; CHECK-NEXT: call void @use64(i64 [[NUM_LOW_BITS_TO_SKIP_WIDE]])
44 ; CHECK-NEXT: call void @use64(i64 [[HIGH_BITS_EXTRACTED]])
45 ; CHECK-NEXT: call void @use32(i32 [[HIGH_BITS_EXTRACTED_NARROW]])
46 ; CHECK-NEXT: call void @use32(i32 [[SKIP_ALL_BITS_TILL_SIGNBIT]])
47 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
48 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i64 [[DATA]], 0
49 ; CHECK-NEXT: ret i1 [[ISNEG]]
51 %num_low_bits_to_skip = sub i32 64, %nbits
52 %num_low_bits_to_skip_wide = zext i32 %num_low_bits_to_skip to i64
53 %high_bits_extracted = lshr i64 %data, %num_low_bits_to_skip_wide
54 %high_bits_extracted_narrow = trunc i64 %high_bits_extracted to i32
55 %skip_all_bits_till_signbit = sub i32 %nbits, 1
56 %signbit = lshr i32 %high_bits_extracted_narrow, %skip_all_bits_till_signbit
58 call void @use32(i32 %num_low_bits_to_skip)
59 call void @use64(i64 %num_low_bits_to_skip_wide)
60 call void @use64(i64 %high_bits_extracted)
61 call void @use32(i32 %high_bits_extracted_narrow)
62 call void @use32(i32 %skip_all_bits_till_signbit)
63 call void @use32(i32 %signbit)
65 %isneg = icmp ne i32 %signbit, 0
69 define i1 @highest_bit_test_via_ashr(i32 %data, i32 %nbits) {
70 ; CHECK-LABEL: @highest_bit_test_via_ashr(
71 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP:%.*]] = sub i32 32, [[NBITS:%.*]]
72 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED:%.*]] = ashr i32 [[DATA:%.*]], [[NUM_LOW_BITS_TO_SKIP]]
73 ; CHECK-NEXT: [[SKIP_ALL_BITS_TILL_SIGNBIT:%.*]] = add i32 [[NBITS]], -1
74 ; CHECK-NEXT: [[SIGNBIT:%.*]] = ashr i32 [[DATA]], 31
75 ; CHECK-NEXT: call void @use32(i32 [[NUM_LOW_BITS_TO_SKIP]])
76 ; CHECK-NEXT: call void @use32(i32 [[HIGH_BITS_EXTRACTED]])
77 ; CHECK-NEXT: call void @use32(i32 [[SKIP_ALL_BITS_TILL_SIGNBIT]])
78 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
79 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i32 [[DATA]], 0
80 ; CHECK-NEXT: ret i1 [[ISNEG]]
82 %num_low_bits_to_skip = sub i32 32, %nbits
83 %high_bits_extracted = ashr i32 %data, %num_low_bits_to_skip
84 %skip_all_bits_till_signbit = sub i32 %nbits, 1
85 %signbit = ashr i32 %high_bits_extracted, %skip_all_bits_till_signbit
87 call void @use32(i32 %num_low_bits_to_skip)
88 call void @use32(i32 %high_bits_extracted)
89 call void @use32(i32 %skip_all_bits_till_signbit)
90 call void @use32(i32 %signbit)
92 %isneg = icmp ne i32 %signbit, 0
96 define i1 @highest_bit_test_via_ashr_with_truncation(i64 %data, i32 %nbits) {
97 ; CHECK-LABEL: @highest_bit_test_via_ashr_with_truncation(
98 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP:%.*]] = sub i32 64, [[NBITS:%.*]]
99 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP_WIDE:%.*]] = zext i32 [[NUM_LOW_BITS_TO_SKIP]] to i64
100 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED:%.*]] = ashr i64 [[DATA:%.*]], [[NUM_LOW_BITS_TO_SKIP_WIDE]]
101 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED_NARROW:%.*]] = trunc i64 [[HIGH_BITS_EXTRACTED]] to i32
102 ; CHECK-NEXT: [[SKIP_ALL_BITS_TILL_SIGNBIT:%.*]] = add i32 [[NBITS]], -1
103 ; CHECK-NEXT: [[SIGNBIT:%.*]] = ashr i32 [[HIGH_BITS_EXTRACTED_NARROW]], [[SKIP_ALL_BITS_TILL_SIGNBIT]]
104 ; CHECK-NEXT: call void @use32(i32 [[NUM_LOW_BITS_TO_SKIP]])
105 ; CHECK-NEXT: call void @use64(i64 [[NUM_LOW_BITS_TO_SKIP_WIDE]])
106 ; CHECK-NEXT: call void @use64(i64 [[HIGH_BITS_EXTRACTED]])
107 ; CHECK-NEXT: call void @use32(i32 [[HIGH_BITS_EXTRACTED_NARROW]])
108 ; CHECK-NEXT: call void @use32(i32 [[SKIP_ALL_BITS_TILL_SIGNBIT]])
109 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
110 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i64 [[DATA]], 0
111 ; CHECK-NEXT: ret i1 [[ISNEG]]
113 %num_low_bits_to_skip = sub i32 64, %nbits
114 %num_low_bits_to_skip_wide = zext i32 %num_low_bits_to_skip to i64
115 %high_bits_extracted = ashr i64 %data, %num_low_bits_to_skip_wide
116 %high_bits_extracted_narrow = trunc i64 %high_bits_extracted to i32
117 %skip_all_bits_till_signbit = sub i32 %nbits, 1
118 %signbit = ashr i32 %high_bits_extracted_narrow, %skip_all_bits_till_signbit
120 call void @use32(i32 %num_low_bits_to_skip)
121 call void @use64(i64 %num_low_bits_to_skip_wide)
122 call void @use64(i64 %high_bits_extracted)
123 call void @use32(i32 %high_bits_extracted_narrow)
124 call void @use32(i32 %skip_all_bits_till_signbit)
125 call void @use32(i32 %signbit)
127 %isneg = icmp ne i32 %signbit, 0
131 define i1 @highest_bit_test_via_lshr_ashr(i32 %data, i32 %nbits) {
132 ; CHECK-LABEL: @highest_bit_test_via_lshr_ashr(
133 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP:%.*]] = sub i32 32, [[NBITS:%.*]]
134 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED:%.*]] = lshr i32 [[DATA:%.*]], [[NUM_LOW_BITS_TO_SKIP]]
135 ; CHECK-NEXT: [[SKIP_ALL_BITS_TILL_SIGNBIT:%.*]] = add i32 [[NBITS]], -1
136 ; CHECK-NEXT: [[SIGNBIT:%.*]] = ashr i32 [[HIGH_BITS_EXTRACTED]], [[SKIP_ALL_BITS_TILL_SIGNBIT]]
137 ; CHECK-NEXT: call void @use32(i32 [[NUM_LOW_BITS_TO_SKIP]])
138 ; CHECK-NEXT: call void @use32(i32 [[HIGH_BITS_EXTRACTED]])
139 ; CHECK-NEXT: call void @use32(i32 [[SKIP_ALL_BITS_TILL_SIGNBIT]])
140 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
141 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i32 [[DATA]], 0
142 ; CHECK-NEXT: ret i1 [[ISNEG]]
144 %num_low_bits_to_skip = sub i32 32, %nbits
145 %high_bits_extracted = lshr i32 %data, %num_low_bits_to_skip
146 %skip_all_bits_till_signbit = sub i32 %nbits, 1
147 %signbit = ashr i32 %high_bits_extracted, %skip_all_bits_till_signbit
149 call void @use32(i32 %num_low_bits_to_skip)
150 call void @use32(i32 %high_bits_extracted)
151 call void @use32(i32 %skip_all_bits_till_signbit)
152 call void @use32(i32 %signbit)
154 %isneg = icmp ne i32 %signbit, 0
158 define i1 @highest_bit_test_via_lshr_ashe_with_truncation(i64 %data, i32 %nbits) {
159 ; CHECK-LABEL: @highest_bit_test_via_lshr_ashe_with_truncation(
160 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP:%.*]] = sub i32 64, [[NBITS:%.*]]
161 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP_WIDE:%.*]] = zext i32 [[NUM_LOW_BITS_TO_SKIP]] to i64
162 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED:%.*]] = lshr i64 [[DATA:%.*]], [[NUM_LOW_BITS_TO_SKIP_WIDE]]
163 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED_NARROW:%.*]] = trunc i64 [[HIGH_BITS_EXTRACTED]] to i32
164 ; CHECK-NEXT: [[SKIP_ALL_BITS_TILL_SIGNBIT:%.*]] = add i32 [[NBITS]], -1
165 ; CHECK-NEXT: [[SIGNBIT:%.*]] = ashr i32 [[HIGH_BITS_EXTRACTED_NARROW]], [[SKIP_ALL_BITS_TILL_SIGNBIT]]
166 ; CHECK-NEXT: call void @use32(i32 [[NUM_LOW_BITS_TO_SKIP]])
167 ; CHECK-NEXT: call void @use64(i64 [[NUM_LOW_BITS_TO_SKIP_WIDE]])
168 ; CHECK-NEXT: call void @use64(i64 [[HIGH_BITS_EXTRACTED]])
169 ; CHECK-NEXT: call void @use32(i32 [[HIGH_BITS_EXTRACTED_NARROW]])
170 ; CHECK-NEXT: call void @use32(i32 [[SKIP_ALL_BITS_TILL_SIGNBIT]])
171 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
172 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i64 [[DATA]], 0
173 ; CHECK-NEXT: ret i1 [[ISNEG]]
175 %num_low_bits_to_skip = sub i32 64, %nbits
176 %num_low_bits_to_skip_wide = zext i32 %num_low_bits_to_skip to i64
177 %high_bits_extracted = lshr i64 %data, %num_low_bits_to_skip_wide
178 %high_bits_extracted_narrow = trunc i64 %high_bits_extracted to i32
179 %skip_all_bits_till_signbit = sub i32 %nbits, 1
180 %signbit = ashr i32 %high_bits_extracted_narrow, %skip_all_bits_till_signbit
182 call void @use32(i32 %num_low_bits_to_skip)
183 call void @use64(i64 %num_low_bits_to_skip_wide)
184 call void @use64(i64 %high_bits_extracted)
185 call void @use32(i32 %high_bits_extracted_narrow)
186 call void @use32(i32 %skip_all_bits_till_signbit)
187 call void @use32(i32 %signbit)
189 %isneg = icmp ne i32 %signbit, 0
193 define i1 @highest_bit_test_via_ashr_lshr(i32 %data, i32 %nbits) {
194 ; CHECK-LABEL: @highest_bit_test_via_ashr_lshr(
195 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP:%.*]] = sub i32 32, [[NBITS:%.*]]
196 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED:%.*]] = ashr i32 [[DATA:%.*]], [[NUM_LOW_BITS_TO_SKIP]]
197 ; CHECK-NEXT: [[SKIP_ALL_BITS_TILL_SIGNBIT:%.*]] = add i32 [[NBITS]], -1
198 ; CHECK-NEXT: [[SIGNBIT:%.*]] = lshr i32 [[HIGH_BITS_EXTRACTED]], [[SKIP_ALL_BITS_TILL_SIGNBIT]]
199 ; CHECK-NEXT: call void @use32(i32 [[NUM_LOW_BITS_TO_SKIP]])
200 ; CHECK-NEXT: call void @use32(i32 [[HIGH_BITS_EXTRACTED]])
201 ; CHECK-NEXT: call void @use32(i32 [[SKIP_ALL_BITS_TILL_SIGNBIT]])
202 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
203 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i32 [[DATA]], 0
204 ; CHECK-NEXT: ret i1 [[ISNEG]]
206 %num_low_bits_to_skip = sub i32 32, %nbits
207 %high_bits_extracted = ashr i32 %data, %num_low_bits_to_skip
208 %skip_all_bits_till_signbit = sub i32 %nbits, 1
209 %signbit = lshr i32 %high_bits_extracted, %skip_all_bits_till_signbit
211 call void @use32(i32 %num_low_bits_to_skip)
212 call void @use32(i32 %high_bits_extracted)
213 call void @use32(i32 %skip_all_bits_till_signbit)
214 call void @use32(i32 %signbit)
216 %isneg = icmp ne i32 %signbit, 0
220 define i1 @highest_bit_test_via_ashr_lshr_with_truncation(i64 %data, i32 %nbits) {
221 ; CHECK-LABEL: @highest_bit_test_via_ashr_lshr_with_truncation(
222 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP:%.*]] = sub i32 64, [[NBITS:%.*]]
223 ; CHECK-NEXT: [[NUM_LOW_BITS_TO_SKIP_WIDE:%.*]] = zext i32 [[NUM_LOW_BITS_TO_SKIP]] to i64
224 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED:%.*]] = ashr i64 [[DATA:%.*]], [[NUM_LOW_BITS_TO_SKIP_WIDE]]
225 ; CHECK-NEXT: [[HIGH_BITS_EXTRACTED_NARROW:%.*]] = trunc i64 [[HIGH_BITS_EXTRACTED]] to i32
226 ; CHECK-NEXT: [[SKIP_ALL_BITS_TILL_SIGNBIT:%.*]] = add i32 [[NBITS]], -1
227 ; CHECK-NEXT: [[SIGNBIT:%.*]] = lshr i32 [[HIGH_BITS_EXTRACTED_NARROW]], [[SKIP_ALL_BITS_TILL_SIGNBIT]]
228 ; CHECK-NEXT: call void @use32(i32 [[NUM_LOW_BITS_TO_SKIP]])
229 ; CHECK-NEXT: call void @use64(i64 [[NUM_LOW_BITS_TO_SKIP_WIDE]])
230 ; CHECK-NEXT: call void @use64(i64 [[HIGH_BITS_EXTRACTED]])
231 ; CHECK-NEXT: call void @use32(i32 [[HIGH_BITS_EXTRACTED_NARROW]])
232 ; CHECK-NEXT: call void @use32(i32 [[SKIP_ALL_BITS_TILL_SIGNBIT]])
233 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
234 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i64 [[DATA]], 0
235 ; CHECK-NEXT: ret i1 [[ISNEG]]
237 %num_low_bits_to_skip = sub i32 64, %nbits
238 %num_low_bits_to_skip_wide = zext i32 %num_low_bits_to_skip to i64
239 %high_bits_extracted = ashr i64 %data, %num_low_bits_to_skip_wide
240 %high_bits_extracted_narrow = trunc i64 %high_bits_extracted to i32
241 %skip_all_bits_till_signbit = sub i32 %nbits, 1
242 %signbit = lshr i32 %high_bits_extracted_narrow, %skip_all_bits_till_signbit
244 call void @use32(i32 %num_low_bits_to_skip)
245 call void @use64(i64 %num_low_bits_to_skip_wide)
246 call void @use64(i64 %high_bits_extracted)
247 call void @use32(i32 %high_bits_extracted_narrow)
248 call void @use32(i32 %skip_all_bits_till_signbit)
249 call void @use32(i32 %signbit)
251 %isneg = icmp ne i32 %signbit, 0
255 ;------------------------------------------------------------------------------;
257 define i1 @unsigned_sign_bit_extract(i32 %x) {
258 ; CHECK-LABEL: @unsigned_sign_bit_extract(
259 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i32 [[X:%.*]], 0
260 ; CHECK-NEXT: ret i1 [[ISNEG]]
262 %signbit = lshr i32 %x, 31
263 %isneg = icmp ne i32 %signbit, 0
266 define i1 @unsigned_sign_bit_extract_extrause(i32 %x) {
267 ; CHECK-LABEL: @unsigned_sign_bit_extract_extrause(
268 ; CHECK-NEXT: [[SIGNBIT:%.*]] = lshr i32 [[X:%.*]], 31
269 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
270 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i32 [[X]], 0
271 ; CHECK-NEXT: ret i1 [[ISNEG]]
273 %signbit = lshr i32 %x, 31
274 call void @use32(i32 %signbit)
275 %isneg = icmp ne i32 %signbit, 0
278 define i1 @unsigned_sign_bit_extract_extrause__ispositive(i32 %x) {
279 ; CHECK-LABEL: @unsigned_sign_bit_extract_extrause__ispositive(
280 ; CHECK-NEXT: [[SIGNBIT:%.*]] = lshr i32 [[X:%.*]], 31
281 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT]])
282 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp sgt i32 [[X]], -1
283 ; CHECK-NEXT: ret i1 [[ISNEG]]
285 %signbit = lshr i32 %x, 31
286 call void @use32(i32 %signbit)
287 %isneg = icmp eq i32 %signbit, 0
290 define i1 @signed_sign_bit_extract(i32 %x) {
291 ; CHECK-LABEL: @signed_sign_bit_extract(
292 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i32 [[X:%.*]], 0
293 ; CHECK-NEXT: ret i1 [[ISNEG]]
295 %signsmear = ashr i32 %x, 31
296 %isneg = icmp ne i32 %signsmear, 0
299 define i1 @signed_sign_bit_extract_extrause(i32 %x) {
300 ; CHECK-LABEL: @signed_sign_bit_extract_extrause(
301 ; CHECK-NEXT: [[SIGNSMEAR:%.*]] = ashr i32 [[X:%.*]], 31
302 ; CHECK-NEXT: call void @use32(i32 [[SIGNSMEAR]])
303 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i32 [[X]], 0
304 ; CHECK-NEXT: ret i1 [[ISNEG]]
306 %signsmear = ashr i32 %x, 31
307 call void @use32(i32 %signsmear)
308 %isneg = icmp ne i32 %signsmear, 0
311 define i1 @unsigned_sign_bit_extract_with_trunc(i64 %x) {
312 ; CHECK-LABEL: @unsigned_sign_bit_extract_with_trunc(
313 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i64 [[X:%.*]], 0
314 ; CHECK-NEXT: ret i1 [[ISNEG]]
316 %signbit = lshr i64 %x, 63
317 %signbit_narrow = trunc i64 %signbit to i32
318 %isneg = icmp ne i32 %signbit_narrow, 0
321 define i1 @unsigned_sign_bit_extract_with_trunc_extrause(i64 %x) {
322 ; CHECK-LABEL: @unsigned_sign_bit_extract_with_trunc_extrause(
323 ; CHECK-NEXT: [[SIGNBIT:%.*]] = lshr i64 [[X:%.*]], 63
324 ; CHECK-NEXT: call void @use64(i64 [[SIGNBIT]])
325 ; CHECK-NEXT: [[SIGNBIT_NARROW:%.*]] = trunc i64 [[SIGNBIT]] to i32
326 ; CHECK-NEXT: call void @use32(i32 [[SIGNBIT_NARROW]])
327 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i64 [[X]], 0
328 ; CHECK-NEXT: ret i1 [[ISNEG]]
330 %signbit = lshr i64 %x, 63
331 call void @use64(i64 %signbit)
332 %signbit_narrow = trunc i64 %signbit to i32
333 call void @use32(i32 %signbit_narrow)
334 %isneg = icmp ne i32 %signbit_narrow, 0
337 define i1 @signed_sign_bit_extract_trunc(i64 %x) {
338 ; CHECK-LABEL: @signed_sign_bit_extract_trunc(
339 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i64 [[X:%.*]], 0
340 ; CHECK-NEXT: ret i1 [[ISNEG]]
342 %signsmear = ashr i64 %x, 63
343 %signsmear_narrow = trunc i64 %signsmear to i32
344 %isneg = icmp ne i32 %signsmear_narrow, 0
347 define i1 @signed_sign_bit_extract_trunc_extrause(i64 %x) {
348 ; CHECK-LABEL: @signed_sign_bit_extract_trunc_extrause(
349 ; CHECK-NEXT: [[SIGNSMEAR:%.*]] = ashr i64 [[X:%.*]], 63
350 ; CHECK-NEXT: call void @use64(i64 [[SIGNSMEAR]])
351 ; CHECK-NEXT: [[SIGNSMEAR_NARROW:%.*]] = trunc i64 [[SIGNSMEAR]] to i32
352 ; CHECK-NEXT: call void @use32(i32 [[SIGNSMEAR_NARROW]])
353 ; CHECK-NEXT: [[ISNEG:%.*]] = icmp slt i64 [[X]], 0
354 ; CHECK-NEXT: ret i1 [[ISNEG]]
356 %signsmear = ashr i64 %x, 63
357 call void @use64(i64 %signsmear)
358 %signsmear_narrow = trunc i64 %signsmear to i32
359 call void @use32(i32 %signsmear_narrow)
360 %isneg = icmp ne i32 %signsmear_narrow, 0