exint 0.1.4

An implementation of generic signed and unsigned integers.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
#![allow(non_camel_case_types)]
#![feature(core_intrinsics)]
#![feature(funnel_shifts)]

type int = i8;
type uint = u8;

// -----------------------------------------------------------------------------
// Bitwise Operations
// -----------------------------------------------------------------------------

// CHECK-LABEL: define noundef i8 @band
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn band(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = and i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  a & b
}

// CHECK-LABEL: define noundef i8 @bor
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn bor(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = or i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  a | b
}

// CHECK-LABEL: define noundef i8 @bxor
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn bxor(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = xor i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  a ^ b
}

// CHECK-LABEL: define noundef i8 @bnot
// CHECK-SAME: (i8 noundef %[[A:.+]])
#[unsafe(no_mangle)]
pub fn bnot(a: uint) -> uint {
  // CHECK: %[[B:.+]] = xor i8 %[[A]], -1
  // CHECK: ret i8 %[[B]]
  !a
}

// -----------------------------------------------------------------------------
// Comparison Operations
// -----------------------------------------------------------------------------

// CHECK-LABEL: define noundef zeroext i1 @eq
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn eq(a: uint, b: uint) -> bool {
  // CHECK: %[[C:.+]] = icmp eq i8 %[[A]], %[[B]]
  // CHECK: ret i1 %[[C]]
  a == b
}

// CHECK-LABEL: define noundef range(i8 -1, 2) i8 @ucmp
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn ucmp(a: uint, b: uint) -> ::core::cmp::Ordering {
  // CHECK: %[[C:.+]] = tail call i8 @llvm.ucmp.i8.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret i8 %[[C]]
  a.cmp(&b)
}

// CHECK-LABEL: define noundef range(i8 -1, 2) i8 @scmp
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn scmp(a: int, b: int) -> ::core::cmp::Ordering {
  // CHECK: %[[C:.+]] = tail call i8 @llvm.scmp.i8.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret i8 %[[C]]
  a.cmp(&b)
}

// -----------------------------------------------------------------------------
// Bit Conversion Operations
// -----------------------------------------------------------------------------

// CHECK-LABEL: define noundef i8 @swap1
// CHECK-SAME: (i8 noundef %[[A:.+]])
#[unsafe(no_mangle)]
pub fn swap1(a: uint) -> uint {
  // CHECK: %[[B:.+]] = tail call i8 @llvm.bitreverse.i8(i8 %[[A]])
  // CHECK: ret i8 %[[B]]
  ::core::intrinsics::bitreverse(a)
}

// CHECK-LABEL: define noundef i8 @swap8
// CHECK-SAME: (i8 noundef returned %[[A:.+]])
#[unsafe(no_mangle)]
pub fn swap8(a: uint) -> uint {
  // CHECK: ret i8 %[[A]]
  ::core::intrinsics::bswap(a)
}

// CHECK-LABEL: define noundef i8 @rotl
// CHECK-SAME: (i8 noundef %[[A:.+]], i32 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn rotl(a: uint, b: u32) -> uint {
  // CHECK: %[[C:.+]] = trunc i32 %[[B]] to i8
  // CHECK: %[[D:.+]] = tail call noundef i8 @llvm.fshl.i8(i8 %[[A]], i8 %[[A]], i8 %[[C]])
  // CHECK: ret i8 %[[D]]
  ::core::intrinsics::rotate_left(a, b)
}

// CHECK-LABEL: define noundef i8 @rotr
// CHECK-SAME: (i8 noundef %[[A:.+]], i32 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn rotr(a: uint, b: u32) -> uint {
  // CHECK: %[[C:.+]] = trunc i32 %[[B]] to i8
  // CHECK: %[[D:.+]] = tail call noundef i8 @llvm.fshr.i8(i8 %[[A]], i8 %[[A]], i8 %[[C]])
  // CHECK: ret i8 %[[D]]
  ::core::intrinsics::rotate_right(a, b)
}

// -----------------------------------------------------------------------------
// Bit Inspection Operations
// -----------------------------------------------------------------------------

// CHECK-LABEL: define noundef range(i32 0, 9) i32 @ctpop
// CHECK-SAME: (i8 noundef %[[A:.+]])
#[unsafe(no_mangle)]
pub fn ctpop(a: uint) -> u32 {
  // CHECK: %[[B:.+]] = tail call range(i8 0, 9) i8 @llvm.ctpop.i8(i8 %[[A]])
  // CHECK: %[[C:.+]] = zext nneg i8 %[[B]] to i32
  // CHECK: ret i32 %[[C]]
  ::core::intrinsics::ctpop(a)
}

// CHECK-LABEL: define noundef range(i32 0, 9) i32 @ctlz
// CHECK-SAME: (i8 noundef %[[A:.+]])
#[unsafe(no_mangle)]
pub fn ctlz(a: uint) -> u32 {
  // CHECK: %[[B:.+]] = tail call range(i8 0, 9) i8 @llvm.ctlz.i8(i8 %[[A]], i1 false)
  // CHECK: %[[C:.+]] = zext nneg i8 %[[B]] to i32
  // CHECK: ret i32 %[[C]]
  ::core::intrinsics::ctlz(a)
}

// CHECK-LABEL: define noundef range(i32 0, 9) i32 @cttz
// CHECK-SAME: (i8 noundef %[[A:.+]])
#[unsafe(no_mangle)]
pub fn cttz(a: uint) -> u32 {
  // CHECK: %[[B:.+]] = tail call range(i8 0, 9) i8 @llvm.cttz.i8(i8 %[[A]], i1 false)
  // CHECK: %[[C:.+]] = zext nneg i8 %[[B]] to i32
  // CHECK: ret i32 %[[C]]
  ::core::intrinsics::cttz(a)
}

// CHECK-LABEL: define noundef range(i32 0, 8) i32 @ctlz_nonzero
// CHECK-SAME: (i8 noundef %[[A:.+]])
#[unsafe(no_mangle)]
pub fn ctlz_nonzero(a: uint) -> u32 {
  // CHECK: %[[B:.+]] = tail call range(i8 0, 9) i8 @llvm.ctlz.i8(i8 %[[A]], i1 true)
  // CHECK: %[[C:.+]] = zext nneg i8 %[[B]] to i32
  // CHECK: ret i32 %[[C]]
  unsafe { ::core::intrinsics::ctlz_nonzero(a) }
}

// CHECK-LABEL: define noundef range(i32 0, 8) i32 @cttz_nonzero
// CHECK-SAME: (i8 noundef %[[A:.+]])
#[unsafe(no_mangle)]
pub fn cttz_nonzero(a: uint) -> u32 {
  // CHECK: %[[B:.+]] = tail call range(i8 0, 9) i8 @llvm.cttz.i8(i8 %[[A]], i1 true)
  // CHECK: %[[C:.+]] = zext nneg i8 %[[B]] to i32
  // CHECK: ret i32 %[[C]]
  unsafe { ::core::intrinsics::cttz_nonzero(a) }
}

// -----------------------------------------------------------------------------
// Overflowing Operations
// -----------------------------------------------------------------------------

// CHECK-LABEL: define { i8, i1 } @overflowing_uadd
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn overflowing_uadd(a: uint, b: uint) -> (uint, bool) {
  // CHECK: %[[C:.+]] = add i8 %[[B]], %[[A]]
  // CHECK: %[[D:.+]] = icmp ult i8 %[[C]], %[[A]]
  // CHECK: %[[E:.+]] = insertvalue { i8, i1 } poison, i8 %[[C]], 0
  // CHECK: %[[F:.+]] = insertvalue { i8, i1 } %[[E]], i1 %[[D]], 1
  // CHECK: ret { i8, i1 } %[[F]]
  ::core::intrinsics::add_with_overflow(a, b)
}

// CHECK-LABEL: define { i8, i1 } @overflowing_usub
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn overflowing_usub(a: uint, b: uint) -> (uint, bool) {
  // CHECK: %[[C:.+]] = sub i8 %[[A]], %[[B]]
  // CHECK: %[[D:.+]] = icmp ult i8 %[[A]], %[[B]]
  // CHECK: %[[E:.+]] = insertvalue { i8, i1 } poison, i8 %[[C]], 0
  // CHECK: %[[F:.+]] = insertvalue { i8, i1 } %[[E]], i1 %[[D]], 1
  // CHECK: ret { i8, i1 } %[[F]]
  ::core::intrinsics::sub_with_overflow(a, b)
}

// CHECK-LABEL: define noundef { i8, i1 } @overflowing_umul
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn overflowing_umul(a: uint, b: uint) -> (uint, bool) {
  // CHECK: %[[C:.+]] = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret { i8, i1 } %[[C]]
  ::core::intrinsics::mul_with_overflow(a, b)
}

// CHECK-LABEL: define noundef { i8, i1 } @overflowing_sadd
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn overflowing_sadd(a: int, b: int) -> (int, bool) {
  // CHECK: %[[C:.+]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret { i8, i1 } %[[C]]
  ::core::intrinsics::add_with_overflow(a, b)
}

// CHECK-LABEL: define noundef { i8, i1 } @overflowing_ssub
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn overflowing_ssub(a: int, b: int) -> (int, bool) {
  // CHECK: %[[C:.+]] = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret { i8, i1 } %[[C]]
  ::core::intrinsics::sub_with_overflow(a, b)
}

// CHECK-LABEL: define noundef { i8, i1 } @overflowing_smul
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn overflowing_smul(a: int, b: int) -> (int, bool) {
  // CHECK: %[[C:.+]] = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret { i8, i1 } %[[C]]
  ::core::intrinsics::mul_with_overflow(a, b)
}

// -----------------------------------------------------------------------------
// Saturating Operations
// -----------------------------------------------------------------------------

// CHECK-LABEL: define noundef i8 @saturating_uadd
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn saturating_uadd(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = tail call i8 @llvm.uadd.sat.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret i8 %[[C]]
  ::core::intrinsics::saturating_add(a, b)
}

// CHECK-LABEL: define noundef i8 @saturating_usub
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn saturating_usub(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = tail call i8 @llvm.usub.sat.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret i8 %[[C]]
  ::core::intrinsics::saturating_sub(a, b)
}

// CHECK-LABEL: define noundef i8 @saturating_sadd
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn saturating_sadd(a: int, b: int) -> int {
  // CHECK: %[[C:.+]] = tail call i8 @llvm.sadd.sat.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret i8 %[[C]]
  ::core::intrinsics::saturating_add(a, b)
}

// CHECK-LABEL: define noundef i8 @saturating_ssub
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn saturating_ssub(a: int, b: int) -> int {
  // CHECK: %[[C:.+]] = tail call i8 @llvm.ssub.sat.i8(i8 %[[A]], i8 %[[B]])
  // CHECK: ret i8 %[[C]]
  ::core::intrinsics::saturating_sub(a, b)
}

// -----------------------------------------------------------------------------
// Unchecked Operations
// -----------------------------------------------------------------------------

// CHECK-LABEL: define noundef i8 @unchecked_uadd
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_uadd(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = add nuw i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_add(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_usub
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_usub(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = sub nuw i8 %[[A]], %[[B]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_sub(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_umul
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_umul(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = mul nuw i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_mul(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_udiv
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_udiv(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = udiv i8 %[[A]], %[[B]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_div(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_udiv_exact
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_udiv_exact(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = udiv exact i8 %[[A]], %[[B]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::exact_div(a, b) }
}

// CHECK-LABEL: define noundef range(i8 0, -1) i8 @unchecked_urem
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_urem(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = urem i8 %[[A]], %[[B]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_rem(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_sadd
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_sadd(a: int, b: int) -> int {
  // CHECK: %[[C:.+]] = add nsw i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_add(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_ssub
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_ssub(a: int, b: int) -> int {
  // CHECK: %[[C:.+]] = sub nsw i8 %[[A]], %[[B]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_sub(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_smul
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_smul(a: int, b: int) -> int {
  // CHECK: %[[C:.+]] = mul nsw i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_mul(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_sdiv
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_sdiv(a: int, b: int) -> int {
  // CHECK: %[[C:.+]] = sdiv i8 %[[A]], %[[B]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_div(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_sdiv_exact
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_sdiv_exact(a: int, b: int) -> int {
  // CHECK: %[[C:.+]] = sdiv exact i8 %[[A]], %[[B]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::exact_div(a, b) }
}

// CHECK-LABEL: define noundef range(i8 -127, -128) i8 @unchecked_srem
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_srem(a: int, b: int) -> int {
  // CHECK: %[[C:.+]] = srem i8 %[[A]], %[[B]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::unchecked_rem(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_shl
// CHECK-SAME: (i8 noundef %[[A:.+]], i32 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_shl(a: uint, b: u32) -> uint {
  // CHECK: %[[C:.+]] = trunc nuw i32 %[[B]] to i8
  // CHECK: %[[D:.+]] = shl i8 %[[A]], %[[C]]
  // CHECK: ret i8 %[[D]]
  unsafe { ::core::intrinsics::unchecked_shl(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_lshr
// CHECK-SAME: (i8 noundef %[[A:.+]], i32 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_lshr(a: uint, b: u32) -> uint {
  // CHECK: %[[C:.+]] = trunc nuw i32 %[[B]] to i8
  // CHECK: %[[D:.+]] = lshr i8 %[[A]], %[[C]]
  // CHECK: ret i8 %[[D]]
  unsafe { ::core::intrinsics::unchecked_shr(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_ashr
// CHECK-SAME: (i8 noundef %[[A:.+]], i32 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_ashr(a: int, b: u32) -> int {
  // CHECK: %[[C:.+]] = trunc nuw i32 %[[B]] to i8
  // CHECK: %[[D:.+]] = ashr i8 %[[A]], %[[C]]
  // CHECK: ret i8 %[[D]]
  unsafe { ::core::intrinsics::unchecked_shr(a, b) }
}

// CHECK-LABEL: define noundef i8 @unchecked_fshl
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]], i32 noundef %[[C:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_fshl(a: uint, b: uint, c: u32) -> uint {
  // CHECK: %[[D:.+]] = trunc i32 %[[C]] to i8
  // CHECK: %[[E:.+]] = tail call i8 @llvm.fshl.i8(i8 %[[A]], i8 %[[B]], i8 %[[D]])
  // CHECK: ret i8 %[[E]]
  unsafe { ::core::intrinsics::unchecked_funnel_shl(a, b, c) }
}

// CHECK-LABEL: define noundef i8 @unchecked_fshr
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]], i32 noundef %[[C:.+]])
#[unsafe(no_mangle)]
pub fn unchecked_fshr(a: uint, b: uint, c: u32) -> uint {
  // CHECK: %[[D:.+]] = trunc i32 %[[C]] to i8
  // CHECK: %[[E:.+]] = tail call i8 @llvm.fshr.i8(i8 %[[A]], i8 %[[B]], i8 %[[D]])
  // CHECK: ret i8 %[[E]]
  unsafe { ::core::intrinsics::unchecked_funnel_shr(a, b, c) }
}

// -----------------------------------------------------------------------------
// Wrapping Operations
// -----------------------------------------------------------------------------

// CHECK-LABEL: define noundef i8 @wrapping_add
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn wrapping_add(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = add i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  ::core::intrinsics::wrapping_add(a, b)
}

// CHECK-LABEL: define noundef i8 @wrapping_sub
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn wrapping_sub(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = sub i8 %[[A]], %[[B]]
  // CHECK: ret i8 %[[C]]
  ::core::intrinsics::wrapping_sub(a, b)
}

// CHECK-LABEL: define noundef i8 @wrapping_mul
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn wrapping_mul(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = mul i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  ::core::intrinsics::wrapping_mul(a, b)
}

// -----------------------------------------------------------------------------
// Misc. Operations
// -----------------------------------------------------------------------------

// CHECK-LABEL: define noundef i8 @disjoint_bor
// CHECK-SAME: (i8 noundef %[[A:.+]], i8 noundef %[[B:.+]])
#[unsafe(no_mangle)]
pub fn disjoint_bor(a: uint, b: uint) -> uint {
  // CHECK: %[[C:.+]] = or disjoint i8 %[[B]], %[[A]]
  // CHECK: ret i8 %[[C]]
  unsafe { ::core::intrinsics::disjoint_bitor(a, b) }
}