1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mattr=+m -mtriple=riscv64 -run-pass=legalizer %s -o - \
4 # RUN: llc -mattr=+zmmul -mtriple=riscv64 -run-pass=legalizer %s -o - \
10 ; CHECK-LABEL: name: mul_i8
11 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
12 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
13 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]]
14 ; CHECK-NEXT: $x10 = COPY [[MUL]](s64)
15 ; CHECK-NEXT: PseudoRET implicit $x10
18 %2:_(s8) = G_TRUNC %0(s64)
19 %3:_(s8) = G_TRUNC %1(s64)
20 %4:_(s8) = G_MUL %2, %3
21 %5:_(s64) = G_ANYEXT %4(s8)
23 PseudoRET implicit $x10
30 ; CHECK-LABEL: name: mul_i15
31 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
32 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
33 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]]
34 ; CHECK-NEXT: $x10 = COPY [[MUL]](s64)
35 ; CHECK-NEXT: PseudoRET implicit $x10
38 %2:_(s15) = G_TRUNC %0(s64)
39 %3:_(s15) = G_TRUNC %1(s64)
40 %4:_(s15) = G_MUL %2, %3
41 %5:_(s64) = G_ANYEXT %4(s15)
43 PseudoRET implicit $x10
50 ; CHECK-LABEL: name: mul_i16
51 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
52 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
53 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]]
54 ; CHECK-NEXT: $x10 = COPY [[MUL]](s64)
55 ; CHECK-NEXT: PseudoRET implicit $x10
58 %2:_(s16) = G_TRUNC %0(s64)
59 %3:_(s16) = G_TRUNC %1(s64)
60 %4:_(s16) = G_MUL %2, %3
61 %5:_(s64) = G_ANYEXT %4(s16)
63 PseudoRET implicit $x10
70 ; CHECK-LABEL: name: mul_i32
71 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
72 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
73 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]]
74 ; CHECK-NEXT: $x10 = COPY [[MUL]](s64)
75 ; CHECK-NEXT: PseudoRET implicit $x10
78 %2:_(s32) = G_TRUNC %0(s64)
79 %3:_(s32) = G_TRUNC %1(s64)
80 %4:_(s32) = G_MUL %2, %3
81 %5:_(s64) = G_ANYEXT %4(s32)
83 PseudoRET implicit $x10
90 ; CHECK-LABEL: name: mul_i64
91 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
92 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
93 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[COPY]], [[COPY1]]
94 ; CHECK-NEXT: $x10 = COPY [[MUL]](s64)
95 ; CHECK-NEXT: PseudoRET implicit $x10
98 %2:_(s64) = G_MUL %0, %1
100 PseudoRET implicit $x10
107 ; CHECK-LABEL: name: mul_i72
108 ; CHECK: %xlo:_(s64) = COPY $x10
109 ; CHECK-NEXT: %xhi:_(s64) = COPY $x11
110 ; CHECK-NEXT: %ylo:_(s64) = COPY $x12
111 ; CHECK-NEXT: %yhi:_(s64) = COPY $x13
112 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL %xlo, %ylo
113 ; CHECK-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL %xhi, %ylo
114 ; CHECK-NEXT: [[MUL2:%[0-9]+]]:_(s64) = G_MUL %xlo, %yhi
115 ; CHECK-NEXT: [[UMULH:%[0-9]+]]:_(s64) = G_UMULH %xlo, %ylo
116 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[MUL1]], [[MUL2]]
117 ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD [[ADD]], [[UMULH]]
118 ; CHECK-NEXT: $x10 = COPY [[MUL]](s64)
119 ; CHECK-NEXT: $x11 = COPY [[ADD1]](s64)
120 ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11
121 %xlo:_(s64) = COPY $x10
122 %xhi:_(s64) = COPY $x11
123 %ylo:_(s64) = COPY $x12
124 %yhi:_(s64) = COPY $x13
125 %x0:_(s128) = G_MERGE_VALUES %xlo(s64), %xhi(s64)
126 %y0:_(s128) = G_MERGE_VALUES %ylo(s64), %yhi(s64)
127 %x:_(s72) = G_TRUNC %x0(s128)
128 %y:_(s72) = G_TRUNC %y0(s128)
129 %z:_(s72) = G_MUL %x, %y
130 %z0:_(s128) = G_ANYEXT %z(s72)
131 %zlo:_(s64), %zhi:_(s64) = G_UNMERGE_VALUES %z0(s128)
132 $x10 = COPY %zlo(s64)
133 $x11 = COPY %zhi(s64)
134 PseudoRET implicit $x10, implicit $x11
141 ; CHECK-LABEL: name: mul_i128
142 ; CHECK: %lo1:_(s64) = COPY $x10
143 ; CHECK-NEXT: %hi1:_(s64) = COPY $x11
144 ; CHECK-NEXT: %lo2:_(s64) = COPY $x12
145 ; CHECK-NEXT: %hi2:_(s64) = COPY $x13
146 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL %lo1, %lo2
147 ; CHECK-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL %hi1, %lo2
148 ; CHECK-NEXT: [[MUL2:%[0-9]+]]:_(s64) = G_MUL %lo1, %hi2
149 ; CHECK-NEXT: [[UMULH:%[0-9]+]]:_(s64) = G_UMULH %lo1, %lo2
150 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[MUL1]], [[MUL2]]
151 ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD [[ADD]], [[UMULH]]
152 ; CHECK-NEXT: $x10 = COPY [[MUL]](s64)
153 ; CHECK-NEXT: $x11 = COPY [[ADD1]](s64)
154 ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11
155 %lo1:_(s64) = COPY $x10
156 %hi1:_(s64) = COPY $x11
157 %lo2:_(s64) = COPY $x12
158 %hi2:_(s64) = COPY $x13
159 %x1:_(s128) = G_MERGE_VALUES %lo1(s64), %hi1(s64)
160 %x2:_(s128) = G_MERGE_VALUES %lo2(s64), %hi2(s64)
161 %y:_(s128) = G_MUL %x1, %x2
162 %loy:_(s64), %hiy:_(s64) = G_UNMERGE_VALUES %y(s128)
163 $x10 = COPY %loy(s64)
164 $x11 = COPY %hiy(s64)
165 PseudoRET implicit $x10, implicit $x11
172 ; CHECK-LABEL: name: mul_i192
173 ; CHECK: %lo1:_(s64) = COPY $x10
174 ; CHECK-NEXT: %mid1:_(s64) = COPY $x11
175 ; CHECK-NEXT: %hi1:_(s64) = COPY $x12
176 ; CHECK-NEXT: %lo2:_(s64) = COPY $x13
177 ; CHECK-NEXT: %mid2:_(s64) = COPY $x14
178 ; CHECK-NEXT: %hi2:_(s64) = COPY $x15
179 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL %lo1, %lo2
180 ; CHECK-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL %mid1, %lo2
181 ; CHECK-NEXT: [[MUL2:%[0-9]+]]:_(s64) = G_MUL %lo1, %mid2
182 ; CHECK-NEXT: [[UMULH:%[0-9]+]]:_(s64) = G_UMULH %lo1, %lo2
183 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = G_ADD [[MUL1]], [[MUL2]]
184 ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), [[ADD]](s64), [[MUL2]]
185 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[ADD]](s64)
186 ; CHECK-NEXT: [[ADD1:%[0-9]+]]:_(s64) = G_ADD [[COPY]], [[UMULH]]
187 ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(s64) = G_ICMP intpred(ult), [[ADD1]](s64), [[UMULH]]
188 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY [[ADD1]](s64)
189 ; CHECK-NEXT: [[ADD2:%[0-9]+]]:_(s64) = G_ADD [[ICMP]], [[ICMP1]]
190 ; CHECK-NEXT: [[MUL3:%[0-9]+]]:_(s64) = G_MUL %hi1, %lo2
191 ; CHECK-NEXT: [[MUL4:%[0-9]+]]:_(s64) = G_MUL %mid1, %mid2
192 ; CHECK-NEXT: [[MUL5:%[0-9]+]]:_(s64) = G_MUL %lo1, %hi2
193 ; CHECK-NEXT: [[UMULH1:%[0-9]+]]:_(s64) = G_UMULH %mid1, %lo2
194 ; CHECK-NEXT: [[UMULH2:%[0-9]+]]:_(s64) = G_UMULH %lo1, %mid2
195 ; CHECK-NEXT: [[ADD3:%[0-9]+]]:_(s64) = G_ADD [[MUL3]], [[MUL4]]
196 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY [[ADD3]](s64)
197 ; CHECK-NEXT: [[ADD4:%[0-9]+]]:_(s64) = G_ADD [[COPY2]], [[MUL5]]
198 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY [[ADD4]](s64)
199 ; CHECK-NEXT: [[ADD5:%[0-9]+]]:_(s64) = G_ADD [[COPY3]], [[UMULH1]]
200 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:_(s64) = COPY [[ADD5]](s64)
201 ; CHECK-NEXT: [[ADD6:%[0-9]+]]:_(s64) = G_ADD [[COPY4]], [[UMULH2]]
202 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:_(s64) = COPY [[ADD6]](s64)
203 ; CHECK-NEXT: [[ADD7:%[0-9]+]]:_(s64) = G_ADD [[COPY5]], [[ADD2]]
204 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:_(s64) = COPY [[ADD7]](s64)
205 ; CHECK-NEXT: $x10 = COPY [[MUL]](s64)
206 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64)
207 ; CHECK-NEXT: $x12 = COPY [[COPY6]](s64)
208 ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11, implicit $x12
209 %lo1:_(s64) = COPY $x10
210 %mid1:_(s64) = COPY $x11
211 %hi1:_(s64) = COPY $x12
212 %lo2:_(s64) = COPY $x13
213 %mid2:_(s64) = COPY $x14
214 %hi2:_(s64) = COPY $x15
215 %x1:_(s192) = G_MERGE_VALUES %lo1(s64), %mid1(s64), %hi1(s64)
216 %x2:_(s192) = G_MERGE_VALUES %lo2(s64), %mid2(s64), %hi2(s64)
217 %y:_(s192) = G_MUL %x1, %x2
218 %lo:_(s64), %mid:_(s64), %hi:_(s64) = G_UNMERGE_VALUES %y(s192)
220 $x11 = COPY %mid(s64)
222 PseudoRET implicit $x10, implicit $x11, implicit $x12
229 ; CHECK-LABEL: name: smulh_i32
230 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
231 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
232 ; CHECK-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY]], 32
233 ; CHECK-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s64) = G_SEXT_INREG [[COPY1]], 32
234 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[SEXT_INREG]], [[SEXT_INREG1]]
235 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
236 ; CHECK-NEXT: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[MUL]], [[C]](s64)
237 ; CHECK-NEXT: $x10 = COPY [[ASHR]](s64)
238 ; CHECK-NEXT: PseudoRET implicit $x10
239 %0:_(s64) = COPY $x10
240 %1:_(s64) = COPY $x11
241 %2:_(s32) = G_TRUNC %0(s64)
242 %3:_(s32) = G_TRUNC %1(s64)
243 %4:_(s32) = G_SMULH %2, %3
244 %5:_(s64) = G_ANYEXT %4(s32)
246 PseudoRET implicit $x10