1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=aarch64-- -run-pass=legalizer %s -o - | FileCheck %s
7 ; CHECK-LABEL: name: test_urem_64
8 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
9 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
10 ; CHECK-NEXT: [[UDIV:%[0-9]+]]:_(s64) = G_UDIV [[COPY]], [[COPY1]]
11 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[UDIV]], [[COPY1]]
12 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[COPY]], [[MUL]]
13 ; CHECK-NEXT: $x0 = COPY [[SUB]](s64)
16 %2:_(s64) = G_UREM %0, %1
24 ; CHECK-LABEL: name: test_srem_32
25 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
26 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
27 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
28 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
29 ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[TRUNC]], [[TRUNC1]]
30 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[SDIV]], [[TRUNC1]]
31 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[TRUNC]], [[MUL]]
32 ; CHECK-NEXT: $w0 = COPY [[SUB]](s32)
35 %2:_(s32) = G_TRUNC %0(s64)
36 %3:_(s32) = G_TRUNC %1(s64)
37 %4:_(s32) = G_SREM %2, %3
45 ; CHECK-LABEL: name: test_srem_8
46 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
47 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
48 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
49 ; CHECK-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC]], 8
50 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
51 ; CHECK-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC1]], 8
52 ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[SEXT_INREG]], [[SEXT_INREG1]]
53 ; CHECK-NEXT: [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
54 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[SDIV]], [[TRUNC2]]
55 ; CHECK-NEXT: [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
56 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[TRUNC3]], [[MUL]]
57 ; CHECK-NEXT: $w0 = COPY [[SUB]](s32)
60 %2:_(s8) = G_TRUNC %0(s64)
61 %3:_(s8) = G_TRUNC %1(s64)
62 %4:_(s8) = G_SREM %2, %3
63 %5:_(s32) = G_ANYEXT %4(s8)
71 ; CHECK-LABEL: name: test_srem_1
72 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
73 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
74 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
75 ; CHECK-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC]], 1
76 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
77 ; CHECK-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC1]], 1
78 ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[SEXT_INREG]], [[SEXT_INREG1]]
79 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[SDIV]], [[SEXT_INREG1]]
80 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[SEXT_INREG]], [[MUL]]
81 ; CHECK-NEXT: $w0 = COPY [[SUB]](s32)
84 %2:_(s1) = G_TRUNC %0(s64)
85 %3:_(s1) = G_TRUNC %1(s64)
86 %4:_(s1) = G_SREM %2, %3
87 %5:_(s32) = G_ANYEXT %4(s1)
96 ; CHECK-LABEL: name: test_urem_1
97 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
98 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
99 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
100 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
101 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC]], [[C]]
102 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
103 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC1]], [[C]]
104 ; CHECK-NEXT: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]]
105 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[UDIV]], [[AND1]]
106 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[AND]], [[MUL]]
107 ; CHECK-NEXT: $w0 = COPY [[SUB]](s32)
110 %2:_(s1) = G_TRUNC %0(s64)
111 %3:_(s1) = G_TRUNC %1(s64)
112 %4:_(s1) = G_UREM %2, %3
113 %5:_(s32) = G_ANYEXT %4(s1)
122 ; CHECK-LABEL: name: test_frem
123 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
124 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
125 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
126 ; CHECK-NEXT: $d0 = COPY [[COPY]](s64)
127 ; CHECK-NEXT: $d1 = COPY [[COPY1]](s64)
128 ; CHECK-NEXT: BL &fmod, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $d0, implicit $d1, implicit-def $d0
129 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
130 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $d0
131 ; CHECK-NEXT: $x0 = COPY [[COPY2]](s64)
132 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
133 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
134 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
135 ; CHECK-NEXT: $s0 = COPY [[TRUNC]](s32)
136 ; CHECK-NEXT: $s1 = COPY [[TRUNC1]](s32)
137 ; CHECK-NEXT: BL &fmodf, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $s0, implicit $s1, implicit-def $s0
138 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
139 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY $s0
140 ; CHECK-NEXT: $w0 = COPY [[COPY3]](s32)
143 %2:_(s64) = G_FREM %0, %1
145 %3:_(s32) = G_TRUNC %0(s64)
146 %4:_(s32) = G_TRUNC %1(s64)
147 %5:_(s32) = G_FREM %3, %4
152 name: test_srem_v2s32
155 ; CHECK-LABEL: name: test_srem_v2s32
156 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
157 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1
158 ; CHECK-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
159 ; CHECK-NEXT: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<2 x s32>)
160 ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[UV]], [[UV2]]
161 ; CHECK-NEXT: [[SDIV1:%[0-9]+]]:_(s32) = G_SDIV [[UV1]], [[UV3]]
162 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[SDIV]](s32), [[SDIV1]](s32)
163 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(<2 x s32>) = G_MUL [[BUILD_VECTOR]], [[COPY1]]
164 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(<2 x s32>) = G_SUB [[COPY]], [[MUL]]
165 ; CHECK-NEXT: $d0 = COPY [[SUB]](<2 x s32>)
166 %0:_(<2 x s32>) = COPY $d0
167 %1:_(<2 x s32>) = COPY $d1
168 %2:_(<2 x s32>) = G_SREM %0, %1
169 $d0 = COPY %2(<2 x s32>)
173 name: test_srem_v4s32
176 ; CHECK-LABEL: name: test_srem_v4s32
177 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
178 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1
179 ; CHECK-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32), [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<4 x s32>)
180 ; CHECK-NEXT: [[UV4:%[0-9]+]]:_(s32), [[UV5:%[0-9]+]]:_(s32), [[UV6:%[0-9]+]]:_(s32), [[UV7:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY1]](<4 x s32>)
181 ; CHECK-NEXT: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[UV]], [[UV4]]
182 ; CHECK-NEXT: [[UDIV1:%[0-9]+]]:_(s32) = G_UDIV [[UV1]], [[UV5]]
183 ; CHECK-NEXT: [[UDIV2:%[0-9]+]]:_(s32) = G_UDIV [[UV2]], [[UV6]]
184 ; CHECK-NEXT: [[UDIV3:%[0-9]+]]:_(s32) = G_UDIV [[UV3]], [[UV7]]
185 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[UDIV]](s32), [[UDIV1]](s32), [[UDIV2]](s32), [[UDIV3]](s32)
186 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(<4 x s32>) = G_MUL [[BUILD_VECTOR]], [[COPY1]]
187 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(<4 x s32>) = G_SUB [[COPY]], [[MUL]]
188 ; CHECK-NEXT: $q0 = COPY [[SUB]](<4 x s32>)
189 %0:_(<4 x s32>) = COPY $q0
190 %1:_(<4 x s32>) = COPY $q1
191 %2:_(<4 x s32>) = G_UREM %0, %1
192 $q0 = COPY %2(<4 x s32>)
196 name: test_srem_v2s64
199 ; CHECK-LABEL: name: test_srem_v2s64
200 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
201 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1
202 ; CHECK-NEXT: [[UV:%[0-9]+]]:_(s64), [[UV1:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[COPY]](<2 x s64>)
203 ; CHECK-NEXT: [[UV2:%[0-9]+]]:_(s64), [[UV3:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[COPY1]](<2 x s64>)
204 ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s64) = G_SDIV [[UV]], [[UV2]]
205 ; CHECK-NEXT: [[SDIV1:%[0-9]+]]:_(s64) = G_SDIV [[UV1]], [[UV3]]
206 ; CHECK-NEXT: [[UV4:%[0-9]+]]:_(s64), [[UV5:%[0-9]+]]:_(s64) = G_UNMERGE_VALUES [[COPY1]](<2 x s64>)
207 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[SDIV]], [[UV4]]
208 ; CHECK-NEXT: [[MUL1:%[0-9]+]]:_(s64) = G_MUL [[SDIV1]], [[UV5]]
209 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[MUL]](s64), [[MUL1]](s64)
210 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(<2 x s64>) = G_SUB [[COPY]], [[BUILD_VECTOR]]
211 ; CHECK-NEXT: $q0 = COPY [[SUB]](<2 x s64>)
212 %0:_(<2 x s64>) = COPY $q0
213 %1:_(<2 x s64>) = COPY $q1
214 %2:_(<2 x s64>) = G_SREM %0, %1
215 $q0 = COPY %2(<2 x s64>)
219 name: test_srem_v4s16
222 ; CHECK-LABEL: name: test_srem_v4s16
223 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s16>) = COPY $d0
224 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<4 x s16>) = COPY $d1
225 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(<4 x s32>) = G_ZEXT [[COPY]](<4 x s16>)
226 ; CHECK-NEXT: [[ZEXT1:%[0-9]+]]:_(<4 x s32>) = G_ZEXT [[COPY1]](<4 x s16>)
227 ; CHECK-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32), [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[ZEXT]](<4 x s32>)
228 ; CHECK-NEXT: [[UV4:%[0-9]+]]:_(s32), [[UV5:%[0-9]+]]:_(s32), [[UV6:%[0-9]+]]:_(s32), [[UV7:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[ZEXT1]](<4 x s32>)
229 ; CHECK-NEXT: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[UV]], [[UV4]]
230 ; CHECK-NEXT: [[UDIV1:%[0-9]+]]:_(s32) = G_UDIV [[UV1]], [[UV5]]
231 ; CHECK-NEXT: [[UDIV2:%[0-9]+]]:_(s32) = G_UDIV [[UV2]], [[UV6]]
232 ; CHECK-NEXT: [[UDIV3:%[0-9]+]]:_(s32) = G_UDIV [[UV3]], [[UV7]]
233 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s32>) = G_BUILD_VECTOR [[UDIV]](s32), [[UDIV1]](s32), [[UDIV2]](s32), [[UDIV3]](s32)
234 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(<4 x s32>) = G_MUL [[BUILD_VECTOR]], [[ZEXT1]]
235 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(<4 x s32>) = G_SUB [[ZEXT]], [[MUL]]
236 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(<4 x s16>) = G_TRUNC [[SUB]](<4 x s32>)
237 ; CHECK-NEXT: $d0 = COPY [[TRUNC]](<4 x s16>)
238 %0:_(<4 x s16>) = COPY $d0
239 %1:_(<4 x s16>) = COPY $d1
240 %2:_(<4 x s16>) = G_UREM %0, %1
241 $d0 = COPY %2(<4 x s16>)