1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=arm64-eabi | FileCheck %s --check-prefixes=CHECK,CHECK-SD
3 ; RUN: llc < %s -mtriple=arm64-eabi -global-isel | FileCheck %s --check-prefixes=CHECK,CHECK-GI
8 define i128 @t1(i64 %a, i64 %b) nounwind readnone ssp {
10 ; CHECK: // %bb.0: // %entry
11 ; CHECK-NEXT: mul x8, x0, x1
12 ; CHECK-NEXT: umulh x1, x0, x1
13 ; CHECK-NEXT: mov x0, x8
16 %tmp1 = zext i64 %a to i128
17 %tmp2 = zext i64 %b to i128
18 %tmp3 = mul i128 %tmp1, %tmp2
22 define i128 @t2(i64 %a, i64 %b) nounwind readnone ssp {
24 ; CHECK-SD: // %bb.0: // %entry
25 ; CHECK-SD-NEXT: mul x8, x0, x1
26 ; CHECK-SD-NEXT: smulh x1, x0, x1
27 ; CHECK-SD-NEXT: mov x0, x8
31 ; CHECK-GI: // %bb.0: // %entry
32 ; CHECK-GI-NEXT: asr x9, x1, #63
33 ; CHECK-GI-NEXT: asr x10, x0, #63
34 ; CHECK-GI-NEXT: mul x8, x0, x1
35 ; CHECK-GI-NEXT: mul x9, x0, x9
36 ; CHECK-GI-NEXT: umulh x11, x0, x1
37 ; CHECK-GI-NEXT: mov x0, x8
38 ; CHECK-GI-NEXT: madd x9, x10, x1, x9
39 ; CHECK-GI-NEXT: add x1, x9, x11
42 %tmp1 = sext i64 %a to i128
43 %tmp2 = sext i64 %b to i128
44 %tmp3 = mul i128 %tmp1, %tmp2
48 define i64 @t3(i32 %a, i32 %b) nounwind {
50 ; CHECK: // %bb.0: // %entry
51 ; CHECK-NEXT: umull x0, w0, w1
54 %tmp1 = zext i32 %a to i64
55 %tmp2 = zext i32 %b to i64
56 %tmp3 = mul i64 %tmp1, %tmp2
60 define i64 @t4(i32 %a, i32 %b) nounwind {
62 ; CHECK: // %bb.0: // %entry
63 ; CHECK-NEXT: smull x0, w0, w1
66 %tmp1 = sext i32 %a to i64
67 %tmp2 = sext i32 %b to i64
68 %tmp3 = mul i64 %tmp1, %tmp2
72 define i64 @t5(i32 %a, i32 %b, i64 %c) nounwind {
74 ; CHECK: // %bb.0: // %entry
75 ; CHECK-NEXT: umaddl x0, w0, w1, x2
78 %tmp1 = zext i32 %a to i64
79 %tmp2 = zext i32 %b to i64
80 %tmp3 = mul i64 %tmp1, %tmp2
81 %tmp4 = add i64 %c, %tmp3
85 define i64 @t6(i32 %a, i32 %b, i64 %c) nounwind {
87 ; CHECK: // %bb.0: // %entry
88 ; CHECK-NEXT: smsubl x0, w0, w1, x2
91 %tmp1 = sext i32 %a to i64
92 %tmp2 = sext i32 %b to i64
93 %tmp3 = mul i64 %tmp1, %tmp2
94 %tmp4 = sub i64 %c, %tmp3
98 define i64 @t7(i32 %a, i32 %b) nounwind {
100 ; CHECK: // %bb.0: // %entry
101 ; CHECK-NEXT: umnegl x0, w0, w1
104 %tmp1 = zext i32 %a to i64
105 %tmp2 = zext i32 %b to i64
106 %tmp3 = mul i64 %tmp1, %tmp2
107 %tmp4 = sub i64 0, %tmp3
111 define i64 @t8(i32 %a, i32 %b) nounwind {
113 ; CHECK: // %bb.0: // %entry
114 ; CHECK-NEXT: smnegl x0, w0, w1
117 %tmp1 = sext i32 %a to i64
118 %tmp2 = sext i32 %b to i64
119 %tmp3 = mul i64 %tmp1, %tmp2
120 %tmp4 = sub i64 0, %tmp3
124 define i64 @t9(i32 %a) nounwind {
126 ; CHECK: // %bb.0: // %entry
127 ; CHECK-NEXT: mov w8, #8896 // =0x22c0
128 ; CHECK-NEXT: movk w8, #2, lsl #16
129 ; CHECK-NEXT: umull x0, w0, w8
132 %tmp1 = zext i32 %a to i64
133 %tmp2 = mul i64 %tmp1, 139968
137 ; Check 64-bit multiplication is used for constants > 32 bits.
138 define i64 @t10(i32 %a) nounwind {
140 ; CHECK: // %bb.0: // %entry
141 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
142 ; CHECK-NEXT: sxtw x8, w0
143 ; CHECK-NEXT: mov w9, #2 // =0x2
144 ; CHECK-NEXT: movk w9, #32768, lsl #16
145 ; CHECK-NEXT: mul x0, x8, x9
148 %tmp1 = sext i32 %a to i64
149 %tmp2 = mul i64 %tmp1, 2147483650 ; = 2^31 + 2
153 ; Check the sext_inreg case.
154 define i64 @t11(i64 %a) nounwind {
156 ; CHECK: // %bb.0: // %entry
157 ; CHECK-NEXT: mov w8, #29594 // =0x739a
158 ; CHECK-NEXT: movk w8, #65499, lsl #16
159 ; CHECK-NEXT: smnegl x0, w0, w8
162 %tmp1 = trunc i64 %a to i32
163 %tmp2 = sext i32 %tmp1 to i64
164 %tmp3 = mul i64 %tmp2, -2395238
165 %tmp4 = sub i64 0, %tmp3
169 define i64 @t12(i64 %a, i64 %b) nounwind {
171 ; CHECK: // %bb.0: // %entry
172 ; CHECK-NEXT: mov w8, #35118 // =0x892e
173 ; CHECK-NEXT: movk w8, #65008, lsl #16
174 ; CHECK-NEXT: smaddl x0, w0, w8, x1
177 %tmp1 = trunc i64 %a to i32
178 %tmp2 = sext i32 %tmp1 to i64
179 %tmp3 = mul i64 %tmp2, -34567890
180 %tmp4 = add i64 %b, %tmp3
184 define i64 @t13(i32 %a, i64 %b) nounwind {
186 ; CHECK: // %bb.0: // %entry
187 ; CHECK-NEXT: mov w8, #24910 // =0x614e
188 ; CHECK-NEXT: movk w8, #188, lsl #16
189 ; CHECK-NEXT: umsubl x0, w0, w8, x1
192 %tmp1 = zext i32 %a to i64
193 %tmp3 = mul i64 %tmp1, 12345678
194 %tmp4 = sub i64 %b, %tmp3
198 define i64 @t14(i32 %a, i64 %b) nounwind {
200 ; CHECK: // %bb.0: // %entry
201 ; CHECK-NEXT: mov w8, #40626 // =0x9eb2
202 ; CHECK-NEXT: movk w8, #65347, lsl #16
203 ; CHECK-NEXT: smsubl x0, w0, w8, x1
206 %tmp1 = sext i32 %a to i64
207 %tmp3 = mul i64 %tmp1, -12345678
208 %tmp4 = sub i64 %b, %tmp3