1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s | FileCheck %s
4 ; Test custom lowering for 32-bit integer multiplication.
6 target datalayout = "E-m:e-p:32:32-i64:64-a:0:32-n32-S64"
7 target triple = "lanai"
9 define i32 @f6(i32 inreg %a) #0 {
12 ; CHECK-NEXT: st %fp, [--%sp]
13 ; CHECK-NEXT: add %sp, 0x8, %fp
14 ; CHECK-NEXT: sub %sp, 0x8, %sp
15 ; CHECK-NEXT: sh %r6, 0x1, %r3
16 ; CHECK-NEXT: sh %r6, 0x3, %r9
17 ; CHECK-NEXT: sub %r9, %r3, %rv
18 ; CHECK-NEXT: ld -4[%fp], %pc ! return
19 ; CHECK-NEXT: add %fp, 0x0, %sp
20 ; CHECK-NEXT: ld -8[%fp], %fp
21 %1 = mul nsw i32 %a, 6
25 define i32 @f7(i32 inreg %a) #0 {
28 ; CHECK-NEXT: st %fp, [--%sp]
29 ; CHECK-NEXT: add %sp, 0x8, %fp
30 ; CHECK-NEXT: sub %sp, 0x8, %sp
31 ; CHECK-NEXT: sh %r6, 0x3, %r3
32 ; CHECK-NEXT: sub %r3, %r6, %rv
33 ; CHECK-NEXT: ld -4[%fp], %pc ! return
34 ; CHECK-NEXT: add %fp, 0x0, %sp
35 ; CHECK-NEXT: ld -8[%fp], %fp
36 %1 = mul nsw i32 %a, 7
40 define i32 @f8(i32 inreg %a) #0 {
43 ; CHECK-NEXT: st %fp, [--%sp]
44 ; CHECK-NEXT: add %sp, 0x8, %fp
45 ; CHECK-NEXT: sub %sp, 0x8, %sp
46 ; CHECK-NEXT: sh %r6, 0x3, %rv
47 ; CHECK-NEXT: ld -4[%fp], %pc ! return
48 ; CHECK-NEXT: add %fp, 0x0, %sp
49 ; CHECK-NEXT: ld -8[%fp], %fp
50 %1 = shl nsw i32 %a, 3
54 define i32 @f9(i32 inreg %a) #0 {
57 ; CHECK-NEXT: st %fp, [--%sp]
58 ; CHECK-NEXT: add %sp, 0x8, %fp
59 ; CHECK-NEXT: sub %sp, 0x8, %sp
60 ; CHECK-NEXT: sh %r6, 0x3, %r3
61 ; CHECK-NEXT: add %r3, %r6, %rv
62 ; CHECK-NEXT: ld -4[%fp], %pc ! return
63 ; CHECK-NEXT: add %fp, 0x0, %sp
64 ; CHECK-NEXT: ld -8[%fp], %fp
65 %1 = mul nsw i32 %a, 9
69 define i32 @f10(i32 inreg %a) #0 {
72 ; CHECK-NEXT: st %fp, [--%sp]
73 ; CHECK-NEXT: add %sp, 0x8, %fp
74 ; CHECK-NEXT: sub %sp, 0x8, %sp
75 ; CHECK-NEXT: sh %r6, 0x1, %r3
76 ; CHECK-NEXT: sh %r6, 0x3, %r9
77 ; CHECK-NEXT: add %r9, %r3, %rv
78 ; CHECK-NEXT: ld -4[%fp], %pc ! return
79 ; CHECK-NEXT: add %fp, 0x0, %sp
80 ; CHECK-NEXT: ld -8[%fp], %fp
81 %1 = mul nsw i32 %a, 10
85 define i32 @f1280(i32 inreg %a) #0 {
88 ; CHECK-NEXT: st %fp, [--%sp]
89 ; CHECK-NEXT: add %sp, 0x8, %fp
90 ; CHECK-NEXT: sub %sp, 0x8, %sp
91 ; CHECK-NEXT: sh %r6, 0x8, %r3
92 ; CHECK-NEXT: sh %r6, 0xa, %r9
93 ; CHECK-NEXT: add %r9, %r3, %rv
94 ; CHECK-NEXT: ld -4[%fp], %pc ! return
95 ; CHECK-NEXT: add %fp, 0x0, %sp
96 ; CHECK-NEXT: ld -8[%fp], %fp
97 %1 = mul nsw i32 %a, 1280
101 define i32 @fm6(i32 inreg %a) #0 {
104 ; CHECK-NEXT: st %fp, [--%sp]
105 ; CHECK-NEXT: add %sp, 0x8, %fp
106 ; CHECK-NEXT: sub %sp, 0x8, %sp
107 ; CHECK-NEXT: sh %r6, 0x3, %r3
108 ; CHECK-NEXT: sh %r6, 0x1, %r9
109 ; CHECK-NEXT: sub %r9, %r3, %rv
110 ; CHECK-NEXT: ld -4[%fp], %pc ! return
111 ; CHECK-NEXT: add %fp, 0x0, %sp
112 ; CHECK-NEXT: ld -8[%fp], %fp
113 %1 = mul nsw i32 %a, -6
117 define i32 @fm7(i32 inreg %a) #0 {
120 ; CHECK-NEXT: st %fp, [--%sp]
121 ; CHECK-NEXT: add %sp, 0x8, %fp
122 ; CHECK-NEXT: sub %sp, 0x8, %sp
123 ; CHECK-NEXT: sh %r6, 0x3, %r3
124 ; CHECK-NEXT: sub %r6, %r3, %rv
125 ; CHECK-NEXT: ld -4[%fp], %pc ! return
126 ; CHECK-NEXT: add %fp, 0x0, %sp
127 ; CHECK-NEXT: ld -8[%fp], %fp
128 %1 = mul nsw i32 %a, -7
132 define i32 @fm8(i32 inreg %a) #0 {
135 ; CHECK-NEXT: st %fp, [--%sp]
136 ; CHECK-NEXT: add %sp, 0x8, %fp
137 ; CHECK-NEXT: sub %sp, 0x8, %sp
138 ; CHECK-NEXT: sh %r6, 0x3, %r3
139 ; CHECK-NEXT: sub %r0, %r3, %rv
140 ; CHECK-NEXT: ld -4[%fp], %pc ! return
141 ; CHECK-NEXT: add %fp, 0x0, %sp
142 ; CHECK-NEXT: ld -8[%fp], %fp
143 %1 = mul nsw i32 %a, -8
147 define i32 @fm9(i32 inreg %a) #0 {
150 ; CHECK-NEXT: st %fp, [--%sp]
151 ; CHECK-NEXT: add %sp, 0x8, %fp
152 ; CHECK-NEXT: sub %sp, 0x8, %sp
153 ; CHECK-NEXT: sh %r6, 0x3, %r3
154 ; CHECK-NEXT: add %r6, %r3, %r3
155 ; CHECK-NEXT: sub %r0, %r3, %rv
156 ; CHECK-NEXT: ld -4[%fp], %pc ! return
157 ; CHECK-NEXT: add %fp, 0x0, %sp
158 ; CHECK-NEXT: ld -8[%fp], %fp
159 %1 = mul nsw i32 %a, -9
163 define i32 @fm10(i32 inreg %a) #0 {
166 ; CHECK-NEXT: st %fp, [--%sp]
167 ; CHECK-NEXT: add %sp, 0x8, %fp
168 ; CHECK-NEXT: sub %sp, 0x8, %sp
169 ; CHECK-NEXT: sh %r6, 0x3, %r3
170 ; CHECK-NEXT: sh %r6, 0x1, %r9
171 ; CHECK-NEXT: add %r9, %r3, %r3
172 ; CHECK-NEXT: sub %r0, %r3, %rv
173 ; CHECK-NEXT: ld -4[%fp], %pc ! return
174 ; CHECK-NEXT: add %fp, 0x0, %sp
175 ; CHECK-NEXT: ld -8[%fp], %fp
176 %1 = mul nsw i32 %a, -10
180 define i32 @h1(i32 inreg %a) #0 {
183 ; CHECK-NEXT: st %fp, [--%sp]
184 ; CHECK-NEXT: add %sp, 0x8, %fp
185 ; CHECK-NEXT: sub %sp, 0x8, %sp
186 ; CHECK-NEXT: mov 0xaaaa0000, %r3
187 ; CHECK-NEXT: add %pc, 0x10, %rca
188 ; CHECK-NEXT: st %rca, [--%sp]
189 ; CHECK-NEXT: bt __mulsi3
190 ; CHECK-NEXT: or %r3, 0xaaab, %r7
191 ; CHECK-NEXT: ld -4[%fp], %pc ! return
192 ; CHECK-NEXT: add %fp, 0x0, %sp
193 ; CHECK-NEXT: ld -8[%fp], %fp
194 %1 = mul i32 %a, -1431655765