1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=arm64-eabi | FileCheck %s
7 define i128 @t1(i64 %a, i64 %b) nounwind readnone ssp {
9 ; CHECK: // %bb.0: // %entry
10 ; CHECK-NEXT: mul x8, x0, x1
11 ; CHECK-NEXT: umulh x1, x0, x1
12 ; CHECK-NEXT: mov x0, x8
15 %tmp1 = zext i64 %a to i128
16 %tmp2 = zext i64 %b to i128
17 %tmp3 = mul i128 %tmp1, %tmp2
21 define i128 @t2(i64 %a, i64 %b) nounwind readnone ssp {
23 ; CHECK: // %bb.0: // %entry
24 ; CHECK-NEXT: mul x8, x0, x1
25 ; CHECK-NEXT: smulh x1, x0, x1
26 ; CHECK-NEXT: mov x0, x8
29 %tmp1 = sext i64 %a to i128
30 %tmp2 = sext i64 %b to i128
31 %tmp3 = mul i128 %tmp1, %tmp2
35 define i64 @t3(i32 %a, i32 %b) nounwind {
37 ; CHECK: // %bb.0: // %entry
38 ; CHECK-NEXT: umull x0, w0, w1
41 %tmp1 = zext i32 %a to i64
42 %tmp2 = zext i32 %b to i64
43 %tmp3 = mul i64 %tmp1, %tmp2
47 define i64 @t4(i32 %a, i32 %b) nounwind {
49 ; CHECK: // %bb.0: // %entry
50 ; CHECK-NEXT: smull x0, w0, w1
53 %tmp1 = sext i32 %a to i64
54 %tmp2 = sext i32 %b to i64
55 %tmp3 = mul i64 %tmp1, %tmp2
59 define i64 @t5(i32 %a, i32 %b, i64 %c) nounwind {
61 ; CHECK: // %bb.0: // %entry
62 ; CHECK-NEXT: umaddl x0, w0, w1, x2
65 %tmp1 = zext i32 %a to i64
66 %tmp2 = zext i32 %b to i64
67 %tmp3 = mul i64 %tmp1, %tmp2
68 %tmp4 = add i64 %c, %tmp3
72 define i64 @t6(i32 %a, i32 %b, i64 %c) nounwind {
74 ; CHECK: // %bb.0: // %entry
75 ; CHECK-NEXT: smsubl x0, w0, w1, x2
78 %tmp1 = sext i32 %a to i64
79 %tmp2 = sext i32 %b to i64
80 %tmp3 = mul i64 %tmp1, %tmp2
81 %tmp4 = sub i64 %c, %tmp3
85 define i64 @t7(i32 %a, i32 %b) nounwind {
87 ; CHECK: // %bb.0: // %entry
88 ; CHECK-NEXT: umnegl x0, w0, w1
91 %tmp1 = zext i32 %a to i64
92 %tmp2 = zext i32 %b to i64
93 %tmp3 = mul i64 %tmp1, %tmp2
94 %tmp4 = sub i64 0, %tmp3
98 define i64 @t8(i32 %a, i32 %b) nounwind {
100 ; CHECK: // %bb.0: // %entry
101 ; CHECK-NEXT: smnegl x0, w0, w1
104 %tmp1 = sext i32 %a to i64
105 %tmp2 = sext i32 %b to i64
106 %tmp3 = mul i64 %tmp1, %tmp2
107 %tmp4 = sub i64 0, %tmp3
111 define i64 @t9(i32 %a) nounwind {
113 ; CHECK: // %bb.0: // %entry
114 ; CHECK-NEXT: mov w8, #8896 // =0x22c0
115 ; CHECK-NEXT: movk w8, #2, lsl #16
116 ; CHECK-NEXT: umull x0, w0, w8
119 %tmp1 = zext i32 %a to i64
120 %tmp2 = mul i64 %tmp1, 139968
124 ; Check 64-bit multiplication is used for constants > 32 bits.
125 define i64 @t10(i32 %a) nounwind {
127 ; CHECK: // %bb.0: // %entry
128 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
129 ; CHECK-NEXT: sxtw x8, w0
130 ; CHECK-NEXT: mov w9, #2 // =0x2
131 ; CHECK-NEXT: movk w9, #32768, lsl #16
132 ; CHECK-NEXT: mul x0, x8, x9
135 %tmp1 = sext i32 %a to i64
136 %tmp2 = mul i64 %tmp1, 2147483650 ; = 2^31 + 2
140 ; Check the sext_inreg case.
141 define i64 @t11(i64 %a) nounwind {
143 ; CHECK: // %bb.0: // %entry
144 ; CHECK-NEXT: mov w8, #29594 // =0x739a
145 ; CHECK-NEXT: movk w8, #65499, lsl #16
146 ; CHECK-NEXT: smnegl x0, w0, w8
149 %tmp1 = trunc i64 %a to i32
150 %tmp2 = sext i32 %tmp1 to i64
151 %tmp3 = mul i64 %tmp2, -2395238
152 %tmp4 = sub i64 0, %tmp3
156 define i64 @t12(i64 %a, i64 %b) nounwind {
158 ; CHECK: // %bb.0: // %entry
159 ; CHECK-NEXT: mov w8, #35118 // =0x892e
160 ; CHECK-NEXT: movk w8, #65008, lsl #16
161 ; CHECK-NEXT: smaddl x0, w0, w8, x1
164 %tmp1 = trunc i64 %a to i32
165 %tmp2 = sext i32 %tmp1 to i64
166 %tmp3 = mul i64 %tmp2, -34567890
167 %tmp4 = add i64 %b, %tmp3
171 define i64 @t13(i32 %a, i64 %b) nounwind {
173 ; CHECK: // %bb.0: // %entry
174 ; CHECK-NEXT: mov w8, #24910 // =0x614e
175 ; CHECK-NEXT: movk w8, #188, lsl #16
176 ; CHECK-NEXT: umsubl x0, w0, w8, x1
179 %tmp1 = zext i32 %a to i64
180 %tmp3 = mul i64 %tmp1, 12345678
181 %tmp4 = sub i64 %b, %tmp3
185 define i64 @t14(i32 %a, i64 %b) nounwind {
187 ; CHECK: // %bb.0: // %entry
188 ; CHECK-NEXT: mov w8, #40626 // =0x9eb2
189 ; CHECK-NEXT: movk w8, #65347, lsl #16
190 ; CHECK-NEXT: smsubl x0, w0, w8, x1
193 %tmp1 = sext i32 %a to i64
194 %tmp3 = mul i64 %tmp1, -12345678
195 %tmp4 = sub i64 %b, %tmp3