1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - \
8 ; CHECK-LABEL: name: mul_i8
9 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
10 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
11 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
12 ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
13 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64)
14 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
15 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
16 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10
17 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64)
18 ; CHECK-NEXT: PseudoRET implicit $x10
21 %2:_(s8) = G_TRUNC %0(s64)
22 %3:_(s8) = G_TRUNC %1(s64)
23 %4:_(s8) = G_MUL %2, %3
24 %5:_(s64) = G_ANYEXT %4(s8)
26 PseudoRET implicit $x10
33 ; CHECK-LABEL: name: mul_i15
34 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
35 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
36 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
37 ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
38 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64)
39 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
40 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
41 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10
42 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64)
43 ; CHECK-NEXT: PseudoRET implicit $x10
46 %2:_(s15) = G_TRUNC %0(s64)
47 %3:_(s15) = G_TRUNC %1(s64)
48 %4:_(s15) = G_MUL %2, %3
49 %5:_(s64) = G_ANYEXT %4(s15)
51 PseudoRET implicit $x10
58 ; CHECK-LABEL: name: mul_i16
59 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
60 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
61 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
62 ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
63 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64)
64 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
65 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
66 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10
67 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64)
68 ; CHECK-NEXT: PseudoRET implicit $x10
71 %2:_(s16) = G_TRUNC %0(s64)
72 %3:_(s16) = G_TRUNC %1(s64)
73 %4:_(s16) = G_MUL %2, %3
74 %5:_(s64) = G_ANYEXT %4(s16)
76 PseudoRET implicit $x10
83 ; CHECK-LABEL: name: mul_i32
84 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
85 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
86 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
87 ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
88 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64)
89 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
90 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
91 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10
92 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64)
93 ; CHECK-NEXT: PseudoRET implicit $x10
96 %2:_(s32) = G_TRUNC %0(s64)
97 %3:_(s32) = G_TRUNC %1(s64)
98 %4:_(s32) = G_MUL %2, %3
99 %5:_(s64) = G_ANYEXT %4(s32)
101 PseudoRET implicit $x10
108 ; CHECK-LABEL: name: mul_i64
109 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
110 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
111 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
112 ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
113 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64)
114 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__muldi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
115 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
116 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x10
117 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64)
118 ; CHECK-NEXT: PseudoRET implicit $x10
119 %0:_(s64) = COPY $x10
120 %1:_(s64) = COPY $x11
121 %2:_(s64) = G_MUL %0, %1
123 PseudoRET implicit $x10
130 ; CHECK-LABEL: name: mul_i128
131 ; CHECK: %lo1:_(s64) = COPY $x10
132 ; CHECK-NEXT: %hi1:_(s64) = COPY $x11
133 ; CHECK-NEXT: %lo2:_(s64) = COPY $x12
134 ; CHECK-NEXT: %hi2:_(s64) = COPY $x13
135 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
136 ; CHECK-NEXT: $x10 = COPY %lo1(s64)
137 ; CHECK-NEXT: $x11 = COPY %hi1(s64)
138 ; CHECK-NEXT: $x12 = COPY %lo2(s64)
139 ; CHECK-NEXT: $x13 = COPY %hi2(s64)
140 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__multi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit $x13, implicit-def $x10, implicit-def $x11
141 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
142 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
143 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
144 ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
145 ; CHECK-NEXT: $x11 = COPY [[COPY1]](s64)
146 ; CHECK-NEXT: PseudoRET implicit $x10, implicit $x11
147 %lo1:_(s64) = COPY $x10
148 %hi1:_(s64) = COPY $x11
149 %lo2:_(s64) = COPY $x12
150 %hi2:_(s64) = COPY $x13
151 %x1:_(s128) = G_MERGE_VALUES %lo1(s64), %hi1(s64)
152 %x2:_(s128) = G_MERGE_VALUES %lo2(s64), %hi2(s64)
153 %y:_(s128) = G_MUL %x1, %x2
154 %loy:_(s64), %hiy:_(s64) = G_UNMERGE_VALUES %y(s128)
155 $x10 = COPY %loy(s64)
156 $x11 = COPY %hiy(s64)
157 PseudoRET implicit $x10, implicit $x11
164 ; CHECK-LABEL: name: smulh_i64
165 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
166 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
167 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 63
168 ; CHECK-NEXT: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[COPY]], [[C]](s64)
169 ; CHECK-NEXT: [[ASHR1:%[0-9]+]]:_(s64) = G_ASHR [[COPY1]], [[C]](s64)
170 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
171 ; CHECK-NEXT: $x10 = COPY [[COPY]](s64)
172 ; CHECK-NEXT: $x11 = COPY [[ASHR]](s64)
173 ; CHECK-NEXT: $x12 = COPY [[COPY1]](s64)
174 ; CHECK-NEXT: $x13 = COPY [[ASHR1]](s64)
175 ; CHECK-NEXT: PseudoCALL target-flags(riscv-call) &__multi3, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit $x13, implicit-def $x10, implicit-def $x11
176 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
177 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x11
178 ; CHECK-NEXT: $x10 = COPY [[COPY2]](s64)
179 ; CHECK-NEXT: PseudoRET implicit $x10
180 %0:_(s64) = COPY $x10
181 %1:_(s64) = COPY $x11
182 %2:_(s64) = G_SMULH %0, %1
184 PseudoRET implicit $x10