1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=AARCH
4 define { i128, i8 } @muloti_test(i128 %l, i128 %r) unnamed_addr #0 {
5 ; AARCH-LABEL: muloti_test:
6 ; AARCH: // %bb.0: // %start
7 ; AARCH-NEXT: mul x9, x3, x0
8 ; AARCH-NEXT: cmp x1, #0
9 ; AARCH-NEXT: ccmp x3, #0, #4, ne
10 ; AARCH-NEXT: umulh x8, x1, x2
11 ; AARCH-NEXT: umulh x10, x3, x0
12 ; AARCH-NEXT: madd x9, x1, x2, x9
13 ; AARCH-NEXT: ccmp xzr, x8, #0, eq
14 ; AARCH-NEXT: umulh x11, x0, x2
15 ; AARCH-NEXT: ccmp xzr, x10, #0, eq
16 ; AARCH-NEXT: mul x0, x0, x2
17 ; AARCH-NEXT: cset w8, ne
18 ; AARCH-NEXT: adds x1, x11, x9
19 ; AARCH-NEXT: csinc w2, w8, wzr, lo
22 %0 = tail call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %l, i128 %r) #2
23 %1 = extractvalue { i128, i1 } %0, 0
24 %2 = extractvalue { i128, i1 } %0, 1
26 %4 = insertvalue { i128, i8 } undef, i128 %1, 0
27 %5 = insertvalue { i128, i8 } %4, i8 %3, 1
32 ; We avoid lowering the intrinsic as a libcall because this function has the same name as
33 ; the libcall we wanted to generate (that would create an infinite loop).
35 define i128 @__muloti4(i128 %0, i128 %1, ptr nocapture nonnull writeonly align 4 %2) #2 {
36 ; AARCH-LABEL: __muloti4:
37 ; AARCH: // %bb.0: // %Entry
38 ; AARCH-NEXT: asr x10, x1, #63
39 ; AARCH-NEXT: asr x9, x3, #63
40 ; AARCH-NEXT: umulh x14, x0, x2
41 ; AARCH-NEXT: mov x8, x1
42 ; AARCH-NEXT: str wzr, [x4]
43 ; AARCH-NEXT: mul x12, x2, x10
44 ; AARCH-NEXT: umulh x13, x2, x10
45 ; AARCH-NEXT: umulh x11, x9, x0
46 ; AARCH-NEXT: mul x15, x1, x2
47 ; AARCH-NEXT: add x13, x13, x12
48 ; AARCH-NEXT: madd x11, x9, x1, x11
49 ; AARCH-NEXT: mul x9, x9, x0
50 ; AARCH-NEXT: madd x10, x3, x10, x13
51 ; AARCH-NEXT: umulh x13, x1, x2
52 ; AARCH-NEXT: add x11, x11, x9
53 ; AARCH-NEXT: adds x9, x9, x12
54 ; AARCH-NEXT: mul x16, x0, x3
55 ; AARCH-NEXT: adc x10, x11, x10
56 ; AARCH-NEXT: adds x11, x15, x14
57 ; AARCH-NEXT: umulh x17, x0, x3
58 ; AARCH-NEXT: cinc x13, x13, hs
59 ; AARCH-NEXT: mul x12, x1, x3
60 ; AARCH-NEXT: adds x1, x16, x11
61 ; AARCH-NEXT: umulh x11, x8, x3
62 ; AARCH-NEXT: cinc x14, x17, hs
63 ; AARCH-NEXT: adds x13, x13, x14
64 ; AARCH-NEXT: mul x0, x0, x2
65 ; AARCH-NEXT: cset w14, hs
66 ; AARCH-NEXT: adds x12, x12, x13
67 ; AARCH-NEXT: asr x13, x1, #63
68 ; AARCH-NEXT: adc x11, x11, x14
69 ; AARCH-NEXT: adds x9, x12, x9
70 ; AARCH-NEXT: adc x10, x11, x10
71 ; AARCH-NEXT: cmp x9, x13
72 ; AARCH-NEXT: ccmp x10, x13, #0, eq
73 ; AARCH-NEXT: cset w9, ne
74 ; AARCH-NEXT: tbz x8, #63, .LBB1_2
75 ; AARCH-NEXT: // %bb.1: // %Entry
76 ; AARCH-NEXT: eor x8, x3, #0x8000000000000000
77 ; AARCH-NEXT: orr x8, x2, x8
78 ; AARCH-NEXT: cbz x8, .LBB1_3
79 ; AARCH-NEXT: .LBB1_2: // %Else2
80 ; AARCH-NEXT: cbz w9, .LBB1_4
81 ; AARCH-NEXT: .LBB1_3: // %Then7
82 ; AARCH-NEXT: mov w8, #1 // =0x1
83 ; AARCH-NEXT: str w8, [x4]
84 ; AARCH-NEXT: .LBB1_4: // %Block9
87 store i32 0, ptr %2, align 4
89 %mul = tail call { i128, i1 } @llvm.smul.with.overflow.i128(i128 %0, i128 %.fr)
90 %3 = icmp slt i128 %0, 0
91 %4 = icmp eq i128 %.fr, -170141183460469231731687303715884105728
93 br i1 %5, label %Then7, label %Else2
95 Else2: ; preds = %Entry
96 %mul.ov = extractvalue { i128, i1 } %mul, 1
97 br i1 %mul.ov, label %Then7, label %Block9
99 Then7: ; preds = %Else2, %Entry
100 store i32 1, ptr %2, align 4
103 Block9: ; preds = %Else2, %Then7
104 %mul.val = extractvalue { i128, i1 } %mul, 0
108 declare { i128, i1 } @llvm.umul.with.overflow.i128(i128, i128) #1
109 declare { i128, i1 } @llvm.smul.with.overflow.i128(i128, i128) #1
111 attributes #0 = { nounwind readnone uwtable }
112 attributes #1 = { nounwind readnone speculatable }
113 attributes #2 = { nounwind }