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
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=thumbv6m-none-unknown-eabi -mcpu=cortex-m0 | FileCheck %s --check-prefix=ARM
declare i4 @llvm.smul.fix.sat.i4 (i4, i4, i32)
declare i32 @llvm.smul.fix.sat.i32 (i32, i32, i32)
declare i64 @llvm.smul.fix.sat.i64 (i64, i64, i32)
define i32 @func(i32 %x, i32 %y) nounwind {
; ARM-LABEL: func:
; ARM: @ %bb.0:
; ARM-NEXT: .save {r7, lr}
; ARM-NEXT: push {r7, lr}
; ARM-NEXT: mov r2, r1
; ARM-NEXT: asrs r1, r0, #31
; ARM-NEXT: asrs r3, r2, #31
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: cmp r1, #1
; ARM-NEXT: bgt .LBB0_2
; ARM-NEXT: @ %bb.1:
; ARM-NEXT: lsrs r0, r0, #2
; ARM-NEXT: lsls r2, r1, #30
; ARM-NEXT: adds r0, r2, r0
; ARM-NEXT: b .LBB0_3
; ARM-NEXT: .LBB0_2:
; ARM-NEXT: ldr r0, .LCPI0_0
; ARM-NEXT: .LBB0_3:
; ARM-NEXT: movs r2, #1
; ARM-NEXT: mvns r3, r2
; ARM-NEXT: cmp r1, r3
; ARM-NEXT: bge .LBB0_5
; ARM-NEXT: @ %bb.4:
; ARM-NEXT: lsls r0, r2, #31
; ARM-NEXT: .LBB0_5:
; ARM-NEXT: pop {r7, pc}
; ARM-NEXT: .p2align 2
; ARM-NEXT: @ %bb.6:
; ARM-NEXT: .LCPI0_0:
; ARM-NEXT: .long 2147483647 @ 0x7fffffff
%tmp = call i32 @llvm.smul.fix.sat.i32(i32 %x, i32 %y, i32 2)
ret i32 %tmp
}
define i64 @func2(i64 %x, i64 %y) nounwind {
; ARM-LABEL: func2:
; ARM: @ %bb.0:
; ARM-NEXT: .save {r4, r5, r6, r7, lr}
; ARM-NEXT: push {r4, r5, r6, r7, lr}
; ARM-NEXT: .pad #36
; ARM-NEXT: sub sp, #36
; ARM-NEXT: str r3, [sp, #28] @ 4-byte Spill
; ARM-NEXT: mov r6, r1
; ARM-NEXT: str r1, [sp, #8] @ 4-byte Spill
; ARM-NEXT: movs r4, #0
; ARM-NEXT: str r4, [sp, #32] @ 4-byte Spill
; ARM-NEXT: mov r5, r0
; ARM-NEXT: str r0, [sp, #20] @ 4-byte Spill
; ARM-NEXT: mov r1, r4
; ARM-NEXT: mov r7, r2
; ARM-NEXT: str r2, [sp, #16] @ 4-byte Spill
; ARM-NEXT: mov r3, r4
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: str r0, [sp, #4] @ 4-byte Spill
; ARM-NEXT: str r1, [sp, #24] @ 4-byte Spill
; ARM-NEXT: mov r0, r6
; ARM-NEXT: mov r1, r4
; ARM-NEXT: mov r2, r7
; ARM-NEXT: mov r3, r4
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r6, r1
; ARM-NEXT: ldr r1, [sp, #24] @ 4-byte Reload
; ARM-NEXT: adds r7, r0, r1
; ARM-NEXT: adcs r6, r4
; ARM-NEXT: mov r0, r5
; ARM-NEXT: mov r1, r4
; ARM-NEXT: ldr r5, [sp, #28] @ 4-byte Reload
; ARM-NEXT: mov r2, r5
; ARM-NEXT: mov r3, r4
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: adds r0, r0, r7
; ARM-NEXT: str r0, [sp, #24] @ 4-byte Spill
; ARM-NEXT: adcs r1, r4
; ARM-NEXT: adds r0, r6, r1
; ARM-NEXT: str r0, [sp, #12] @ 4-byte Spill
; ARM-NEXT: mov r6, r4
; ARM-NEXT: adcs r6, r4
; ARM-NEXT: ldr r7, [sp, #8] @ 4-byte Reload
; ARM-NEXT: mov r0, r7
; ARM-NEXT: mov r1, r4
; ARM-NEXT: mov r2, r5
; ARM-NEXT: mov r3, r4
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r5, r1
; ARM-NEXT: ldr r1, [sp, #12] @ 4-byte Reload
; ARM-NEXT: adds r0, r0, r1
; ARM-NEXT: str r0, [sp, #12] @ 4-byte Spill
; ARM-NEXT: adcs r5, r6
; ARM-NEXT: asrs r2, r7, #31
; ARM-NEXT: ldr r0, [sp, #16] @ 4-byte Reload
; ARM-NEXT: ldr r4, [sp, #28] @ 4-byte Reload
; ARM-NEXT: mov r1, r4
; ARM-NEXT: mov r3, r2
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r6, r0
; ARM-NEXT: str r1, [sp, #16] @ 4-byte Spill
; ARM-NEXT: asrs r0, r4, #31
; ARM-NEXT: mov r1, r0
; ARM-NEXT: ldr r2, [sp, #20] @ 4-byte Reload
; ARM-NEXT: mov r3, r7
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: adds r0, r0, r6
; ARM-NEXT: ldr r2, [sp, #16] @ 4-byte Reload
; ARM-NEXT: adcs r1, r2
; ARM-NEXT: ldr r2, [sp, #12] @ 4-byte Reload
; ARM-NEXT: adds r0, r2, r0
; ARM-NEXT: adcs r1, r5
; ARM-NEXT: rsbs r5, r1, #0
; ARM-NEXT: adcs r5, r1
; ARM-NEXT: movs r2, #1
; ARM-NEXT: str r0, [sp, #28] @ 4-byte Spill
; ARM-NEXT: cmp r0, #1
; ARM-NEXT: mov r3, r2
; ARM-NEXT: bhi .LBB1_2
; ARM-NEXT: @ %bb.1:
; ARM-NEXT: ldr r3, [sp, #32] @ 4-byte Reload
; ARM-NEXT: .LBB1_2:
; ARM-NEXT: ands r5, r3
; ARM-NEXT: cmp r1, #0
; ARM-NEXT: mov r3, r2
; ARM-NEXT: bgt .LBB1_4
; ARM-NEXT: @ %bb.3:
; ARM-NEXT: ldr r3, [sp, #32] @ 4-byte Reload
; ARM-NEXT: .LBB1_4:
; ARM-NEXT: orrs r3, r5
; ARM-NEXT: ldr r0, [sp, #32] @ 4-byte Reload
; ARM-NEXT: mvns r6, r0
; ARM-NEXT: cmp r3, #0
; ARM-NEXT: str r6, [sp, #20] @ 4-byte Spill
; ARM-NEXT: bne .LBB1_6
; ARM-NEXT: @ %bb.5:
; ARM-NEXT: ldr r0, [sp, #24] @ 4-byte Reload
; ARM-NEXT: lsls r0, r0, #30
; ARM-NEXT: ldr r4, [sp, #4] @ 4-byte Reload
; ARM-NEXT: lsrs r4, r4, #2
; ARM-NEXT: adds r0, r0, r4
; ARM-NEXT: str r0, [sp, #20] @ 4-byte Spill
; ARM-NEXT: .LBB1_6:
; ARM-NEXT: adds r0, r1, #1
; ARM-NEXT: rsbs r7, r0, #0
; ARM-NEXT: adcs r7, r0
; ARM-NEXT: mvns r0, r2
; ARM-NEXT: ldr r5, [sp, #28] @ 4-byte Reload
; ARM-NEXT: cmp r5, r0
; ARM-NEXT: mov r0, r2
; ARM-NEXT: blo .LBB1_8
; ARM-NEXT: @ %bb.7:
; ARM-NEXT: ldr r0, [sp, #32] @ 4-byte Reload
; ARM-NEXT: .LBB1_8:
; ARM-NEXT: ands r7, r0
; ARM-NEXT: cmp r1, r6
; ARM-NEXT: mov r6, r2
; ARM-NEXT: bge .LBB1_12
; ARM-NEXT: @ %bb.9:
; ARM-NEXT: orrs r6, r7
; ARM-NEXT: beq .LBB1_13
; ARM-NEXT: .LBB1_10:
; ARM-NEXT: cmp r3, #0
; ARM-NEXT: bne .LBB1_14
; ARM-NEXT: .LBB1_11:
; ARM-NEXT: ldr r0, [sp, #28] @ 4-byte Reload
; ARM-NEXT: lsls r0, r0, #30
; ARM-NEXT: ldr r1, [sp, #24] @ 4-byte Reload
; ARM-NEXT: lsrs r1, r1, #2
; ARM-NEXT: adds r1, r0, r1
; ARM-NEXT: cmp r6, #0
; ARM-NEXT: bne .LBB1_15
; ARM-NEXT: b .LBB1_16
; ARM-NEXT: .LBB1_12:
; ARM-NEXT: ldr r6, [sp, #32] @ 4-byte Reload
; ARM-NEXT: orrs r6, r7
; ARM-NEXT: bne .LBB1_10
; ARM-NEXT: .LBB1_13:
; ARM-NEXT: ldr r0, [sp, #20] @ 4-byte Reload
; ARM-NEXT: str r0, [sp, #32] @ 4-byte Spill
; ARM-NEXT: cmp r3, #0
; ARM-NEXT: beq .LBB1_11
; ARM-NEXT: .LBB1_14:
; ARM-NEXT: ldr r1, .LCPI1_0
; ARM-NEXT: cmp r6, #0
; ARM-NEXT: beq .LBB1_16
; ARM-NEXT: .LBB1_15:
; ARM-NEXT: lsls r1, r2, #31
; ARM-NEXT: .LBB1_16:
; ARM-NEXT: ldr r0, [sp, #32] @ 4-byte Reload
; ARM-NEXT: add sp, #36
; ARM-NEXT: pop {r4, r5, r6, r7, pc}
; ARM-NEXT: .p2align 2
; ARM-NEXT: @ %bb.17:
; ARM-NEXT: .LCPI1_0:
; ARM-NEXT: .long 2147483647 @ 0x7fffffff
%tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 2)
ret i64 %tmp
}
define i4 @func3(i4 %x, i4 %y) nounwind {
; ARM-LABEL: func3:
; ARM: @ %bb.0:
; ARM-NEXT: .save {r4, lr}
; ARM-NEXT: push {r4, lr}
; ARM-NEXT: lsls r0, r0, #28
; ARM-NEXT: asrs r4, r0, #31
; ARM-NEXT: lsls r1, r1, #28
; ARM-NEXT: asrs r2, r1, #28
; ARM-NEXT: asrs r3, r1, #31
; ARM-NEXT: mov r1, r4
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: cmp r1, #1
; ARM-NEXT: bgt .LBB2_2
; ARM-NEXT: @ %bb.1:
; ARM-NEXT: lsrs r0, r0, #2
; ARM-NEXT: lsls r2, r1, #30
; ARM-NEXT: adds r0, r2, r0
; ARM-NEXT: b .LBB2_3
; ARM-NEXT: .LBB2_2:
; ARM-NEXT: ldr r0, .LCPI2_0
; ARM-NEXT: .LBB2_3:
; ARM-NEXT: movs r2, #1
; ARM-NEXT: mvns r3, r2
; ARM-NEXT: cmp r1, r3
; ARM-NEXT: bge .LBB2_5
; ARM-NEXT: @ %bb.4:
; ARM-NEXT: lsls r0, r2, #31
; ARM-NEXT: .LBB2_5:
; ARM-NEXT: asrs r0, r0, #28
; ARM-NEXT: pop {r4, pc}
; ARM-NEXT: .p2align 2
; ARM-NEXT: @ %bb.6:
; ARM-NEXT: .LCPI2_0:
; ARM-NEXT: .long 2147483647 @ 0x7fffffff
%tmp = call i4 @llvm.smul.fix.sat.i4(i4 %x, i4 %y, i32 2)
ret i4 %tmp
}
;; These result in regular integer multiplication with a saturation check.
define i32 @func4(i32 %x, i32 %y) nounwind {
; ARM-LABEL: func4:
; ARM: @ %bb.0:
; ARM-NEXT: .save {r7, lr}
; ARM-NEXT: push {r7, lr}
; ARM-NEXT: mov r2, r1
; ARM-NEXT: asrs r1, r0, #31
; ARM-NEXT: asrs r3, r2, #31
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: cmp r1, #0
; ARM-NEXT: bmi .LBB3_2
; ARM-NEXT: @ %bb.1:
; ARM-NEXT: ldr r2, .LCPI3_0
; ARM-NEXT: b .LBB3_3
; ARM-NEXT: .LBB3_2:
; ARM-NEXT: movs r2, #1
; ARM-NEXT: lsls r2, r2, #31
; ARM-NEXT: .LBB3_3:
; ARM-NEXT: asrs r3, r0, #31
; ARM-NEXT: cmp r1, r3
; ARM-NEXT: bne .LBB3_5
; ARM-NEXT: @ %bb.4:
; ARM-NEXT: mov r2, r0
; ARM-NEXT: .LBB3_5:
; ARM-NEXT: mov r0, r2
; ARM-NEXT: pop {r7, pc}
; ARM-NEXT: .p2align 2
; ARM-NEXT: @ %bb.6:
; ARM-NEXT: .LCPI3_0:
; ARM-NEXT: .long 2147483647 @ 0x7fffffff
%tmp = call i32 @llvm.smul.fix.sat.i32(i32 %x, i32 %y, i32 0)
ret i32 %tmp
}
define i64 @func5(i64 %x, i64 %y) {
; ARM-LABEL: func5:
; ARM: @ %bb.0:
; ARM-NEXT: .save {r4, r5, r6, r7, lr}
; ARM-NEXT: push {r4, r5, r6, r7, lr}
; ARM-NEXT: .pad #28
; ARM-NEXT: sub sp, #28
; ARM-NEXT: str r3, [sp, #12] @ 4-byte Spill
; ARM-NEXT: mov r5, r2
; ARM-NEXT: str r2, [sp, #16] @ 4-byte Spill
; ARM-NEXT: mov r6, r1
; ARM-NEXT: movs r7, #0
; ARM-NEXT: mov r4, r0
; ARM-NEXT: str r0, [sp, #20] @ 4-byte Spill
; ARM-NEXT: mov r1, r7
; ARM-NEXT: mov r3, r7
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: str r0, [sp, #4] @ 4-byte Spill
; ARM-NEXT: str r1, [sp, #24] @ 4-byte Spill
; ARM-NEXT: mov r0, r6
; ARM-NEXT: mov r1, r7
; ARM-NEXT: mov r2, r5
; ARM-NEXT: mov r3, r7
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r5, r1
; ARM-NEXT: ldr r1, [sp, #24] @ 4-byte Reload
; ARM-NEXT: adds r0, r0, r1
; ARM-NEXT: str r0, [sp, #24] @ 4-byte Spill
; ARM-NEXT: adcs r5, r7
; ARM-NEXT: mov r0, r4
; ARM-NEXT: mov r1, r7
; ARM-NEXT: ldr r4, [sp, #12] @ 4-byte Reload
; ARM-NEXT: mov r2, r4
; ARM-NEXT: mov r3, r7
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: ldr r2, [sp, #24] @ 4-byte Reload
; ARM-NEXT: adds r0, r0, r2
; ARM-NEXT: str r0, [sp, #24] @ 4-byte Spill
; ARM-NEXT: adcs r1, r7
; ARM-NEXT: adds r0, r5, r1
; ARM-NEXT: str r0, [sp, #8] @ 4-byte Spill
; ARM-NEXT: mov r5, r7
; ARM-NEXT: adcs r5, r7
; ARM-NEXT: mov r0, r6
; ARM-NEXT: mov r1, r7
; ARM-NEXT: mov r2, r4
; ARM-NEXT: mov r3, r7
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r7, r1
; ARM-NEXT: ldr r1, [sp, #8] @ 4-byte Reload
; ARM-NEXT: adds r0, r0, r1
; ARM-NEXT: str r0, [sp, #8] @ 4-byte Spill
; ARM-NEXT: adcs r7, r5
; ARM-NEXT: asrs r2, r6, #31
; ARM-NEXT: ldr r0, [sp, #16] @ 4-byte Reload
; ARM-NEXT: mov r5, r4
; ARM-NEXT: mov r1, r4
; ARM-NEXT: mov r3, r2
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r4, r0
; ARM-NEXT: str r1, [sp, #16] @ 4-byte Spill
; ARM-NEXT: asrs r0, r5, #31
; ARM-NEXT: mov r1, r0
; ARM-NEXT: ldr r2, [sp, #20] @ 4-byte Reload
; ARM-NEXT: mov r3, r6
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: adds r0, r0, r4
; ARM-NEXT: ldr r4, [sp, #24] @ 4-byte Reload
; ARM-NEXT: ldr r2, [sp, #16] @ 4-byte Reload
; ARM-NEXT: adcs r1, r2
; ARM-NEXT: ldr r2, [sp, #8] @ 4-byte Reload
; ARM-NEXT: adds r3, r2, r0
; ARM-NEXT: adcs r1, r7
; ARM-NEXT: asrs r2, r4, #31
; ARM-NEXT: eors r1, r2
; ARM-NEXT: eors r3, r2
; ARM-NEXT: orrs r3, r1
; ARM-NEXT: eors r6, r5
; ARM-NEXT: asrs r1, r6, #31
; ARM-NEXT: cmp r3, #0
; ARM-NEXT: bne .LBB4_3
; ARM-NEXT: @ %bb.1:
; ARM-NEXT: ldr r0, [sp, #4] @ 4-byte Reload
; ARM-NEXT: cmp r3, #0
; ARM-NEXT: beq .LBB4_4
; ARM-NEXT: .LBB4_2:
; ARM-NEXT: ldr r2, .LCPI4_0
; ARM-NEXT: eors r1, r2
; ARM-NEXT: add sp, #28
; ARM-NEXT: pop {r4, r5, r6, r7, pc}
; ARM-NEXT: .LBB4_3:
; ARM-NEXT: mvns r0, r1
; ARM-NEXT: cmp r3, #0
; ARM-NEXT: bne .LBB4_2
; ARM-NEXT: .LBB4_4:
; ARM-NEXT: mov r1, r4
; ARM-NEXT: add sp, #28
; ARM-NEXT: pop {r4, r5, r6, r7, pc}
; ARM-NEXT: .p2align 2
; ARM-NEXT: @ %bb.5:
; ARM-NEXT: .LCPI4_0:
; ARM-NEXT: .long 2147483647 @ 0x7fffffff
%tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 0)
ret i64 %tmp
}
define i4 @func6(i4 %x, i4 %y) nounwind {
; ARM-LABEL: func6:
; ARM: @ %bb.0:
; ARM-NEXT: .save {r4, lr}
; ARM-NEXT: push {r4, lr}
; ARM-NEXT: lsls r0, r0, #28
; ARM-NEXT: asrs r4, r0, #31
; ARM-NEXT: lsls r1, r1, #28
; ARM-NEXT: asrs r2, r1, #28
; ARM-NEXT: asrs r3, r1, #31
; ARM-NEXT: mov r1, r4
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: cmp r1, #0
; ARM-NEXT: bmi .LBB5_2
; ARM-NEXT: @ %bb.1:
; ARM-NEXT: ldr r2, .LCPI5_0
; ARM-NEXT: b .LBB5_3
; ARM-NEXT: .LBB5_2:
; ARM-NEXT: movs r2, #1
; ARM-NEXT: lsls r2, r2, #31
; ARM-NEXT: .LBB5_3:
; ARM-NEXT: asrs r3, r0, #31
; ARM-NEXT: cmp r1, r3
; ARM-NEXT: bne .LBB5_5
; ARM-NEXT: @ %bb.4:
; ARM-NEXT: mov r2, r0
; ARM-NEXT: .LBB5_5:
; ARM-NEXT: asrs r0, r2, #28
; ARM-NEXT: pop {r4, pc}
; ARM-NEXT: .p2align 2
; ARM-NEXT: @ %bb.6:
; ARM-NEXT: .LCPI5_0:
; ARM-NEXT: .long 2147483647 @ 0x7fffffff
%tmp = call i4 @llvm.smul.fix.sat.i4(i4 %x, i4 %y, i32 0)
ret i4 %tmp
}
define i64 @func7(i64 %x, i64 %y) nounwind {
; ARM-LABEL: func7:
; ARM: @ %bb.0:
; ARM-NEXT: .save {r4, r5, r6, r7, lr}
; ARM-NEXT: push {r4, r5, r6, r7, lr}
; ARM-NEXT: .pad #28
; ARM-NEXT: sub sp, #28
; ARM-NEXT: str r3, [sp, #24] @ 4-byte Spill
; ARM-NEXT: mov r5, r1
; ARM-NEXT: str r1, [sp, #20] @ 4-byte Spill
; ARM-NEXT: movs r6, #0
; ARM-NEXT: mov r7, r0
; ARM-NEXT: str r0, [sp, #16] @ 4-byte Spill
; ARM-NEXT: mov r1, r6
; ARM-NEXT: mov r4, r2
; ARM-NEXT: str r2, [sp, #12] @ 4-byte Spill
; ARM-NEXT: mov r3, r6
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: str r1, [sp, #8] @ 4-byte Spill
; ARM-NEXT: mov r0, r5
; ARM-NEXT: mov r1, r6
; ARM-NEXT: mov r2, r4
; ARM-NEXT: mov r3, r6
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r5, r1
; ARM-NEXT: ldr r1, [sp, #8] @ 4-byte Reload
; ARM-NEXT: adds r4, r0, r1
; ARM-NEXT: adcs r5, r6
; ARM-NEXT: mov r0, r7
; ARM-NEXT: mov r1, r6
; ARM-NEXT: ldr r7, [sp, #24] @ 4-byte Reload
; ARM-NEXT: mov r2, r7
; ARM-NEXT: mov r3, r6
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: adds r0, r0, r4
; ARM-NEXT: str r0, [sp, #4] @ 4-byte Spill
; ARM-NEXT: adcs r1, r6
; ARM-NEXT: adds r0, r5, r1
; ARM-NEXT: str r0, [sp, #8] @ 4-byte Spill
; ARM-NEXT: mov r4, r6
; ARM-NEXT: adcs r4, r6
; ARM-NEXT: ldr r5, [sp, #20] @ 4-byte Reload
; ARM-NEXT: mov r0, r5
; ARM-NEXT: mov r1, r6
; ARM-NEXT: mov r2, r7
; ARM-NEXT: mov r3, r6
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r7, r1
; ARM-NEXT: ldr r1, [sp, #8] @ 4-byte Reload
; ARM-NEXT: adds r0, r0, r1
; ARM-NEXT: str r0, [sp, #8] @ 4-byte Spill
; ARM-NEXT: adcs r7, r4
; ARM-NEXT: asrs r2, r5, #31
; ARM-NEXT: ldr r0, [sp, #12] @ 4-byte Reload
; ARM-NEXT: ldr r5, [sp, #24] @ 4-byte Reload
; ARM-NEXT: mov r1, r5
; ARM-NEXT: mov r3, r2
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r4, r0
; ARM-NEXT: str r1, [sp, #12] @ 4-byte Spill
; ARM-NEXT: asrs r0, r5, #31
; ARM-NEXT: mov r1, r0
; ARM-NEXT: ldr r2, [sp, #16] @ 4-byte Reload
; ARM-NEXT: ldr r3, [sp, #20] @ 4-byte Reload
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r2, r1
; ARM-NEXT: adds r0, r0, r4
; ARM-NEXT: ldr r1, [sp, #12] @ 4-byte Reload
; ARM-NEXT: adcs r2, r1
; ARM-NEXT: ldr r1, [sp, #8] @ 4-byte Reload
; ARM-NEXT: adds r0, r1, r0
; ARM-NEXT: adcs r2, r7
; ARM-NEXT: rsbs r5, r2, #0
; ARM-NEXT: adcs r5, r2
; ARM-NEXT: movs r4, #1
; ARM-NEXT: str r0, [sp, #24] @ 4-byte Spill
; ARM-NEXT: cmp r0, #0
; ARM-NEXT: mov r3, r4
; ARM-NEXT: bmi .LBB6_2
; ARM-NEXT: @ %bb.1:
; ARM-NEXT: mov r3, r6
; ARM-NEXT: .LBB6_2:
; ARM-NEXT: ands r5, r3
; ARM-NEXT: cmp r2, #0
; ARM-NEXT: mov r1, r4
; ARM-NEXT: mov r3, r4
; ARM-NEXT: bgt .LBB6_4
; ARM-NEXT: @ %bb.3:
; ARM-NEXT: mov r3, r6
; ARM-NEXT: .LBB6_4:
; ARM-NEXT: orrs r3, r5
; ARM-NEXT: mvns r4, r6
; ARM-NEXT: cmp r3, #0
; ARM-NEXT: mov r5, r4
; ARM-NEXT: bne .LBB6_6
; ARM-NEXT: @ %bb.5:
; ARM-NEXT: ldr r5, [sp, #4] @ 4-byte Reload
; ARM-NEXT: .LBB6_6:
; ARM-NEXT: adds r0, r2, #1
; ARM-NEXT: rsbs r7, r0, #0
; ARM-NEXT: adcs r7, r0
; ARM-NEXT: ldr r0, [sp, #24] @ 4-byte Reload
; ARM-NEXT: cmp r0, #0
; ARM-NEXT: mov r0, r1
; ARM-NEXT: bge .LBB6_8
; ARM-NEXT: @ %bb.7:
; ARM-NEXT: mov r0, r6
; ARM-NEXT: .LBB6_8:
; ARM-NEXT: ands r7, r0
; ARM-NEXT: cmp r2, r4
; ARM-NEXT: mov r0, r1
; ARM-NEXT: mov r2, r1
; ARM-NEXT: bge .LBB6_12
; ARM-NEXT: @ %bb.9:
; ARM-NEXT: orrs r2, r7
; ARM-NEXT: beq .LBB6_13
; ARM-NEXT: .LBB6_10:
; ARM-NEXT: cmp r3, #0
; ARM-NEXT: bne .LBB6_14
; ARM-NEXT: .LBB6_11:
; ARM-NEXT: ldr r1, [sp, #24] @ 4-byte Reload
; ARM-NEXT: cmp r2, #0
; ARM-NEXT: bne .LBB6_15
; ARM-NEXT: b .LBB6_16
; ARM-NEXT: .LBB6_12:
; ARM-NEXT: mov r2, r6
; ARM-NEXT: orrs r2, r7
; ARM-NEXT: bne .LBB6_10
; ARM-NEXT: .LBB6_13:
; ARM-NEXT: mov r6, r5
; ARM-NEXT: cmp r3, #0
; ARM-NEXT: beq .LBB6_11
; ARM-NEXT: .LBB6_14:
; ARM-NEXT: ldr r1, .LCPI6_0
; ARM-NEXT: cmp r2, #0
; ARM-NEXT: beq .LBB6_16
; ARM-NEXT: .LBB6_15:
; ARM-NEXT: lsls r1, r0, #31
; ARM-NEXT: .LBB6_16:
; ARM-NEXT: mov r0, r6
; ARM-NEXT: add sp, #28
; ARM-NEXT: pop {r4, r5, r6, r7, pc}
; ARM-NEXT: .p2align 2
; ARM-NEXT: @ %bb.17:
; ARM-NEXT: .LCPI6_0:
; ARM-NEXT: .long 2147483647 @ 0x7fffffff
%tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 32)
ret i64 %tmp
}
define i64 @func8(i64 %x, i64 %y) nounwind {
; ARM-LABEL: func8:
; ARM: @ %bb.0:
; ARM-NEXT: .save {r4, r5, r6, r7, lr}
; ARM-NEXT: push {r4, r5, r6, r7, lr}
; ARM-NEXT: .pad #28
; ARM-NEXT: sub sp, #28
; ARM-NEXT: str r3, [sp, #24] @ 4-byte Spill
; ARM-NEXT: mov r5, r2
; ARM-NEXT: str r2, [sp, #12] @ 4-byte Spill
; ARM-NEXT: mov r4, r1
; ARM-NEXT: str r1, [sp, #20] @ 4-byte Spill
; ARM-NEXT: movs r7, #0
; ARM-NEXT: mov r6, r0
; ARM-NEXT: str r0, [sp, #16] @ 4-byte Spill
; ARM-NEXT: mov r1, r7
; ARM-NEXT: mov r3, r7
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: str r1, [sp, #8] @ 4-byte Spill
; ARM-NEXT: mov r0, r4
; ARM-NEXT: mov r1, r7
; ARM-NEXT: mov r2, r5
; ARM-NEXT: mov r3, r7
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r5, r1
; ARM-NEXT: ldr r1, [sp, #8] @ 4-byte Reload
; ARM-NEXT: adds r4, r0, r1
; ARM-NEXT: adcs r5, r7
; ARM-NEXT: mov r0, r6
; ARM-NEXT: mov r1, r7
; ARM-NEXT: ldr r6, [sp, #24] @ 4-byte Reload
; ARM-NEXT: mov r2, r6
; ARM-NEXT: mov r3, r7
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: adds r0, r0, r4
; ARM-NEXT: str r0, [sp, #4] @ 4-byte Spill
; ARM-NEXT: adcs r1, r7
; ARM-NEXT: adds r0, r5, r1
; ARM-NEXT: str r0, [sp, #8] @ 4-byte Spill
; ARM-NEXT: mov r4, r7
; ARM-NEXT: adcs r4, r7
; ARM-NEXT: ldr r5, [sp, #20] @ 4-byte Reload
; ARM-NEXT: mov r0, r5
; ARM-NEXT: mov r1, r7
; ARM-NEXT: mov r2, r6
; ARM-NEXT: mov r3, r7
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r6, r1
; ARM-NEXT: ldr r1, [sp, #8] @ 4-byte Reload
; ARM-NEXT: adds r0, r0, r1
; ARM-NEXT: str r0, [sp, #8] @ 4-byte Spill
; ARM-NEXT: adcs r6, r4
; ARM-NEXT: asrs r2, r5, #31
; ARM-NEXT: ldr r0, [sp, #12] @ 4-byte Reload
; ARM-NEXT: ldr r4, [sp, #24] @ 4-byte Reload
; ARM-NEXT: mov r1, r4
; ARM-NEXT: mov r3, r2
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: mov r5, r0
; ARM-NEXT: str r1, [sp, #12] @ 4-byte Spill
; ARM-NEXT: asrs r0, r4, #31
; ARM-NEXT: mov r1, r0
; ARM-NEXT: ldr r2, [sp, #16] @ 4-byte Reload
; ARM-NEXT: ldr r3, [sp, #20] @ 4-byte Reload
; ARM-NEXT: bl __aeabi_lmul
; ARM-NEXT: adds r0, r0, r5
; ARM-NEXT: ldr r2, [sp, #12] @ 4-byte Reload
; ARM-NEXT: adcs r1, r2
; ARM-NEXT: ldr r2, [sp, #8] @ 4-byte Reload
; ARM-NEXT: adds r0, r2, r0
; ARM-NEXT: adcs r1, r6
; ARM-NEXT: ldr r2, .LCPI7_0
; ARM-NEXT: cmp r1, r2
; ARM-NEXT: bgt .LBB7_2
; ARM-NEXT: @ %bb.1:
; ARM-NEXT: lsls r3, r0, #1
; ARM-NEXT: ldr r4, [sp, #4] @ 4-byte Reload
; ARM-NEXT: lsrs r4, r4, #31
; ARM-NEXT: adds r5, r3, r4
; ARM-NEXT: b .LBB7_3
; ARM-NEXT: .LBB7_2:
; ARM-NEXT: mvns r5, r7
; ARM-NEXT: .LBB7_3:
; ARM-NEXT: movs r3, #3
; ARM-NEXT: lsls r3, r3, #30
; ARM-NEXT: cmp r1, r3
; ARM-NEXT: blt .LBB7_5
; ARM-NEXT: @ %bb.4:
; ARM-NEXT: mov r7, r5
; ARM-NEXT: .LBB7_5:
; ARM-NEXT: cmp r1, r2
; ARM-NEXT: bgt .LBB7_7
; ARM-NEXT: @ %bb.6:
; ARM-NEXT: lsls r2, r1, #1
; ARM-NEXT: lsrs r0, r0, #31
; ARM-NEXT: adds r2, r2, r0
; ARM-NEXT: cmp r1, r3
; ARM-NEXT: blt .LBB7_8
; ARM-NEXT: b .LBB7_9
; ARM-NEXT: .LBB7_7:
; ARM-NEXT: ldr r2, .LCPI7_1
; ARM-NEXT: cmp r1, r3
; ARM-NEXT: bge .LBB7_9
; ARM-NEXT: .LBB7_8:
; ARM-NEXT: movs r0, #1
; ARM-NEXT: lsls r2, r0, #31
; ARM-NEXT: .LBB7_9:
; ARM-NEXT: mov r0, r7
; ARM-NEXT: mov r1, r2
; ARM-NEXT: add sp, #28
; ARM-NEXT: pop {r4, r5, r6, r7, pc}
; ARM-NEXT: .p2align 2
; ARM-NEXT: @ %bb.10:
; ARM-NEXT: .LCPI7_0:
; ARM-NEXT: .long 1073741823 @ 0x3fffffff
; ARM-NEXT: .LCPI7_1:
; ARM-NEXT: .long 2147483647 @ 0x7fffffff
%tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 63)
ret i64 %tmp
}
|