fixed_point_sub.c
23.3 KB
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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
short _Accum sa;
_Accum a, a2, a3, a4;
long _Accum la;
unsigned short _Accum usa;
unsigned _Accum ua;
unsigned long _Accum ula;
short _Fract sf;
_Fract f;
long _Fract lf;
unsigned short _Fract usf;
unsigned _Fract uf;
unsigned long _Fract ulf;
_Sat short _Accum sa_sat;
_Sat _Accum a_sat;
_Sat long _Accum la_sat;
_Sat unsigned short _Accum usa_sat;
_Sat unsigned _Accum ua_sat;
_Sat unsigned long _Accum ula_sat;
_Sat unsigned _Fract uf_sat;
int i;
unsigned int ui;
_Bool b;
// CHECK-LABEL: @ssub_sasasa(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP2:%.*]] = sub i16 [[TMP0]], [[TMP1]]
// CHECK-NEXT: store i16 [[TMP2]], i16* @sa, align 2
// CHECK-NEXT: ret void
//
void ssub_sasasa() {
sa = sa - sa;
}
// CHECK-LABEL: @ssub_asaa(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @a, align 4
// CHECK-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i32
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i32 [[RESIZE]], 8
// CHECK-NEXT: [[TMP2:%.*]] = sub i32 [[UPSCALE]], [[TMP1]]
// CHECK-NEXT: store i32 [[TMP2]], i32* @a, align 4
// CHECK-NEXT: ret void
//
void ssub_asaa() {
a = sa - a;
}
// CHECK-LABEL: @ssub_sasasf(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i8, i8* @sf, align 1
// CHECK-NEXT: [[RESIZE:%.*]] = sext i8 [[TMP1]] to i16
// CHECK-NEXT: [[TMP2:%.*]] = sub i16 [[TMP0]], [[RESIZE]]
// CHECK-NEXT: store i16 [[TMP2]], i16* @sa, align 2
// CHECK-NEXT: ret void
//
void ssub_sasasf() {
sa = sa - sf;
}
// CHECK-LABEL: @ssub_sasaf(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i16, i16* @f, align 2
// CHECK-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i24
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i24 [[RESIZE]], 8
// CHECK-NEXT: [[RESIZE1:%.*]] = sext i16 [[TMP1]] to i24
// CHECK-NEXT: [[TMP2:%.*]] = sub i24 [[UPSCALE]], [[RESIZE1]]
// CHECK-NEXT: [[DOWNSCALE:%.*]] = ashr i24 [[TMP2]], 8
// CHECK-NEXT: [[RESIZE2:%.*]] = trunc i24 [[DOWNSCALE]] to i16
// CHECK-NEXT: store i16 [[RESIZE2]], i16* @sa, align 2
// CHECK-NEXT: ret void
//
void ssub_sasaf() {
sa = sa - f;
}
// CHECK-LABEL: @ssub_aasf(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* @a, align 4
// CHECK-NEXT: [[TMP1:%.*]] = load i8, i8* @sf, align 1
// CHECK-NEXT: [[RESIZE:%.*]] = sext i8 [[TMP1]] to i32
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i32 [[RESIZE]], 8
// CHECK-NEXT: [[TMP2:%.*]] = sub i32 [[TMP0]], [[UPSCALE]]
// CHECK-NEXT: store i32 [[TMP2]], i32* @a, align 4
// CHECK-NEXT: ret void
//
void ssub_aasf() {
a = a - sf;
}
// CHECK-LABEL: @ssub_aalf(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* @a, align 4
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @lf, align 4
// CHECK-NEXT: [[RESIZE:%.*]] = sext i32 [[TMP0]] to i48
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i48 [[RESIZE]], 16
// CHECK-NEXT: [[RESIZE1:%.*]] = sext i32 [[TMP1]] to i48
// CHECK-NEXT: [[TMP2:%.*]] = sub i48 [[UPSCALE]], [[RESIZE1]]
// CHECK-NEXT: [[DOWNSCALE:%.*]] = ashr i48 [[TMP2]], 16
// CHECK-NEXT: [[RESIZE2:%.*]] = trunc i48 [[DOWNSCALE]] to i32
// CHECK-NEXT: store i32 [[RESIZE2]], i32* @a, align 4
// CHECK-NEXT: ret void
//
void ssub_aalf() {
a = a - lf;
}
// SIGNED-LABEL: @ssub_sasausa(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// SIGNED-NEXT: [[TMP1:%.*]] = load i16, i16* @usa, align 2
// SIGNED-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i17
// SIGNED-NEXT: [[UPSCALE:%.*]] = shl i17 [[RESIZE]], 1
// SIGNED-NEXT: [[RESIZE1:%.*]] = zext i16 [[TMP1]] to i17
// SIGNED-NEXT: [[TMP2:%.*]] = sub i17 [[UPSCALE]], [[RESIZE1]]
// SIGNED-NEXT: [[DOWNSCALE:%.*]] = ashr i17 [[TMP2]], 1
// SIGNED-NEXT: [[RESIZE2:%.*]] = trunc i17 [[DOWNSCALE]] to i16
// SIGNED-NEXT: store i16 [[RESIZE2]], i16* @sa, align 2
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @ssub_sasausa(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i16, i16* @usa, align 2
// UNSIGNED-NEXT: [[TMP2:%.*]] = sub i16 [[TMP0]], [[TMP1]]
// UNSIGNED-NEXT: store i16 [[TMP2]], i16* @sa, align 2
// UNSIGNED-NEXT: ret void
//
void ssub_sasausa() {
sa = sa - usa;
}
// SIGNED-LABEL: @ssub_asaua(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// SIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @ua, align 4
// SIGNED-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i33
// SIGNED-NEXT: [[UPSCALE:%.*]] = shl i33 [[RESIZE]], 9
// SIGNED-NEXT: [[RESIZE1:%.*]] = zext i32 [[TMP1]] to i33
// SIGNED-NEXT: [[TMP2:%.*]] = sub i33 [[UPSCALE]], [[RESIZE1]]
// SIGNED-NEXT: [[DOWNSCALE:%.*]] = ashr i33 [[TMP2]], 1
// SIGNED-NEXT: [[RESIZE2:%.*]] = trunc i33 [[DOWNSCALE]] to i32
// SIGNED-NEXT: store i32 [[RESIZE2]], i32* @a, align 4
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @ssub_asaua(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @ua, align 4
// UNSIGNED-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i32
// UNSIGNED-NEXT: [[UPSCALE:%.*]] = shl i32 [[RESIZE]], 8
// UNSIGNED-NEXT: [[TMP2:%.*]] = sub i32 [[UPSCALE]], [[TMP1]]
// UNSIGNED-NEXT: store i32 [[TMP2]], i32* @a, align 4
// UNSIGNED-NEXT: ret void
//
void ssub_asaua() {
a = sa - ua;
}
// SIGNED-LABEL: @ssub_sasausf(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// SIGNED-NEXT: [[TMP1:%.*]] = load i8, i8* @usf, align 1
// SIGNED-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i17
// SIGNED-NEXT: [[UPSCALE:%.*]] = shl i17 [[RESIZE]], 1
// SIGNED-NEXT: [[RESIZE1:%.*]] = zext i8 [[TMP1]] to i17
// SIGNED-NEXT: [[TMP2:%.*]] = sub i17 [[UPSCALE]], [[RESIZE1]]
// SIGNED-NEXT: [[DOWNSCALE:%.*]] = ashr i17 [[TMP2]], 1
// SIGNED-NEXT: [[RESIZE2:%.*]] = trunc i17 [[DOWNSCALE]] to i16
// SIGNED-NEXT: store i16 [[RESIZE2]], i16* @sa, align 2
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @ssub_sasausf(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i8, i8* @usf, align 1
// UNSIGNED-NEXT: [[RESIZE:%.*]] = zext i8 [[TMP1]] to i16
// UNSIGNED-NEXT: [[TMP2:%.*]] = sub i16 [[TMP0]], [[RESIZE]]
// UNSIGNED-NEXT: store i16 [[TMP2]], i16* @sa, align 2
// UNSIGNED-NEXT: ret void
//
void ssub_sasausf() {
sa = sa - usf;
}
// SIGNED-LABEL: @ssub_sasaulf(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// SIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @ulf, align 4
// SIGNED-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i41
// SIGNED-NEXT: [[UPSCALE:%.*]] = shl i41 [[RESIZE]], 25
// SIGNED-NEXT: [[RESIZE1:%.*]] = zext i32 [[TMP1]] to i41
// SIGNED-NEXT: [[TMP2:%.*]] = sub i41 [[UPSCALE]], [[RESIZE1]]
// SIGNED-NEXT: [[DOWNSCALE:%.*]] = ashr i41 [[TMP2]], 25
// SIGNED-NEXT: [[RESIZE2:%.*]] = trunc i41 [[DOWNSCALE]] to i16
// SIGNED-NEXT: store i16 [[RESIZE2]], i16* @sa, align 2
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @ssub_sasaulf(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @ulf, align 4
// UNSIGNED-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i40
// UNSIGNED-NEXT: [[UPSCALE:%.*]] = shl i40 [[RESIZE]], 24
// UNSIGNED-NEXT: [[RESIZE1:%.*]] = zext i32 [[TMP1]] to i40
// UNSIGNED-NEXT: [[TMP2:%.*]] = sub i40 [[UPSCALE]], [[RESIZE1]]
// UNSIGNED-NEXT: [[DOWNSCALE:%.*]] = ashr i40 [[TMP2]], 24
// UNSIGNED-NEXT: [[RESIZE2:%.*]] = trunc i40 [[DOWNSCALE]] to i16
// UNSIGNED-NEXT: store i16 [[RESIZE2]], i16* @sa, align 2
// UNSIGNED-NEXT: ret void
//
void ssub_sasaulf() {
sa = sa - ulf;
}
// CHECK-LABEL: @ssub_aaaaa(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* @a, align 4
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @a2, align 4
// CHECK-NEXT: [[TMP2:%.*]] = sub i32 [[TMP0]], [[TMP1]]
// CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* @a3, align 4
// CHECK-NEXT: [[TMP4:%.*]] = sub i32 [[TMP2]], [[TMP3]]
// CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* @a4, align 4
// CHECK-NEXT: [[TMP6:%.*]] = sub i32 [[TMP4]], [[TMP5]]
// CHECK-NEXT: store i32 [[TMP6]], i32* @a, align 4
// CHECK-NEXT: ret void
//
void ssub_aaaaa() {
a = a - a2 - a3 - a4;
}
// CHECK-LABEL: @usub_usausausa(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i16, i16* @usa, align 2
// CHECK-NEXT: [[TMP2:%.*]] = sub i16 [[TMP0]], [[TMP1]]
// CHECK-NEXT: store i16 [[TMP2]], i16* @usa, align 2
// CHECK-NEXT: ret void
//
void usub_usausausa() {
usa = usa - usa;
}
// CHECK-LABEL: @usub_uausaua(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @ua, align 4
// CHECK-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP0]] to i32
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i32 [[RESIZE]], 8
// CHECK-NEXT: [[TMP2:%.*]] = sub i32 [[UPSCALE]], [[TMP1]]
// CHECK-NEXT: store i32 [[TMP2]], i32* @ua, align 4
// CHECK-NEXT: ret void
//
void usub_uausaua() {
ua = usa - ua;
}
// CHECK-LABEL: @usub_usausausf(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i8, i8* @usf, align 1
// CHECK-NEXT: [[RESIZE:%.*]] = zext i8 [[TMP1]] to i16
// CHECK-NEXT: [[TMP2:%.*]] = sub i16 [[TMP0]], [[RESIZE]]
// CHECK-NEXT: store i16 [[TMP2]], i16* @usa, align 2
// CHECK-NEXT: ret void
//
void usub_usausausf() {
usa = usa - usf;
}
// CHECK-LABEL: @usub_usausauf(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i16, i16* @uf, align 2
// CHECK-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP0]] to i24
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i24 [[RESIZE]], 8
// CHECK-NEXT: [[RESIZE1:%.*]] = zext i16 [[TMP1]] to i24
// CHECK-NEXT: [[TMP2:%.*]] = sub i24 [[UPSCALE]], [[RESIZE1]]
// CHECK-NEXT: [[DOWNSCALE:%.*]] = lshr i24 [[TMP2]], 8
// CHECK-NEXT: [[RESIZE2:%.*]] = trunc i24 [[DOWNSCALE]] to i16
// CHECK-NEXT: store i16 [[RESIZE2]], i16* @usa, align 2
// CHECK-NEXT: ret void
//
void usub_usausauf() {
usa = usa - uf;
}
// CHECK-LABEL: @int_sasai(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @i, align 4
// CHECK-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i39
// CHECK-NEXT: [[RESIZE1:%.*]] = sext i32 [[TMP1]] to i39
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i39 [[RESIZE1]], 7
// CHECK-NEXT: [[TMP2:%.*]] = sub i39 [[RESIZE]], [[UPSCALE]]
// CHECK-NEXT: [[RESIZE2:%.*]] = trunc i39 [[TMP2]] to i16
// CHECK-NEXT: store i16 [[RESIZE2]], i16* @sa, align 2
// CHECK-NEXT: ret void
//
void int_sasai() {
sa = sa - i;
}
// CHECK-LABEL: @int_sasaui(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @ui, align 4
// CHECK-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i40
// CHECK-NEXT: [[RESIZE1:%.*]] = zext i32 [[TMP1]] to i40
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i40 [[RESIZE1]], 7
// CHECK-NEXT: [[TMP2:%.*]] = sub i40 [[RESIZE]], [[UPSCALE]]
// CHECK-NEXT: [[RESIZE2:%.*]] = trunc i40 [[TMP2]] to i16
// CHECK-NEXT: store i16 [[RESIZE2]], i16* @sa, align 2
// CHECK-NEXT: ret void
//
void int_sasaui() {
sa = sa - ui;
}
// SIGNED-LABEL: @int_usausai(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// SIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @i, align 4
// SIGNED-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP0]] to i40
// SIGNED-NEXT: [[RESIZE1:%.*]] = sext i32 [[TMP1]] to i40
// SIGNED-NEXT: [[UPSCALE:%.*]] = shl i40 [[RESIZE1]], 8
// SIGNED-NEXT: [[TMP2:%.*]] = sub i40 [[RESIZE]], [[UPSCALE]]
// SIGNED-NEXT: [[RESIZE2:%.*]] = trunc i40 [[TMP2]] to i16
// SIGNED-NEXT: store i16 [[RESIZE2]], i16* @usa, align 2
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @int_usausai(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @i, align 4
// UNSIGNED-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP0]] to i39
// UNSIGNED-NEXT: [[RESIZE1:%.*]] = sext i32 [[TMP1]] to i39
// UNSIGNED-NEXT: [[UPSCALE:%.*]] = shl i39 [[RESIZE1]], 7
// UNSIGNED-NEXT: [[TMP2:%.*]] = sub i39 [[RESIZE]], [[UPSCALE]]
// UNSIGNED-NEXT: [[RESIZE2:%.*]] = trunc i39 [[TMP2]] to i16
// UNSIGNED-NEXT: store i16 [[RESIZE2]], i16* @usa, align 2
// UNSIGNED-NEXT: ret void
//
void int_usausai() {
usa = usa - i;
}
// SIGNED-LABEL: @int_usausaui(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// SIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @ui, align 4
// SIGNED-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP0]] to i40
// SIGNED-NEXT: [[RESIZE1:%.*]] = zext i32 [[TMP1]] to i40
// SIGNED-NEXT: [[UPSCALE:%.*]] = shl i40 [[RESIZE1]], 8
// SIGNED-NEXT: [[TMP2:%.*]] = sub i40 [[RESIZE]], [[UPSCALE]]
// SIGNED-NEXT: [[RESIZE2:%.*]] = trunc i40 [[TMP2]] to i16
// SIGNED-NEXT: store i16 [[RESIZE2]], i16* @usa, align 2
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @int_usausaui(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @ui, align 4
// UNSIGNED-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP0]] to i39
// UNSIGNED-NEXT: [[RESIZE1:%.*]] = zext i32 [[TMP1]] to i39
// UNSIGNED-NEXT: [[UPSCALE:%.*]] = shl i39 [[RESIZE1]], 7
// UNSIGNED-NEXT: [[TMP2:%.*]] = sub i39 [[RESIZE]], [[UPSCALE]]
// UNSIGNED-NEXT: [[RESIZE2:%.*]] = trunc i39 [[TMP2]] to i16
// UNSIGNED-NEXT: store i16 [[RESIZE2]], i16* @usa, align 2
// UNSIGNED-NEXT: ret void
//
void int_usausaui() {
usa = usa - ui;
}
// CHECK-LABEL: @int_lflfui(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* @lf, align 4
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @ui, align 4
// CHECK-NEXT: [[RESIZE:%.*]] = sext i32 [[TMP0]] to i64
// CHECK-NEXT: [[RESIZE1:%.*]] = zext i32 [[TMP1]] to i64
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i64 [[RESIZE1]], 31
// CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[RESIZE]], [[UPSCALE]]
// CHECK-NEXT: [[RESIZE2:%.*]] = trunc i64 [[TMP2]] to i32
// CHECK-NEXT: store i32 [[RESIZE2]], i32* @lf, align 4
// CHECK-NEXT: ret void
//
void int_lflfui() {
lf = lf - ui;
}
// CHECK-LABEL: @int_aab(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* @a, align 4
// CHECK-NEXT: [[TMP1:%.*]] = load i8, i8* @b, align 1
// CHECK-NEXT: [[TOBOOL:%.*]] = trunc i8 [[TMP1]] to i1
// CHECK-NEXT: [[CONV:%.*]] = zext i1 [[TOBOOL]] to i32
// CHECK-NEXT: [[RESIZE:%.*]] = sext i32 [[TMP0]] to i47
// CHECK-NEXT: [[RESIZE1:%.*]] = sext i32 [[CONV]] to i47
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i47 [[RESIZE1]], 15
// CHECK-NEXT: [[TMP2:%.*]] = sub i47 [[RESIZE]], [[UPSCALE]]
// CHECK-NEXT: [[RESIZE2:%.*]] = trunc i47 [[TMP2]] to i32
// CHECK-NEXT: store i32 [[RESIZE2]], i32* @a, align 4
// CHECK-NEXT: ret void
//
void int_aab() {
a = a - b;
}
// CHECK-LABEL: @sat_sassasas(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i16, i16* @sa_sat, align 2
// CHECK-NEXT: [[TMP2:%.*]] = call i16 @llvm.ssub.sat.i16(i16 [[TMP0]], i16 [[TMP1]])
// CHECK-NEXT: store i16 [[TMP2]], i16* @sa_sat, align 2
// CHECK-NEXT: ret void
//
void sat_sassasas() {
sa_sat = sa - sa_sat;
}
// SIGNED-LABEL: @sat_usasusausas(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// SIGNED-NEXT: [[TMP1:%.*]] = load i16, i16* @usa_sat, align 2
// SIGNED-NEXT: [[TMP2:%.*]] = call i16 @llvm.usub.sat.i16(i16 [[TMP0]], i16 [[TMP1]])
// SIGNED-NEXT: store i16 [[TMP2]], i16* @usa_sat, align 2
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @sat_usasusausas(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @usa, align 2
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i16, i16* @usa_sat, align 2
// UNSIGNED-NEXT: [[TMP2:%.*]] = call i16 @llvm.ssub.sat.i16(i16 [[TMP0]], i16 [[TMP1]])
// UNSIGNED-NEXT: [[TMP3:%.*]] = icmp slt i16 [[TMP2]], 0
// UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP3]], i16 0, i16 [[TMP2]]
// UNSIGNED-NEXT: [[RESIZE:%.*]] = trunc i16 [[SATMIN]] to i15
// UNSIGNED-NEXT: [[RESIZE1:%.*]] = zext i15 [[RESIZE]] to i16
// UNSIGNED-NEXT: store i16 [[RESIZE1]], i16* @usa_sat, align 2
// UNSIGNED-NEXT: ret void
//
void sat_usasusausas() {
usa_sat = usa - usa_sat;
}
// SIGNED-LABEL: @sat_uasuausas(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i32, i32* @ua, align 4
// SIGNED-NEXT: [[TMP1:%.*]] = load i16, i16* @usa_sat, align 2
// SIGNED-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP1]] to i32
// SIGNED-NEXT: [[UPSCALE:%.*]] = shl i32 [[RESIZE]], 8
// SIGNED-NEXT: [[TMP2:%.*]] = call i32 @llvm.usub.sat.i32(i32 [[TMP0]], i32 [[UPSCALE]])
// SIGNED-NEXT: store i32 [[TMP2]], i32* @ua_sat, align 4
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @sat_uasuausas(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i32, i32* @ua, align 4
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i16, i16* @usa_sat, align 2
// UNSIGNED-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP1]] to i32
// UNSIGNED-NEXT: [[UPSCALE:%.*]] = shl i32 [[RESIZE]], 8
// UNSIGNED-NEXT: [[TMP2:%.*]] = call i32 @llvm.ssub.sat.i32(i32 [[TMP0]], i32 [[UPSCALE]])
// UNSIGNED-NEXT: [[TMP3:%.*]] = icmp slt i32 [[TMP2]], 0
// UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP3]], i32 0, i32 [[TMP2]]
// UNSIGNED-NEXT: [[RESIZE1:%.*]] = trunc i32 [[SATMIN]] to i31
// UNSIGNED-NEXT: [[RESIZE2:%.*]] = zext i31 [[RESIZE1]] to i32
// UNSIGNED-NEXT: store i32 [[RESIZE2]], i32* @ua_sat, align 4
// UNSIGNED-NEXT: ret void
//
void sat_uasuausas() {
ua_sat = ua - usa_sat;
}
// CHECK-LABEL: @sat_sassasi(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa_sat, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @i, align 4
// CHECK-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i39
// CHECK-NEXT: [[RESIZE1:%.*]] = sext i32 [[TMP1]] to i39
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i39 [[RESIZE1]], 7
// CHECK-NEXT: [[TMP2:%.*]] = call i39 @llvm.ssub.sat.i39(i39 [[RESIZE]], i39 [[UPSCALE]])
// CHECK-NEXT: [[TMP3:%.*]] = icmp sgt i39 [[TMP2]], 32767
// CHECK-NEXT: [[SATMAX:%.*]] = select i1 [[TMP3]], i39 32767, i39 [[TMP2]]
// CHECK-NEXT: [[TMP4:%.*]] = icmp slt i39 [[SATMAX]], -32768
// CHECK-NEXT: [[SATMIN:%.*]] = select i1 [[TMP4]], i39 -32768, i39 [[SATMAX]]
// CHECK-NEXT: [[RESIZE2:%.*]] = trunc i39 [[SATMIN]] to i16
// CHECK-NEXT: store i16 [[RESIZE2]], i16* @sa_sat, align 2
// CHECK-NEXT: ret void
//
void sat_sassasi() {
sa_sat = sa_sat - i;
}
// CHECK-LABEL: @sat_sassasui(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa_sat, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @ui, align 4
// CHECK-NEXT: [[RESIZE:%.*]] = sext i16 [[TMP0]] to i40
// CHECK-NEXT: [[RESIZE1:%.*]] = zext i32 [[TMP1]] to i40
// CHECK-NEXT: [[UPSCALE:%.*]] = shl i40 [[RESIZE1]], 7
// CHECK-NEXT: [[TMP2:%.*]] = call i40 @llvm.ssub.sat.i40(i40 [[RESIZE]], i40 [[UPSCALE]])
// CHECK-NEXT: [[TMP3:%.*]] = icmp sgt i40 [[TMP2]], 32767
// CHECK-NEXT: [[SATMAX:%.*]] = select i1 [[TMP3]], i40 32767, i40 [[TMP2]]
// CHECK-NEXT: [[TMP4:%.*]] = icmp slt i40 [[SATMAX]], -32768
// CHECK-NEXT: [[SATMIN:%.*]] = select i1 [[TMP4]], i40 -32768, i40 [[SATMAX]]
// CHECK-NEXT: [[RESIZE2:%.*]] = trunc i40 [[SATMIN]] to i16
// CHECK-NEXT: store i16 [[RESIZE2]], i16* @sa_sat, align 2
// CHECK-NEXT: ret void
//
void sat_sassasui() {
sa_sat = sa_sat - ui;
}
// SIGNED-LABEL: @sat_ufsufsufs(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @uf_sat, align 2
// SIGNED-NEXT: [[TMP1:%.*]] = load i16, i16* @uf_sat, align 2
// SIGNED-NEXT: [[TMP2:%.*]] = call i16 @llvm.usub.sat.i16(i16 [[TMP0]], i16 [[TMP1]])
// SIGNED-NEXT: store i16 [[TMP2]], i16* @uf_sat, align 2
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @sat_ufsufsufs(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @uf_sat, align 2
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i16, i16* @uf_sat, align 2
// UNSIGNED-NEXT: [[TMP2:%.*]] = call i16 @llvm.ssub.sat.i16(i16 [[TMP0]], i16 [[TMP1]])
// UNSIGNED-NEXT: [[TMP3:%.*]] = icmp slt i16 [[TMP2]], 0
// UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP3]], i16 0, i16 [[TMP2]]
// UNSIGNED-NEXT: [[RESIZE:%.*]] = trunc i16 [[SATMIN]] to i15
// UNSIGNED-NEXT: [[RESIZE1:%.*]] = zext i15 [[RESIZE]] to i16
// UNSIGNED-NEXT: store i16 [[RESIZE1]], i16* @uf_sat, align 2
// UNSIGNED-NEXT: ret void
//
void sat_ufsufsufs() {
uf_sat = uf_sat - uf_sat;
}
// SIGNED-LABEL: @sat_usasusasi(
// SIGNED-NEXT: entry:
// SIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @usa_sat, align 2
// SIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @i, align 4
// SIGNED-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP0]] to i40
// SIGNED-NEXT: [[RESIZE1:%.*]] = sext i32 [[TMP1]] to i40
// SIGNED-NEXT: [[UPSCALE:%.*]] = shl i40 [[RESIZE1]], 8
// SIGNED-NEXT: [[TMP2:%.*]] = call i40 @llvm.ssub.sat.i40(i40 [[RESIZE]], i40 [[UPSCALE]])
// SIGNED-NEXT: [[TMP3:%.*]] = icmp sgt i40 [[TMP2]], 65535
// SIGNED-NEXT: [[SATMAX:%.*]] = select i1 [[TMP3]], i40 65535, i40 [[TMP2]]
// SIGNED-NEXT: [[TMP4:%.*]] = icmp slt i40 [[SATMAX]], 0
// SIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP4]], i40 0, i40 [[SATMAX]]
// SIGNED-NEXT: [[RESIZE2:%.*]] = trunc i40 [[SATMIN]] to i16
// SIGNED-NEXT: store i16 [[RESIZE2]], i16* @usa_sat, align 2
// SIGNED-NEXT: ret void
//
// UNSIGNED-LABEL: @sat_usasusasi(
// UNSIGNED-NEXT: entry:
// UNSIGNED-NEXT: [[TMP0:%.*]] = load i16, i16* @usa_sat, align 2
// UNSIGNED-NEXT: [[TMP1:%.*]] = load i32, i32* @i, align 4
// UNSIGNED-NEXT: [[RESIZE:%.*]] = zext i16 [[TMP0]] to i39
// UNSIGNED-NEXT: [[RESIZE1:%.*]] = sext i32 [[TMP1]] to i39
// UNSIGNED-NEXT: [[UPSCALE:%.*]] = shl i39 [[RESIZE1]], 7
// UNSIGNED-NEXT: [[TMP2:%.*]] = call i39 @llvm.ssub.sat.i39(i39 [[RESIZE]], i39 [[UPSCALE]])
// UNSIGNED-NEXT: [[TMP3:%.*]] = icmp sgt i39 [[TMP2]], 32767
// UNSIGNED-NEXT: [[SATMAX:%.*]] = select i1 [[TMP3]], i39 32767, i39 [[TMP2]]
// UNSIGNED-NEXT: [[TMP4:%.*]] = icmp slt i39 [[SATMAX]], 0
// UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP4]], i39 0, i39 [[SATMAX]]
// UNSIGNED-NEXT: [[RESIZE2:%.*]] = trunc i39 [[SATMIN]] to i16
// UNSIGNED-NEXT: store i16 [[RESIZE2]], i16* @usa_sat, align 2
// UNSIGNED-NEXT: ret void
//
void sat_usasusasi() {
usa_sat = usa_sat - i;
}