1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs -o - %s | FileCheck %s
4 # Post-legalizer should not generate divrem instruction.
7 tracksRegLiveness: true
11 liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
12 ; CHECK-LABEL: name: test_sdiv_srem
13 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
15 ; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
16 ; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
17 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
18 ; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
19 ; CHECK-NEXT: %div:_(s32) = G_SDIV %src1, %src2
20 ; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
21 ; CHECK-NEXT: %rem:_(s32) = G_SREM %src1, %src2
22 ; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
23 %src1:_(s32) = COPY $vgpr0
24 %src2:_(s32) = COPY $vgpr1
25 %ptr1:_(p1) = COPY $vgpr2_vgpr3
26 %ptr2:_(p1) = COPY $vgpr4_vgpr5
27 %div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
28 G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
29 %rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
30 G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
34 tracksRegLiveness: true
38 liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
39 ; CHECK-LABEL: name: test_srem_sdiv
40 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
42 ; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
43 ; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
44 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
45 ; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
46 ; CHECK-NEXT: %rem:_(s32) = G_SREM %src1, %src2
47 ; CHECK-NEXT: G_STORE %rem(s32), %ptr1(p1) :: (store (s32), addrspace 1)
48 ; CHECK-NEXT: %div:_(s32) = G_SDIV %src1, %src2
49 ; CHECK-NEXT: G_STORE %div(s32), %ptr2(p1) :: (store (s32), addrspace 1)
50 %src1:_(s32) = COPY $vgpr0
51 %src2:_(s32) = COPY $vgpr1
52 %ptr1:_(p1) = COPY $vgpr2_vgpr3
53 %ptr2:_(p1) = COPY $vgpr4_vgpr5
54 %rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
55 G_STORE %rem:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
56 %div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
57 G_STORE %div:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
61 tracksRegLiveness: true
65 liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
66 ; CHECK-LABEL: name: test_udiv_urem
67 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
69 ; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
70 ; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
71 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
72 ; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
73 ; CHECK-NEXT: %div:_(s32) = G_UDIV %src1, %src2
74 ; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
75 ; CHECK-NEXT: %rem:_(s32) = G_UREM %src1, %src2
76 ; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
77 %src1:_(s32) = COPY $vgpr0
78 %src2:_(s32) = COPY $vgpr1
79 %ptr1:_(p1) = COPY $vgpr2_vgpr3
80 %ptr2:_(p1) = COPY $vgpr4_vgpr5
81 %div:_(s32) = G_UDIV %src1:_(s32), %src2:_(s32)
82 G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
83 %rem:_(s32) = G_UREM %src1:_(s32), %src2:_(s32)
84 G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
88 tracksRegLiveness: true
92 liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
93 ; CHECK-LABEL: name: test_urem_udiv
94 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5
96 ; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
97 ; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
98 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
99 ; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
100 ; CHECK-NEXT: %rem:_(s32) = G_UREM %src1, %src2
101 ; CHECK-NEXT: G_STORE %rem(s32), %ptr1(p1) :: (store (s32), addrspace 1)
102 ; CHECK-NEXT: %div:_(s32) = G_UDIV %src1, %src2
103 ; CHECK-NEXT: G_STORE %div(s32), %ptr2(p1) :: (store (s32), addrspace 1)
104 %src1:_(s32) = COPY $vgpr0
105 %src2:_(s32) = COPY $vgpr1
106 %ptr1:_(p1) = COPY $vgpr2_vgpr3
107 %ptr2:_(p1) = COPY $vgpr4_vgpr5
108 %rem:_(s32) = G_UREM %src1:_(s32), %src2:_(s32)
109 G_STORE %rem:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
110 %div:_(s32) = G_UDIV %src1:_(s32), %src2:_(s32)
111 G_STORE %div:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
114 name: test_sdiv_srem_v2
115 tracksRegLiveness: true
119 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
120 ; CHECK-LABEL: name: test_sdiv_srem_v2
121 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
123 ; CHECK-NEXT: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
124 ; CHECK-NEXT: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
125 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr4_vgpr5
126 ; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr6_vgpr7
127 ; CHECK-NEXT: %div:_(<2 x s32>) = G_SDIV %src1, %src2
128 ; CHECK-NEXT: G_STORE %div(<2 x s32>), %ptr1(p1) :: (store (<2 x s32>), align 4, addrspace 1)
129 ; CHECK-NEXT: %rem:_(<2 x s32>) = G_SREM %src1, %src2
130 ; CHECK-NEXT: G_STORE %rem(<2 x s32>), %ptr2(p1) :: (store (<2 x s32>), align 4, addrspace 1)
131 %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
132 %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
133 %ptr1:_(p1) = COPY $vgpr4_vgpr5
134 %ptr2:_(p1) = COPY $vgpr6_vgpr7
135 %div:_(<2 x s32>) = G_SDIV %src1:_(<2 x s32>), %src2:_(<2 x s32>)
136 G_STORE %div:_(<2 x s32>), %ptr1:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
137 %rem:_(<2 x s32>) = G_SREM %src1:_(<2 x s32>), %src2:_(<2 x s32>)
138 G_STORE %rem:_(<2 x s32>), %ptr2:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
141 name: test_udiv_urem_v2
142 tracksRegLiveness: true
146 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
147 ; CHECK-LABEL: name: test_udiv_urem_v2
148 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
150 ; CHECK-NEXT: %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
151 ; CHECK-NEXT: %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
152 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr4_vgpr5
153 ; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr6_vgpr7
154 ; CHECK-NEXT: %div:_(<2 x s32>) = G_UDIV %src1, %src2
155 ; CHECK-NEXT: G_STORE %div(<2 x s32>), %ptr1(p1) :: (store (<2 x s32>), align 4, addrspace 1)
156 ; CHECK-NEXT: %rem:_(<2 x s32>) = G_UREM %src1, %src2
157 ; CHECK-NEXT: G_STORE %rem(<2 x s32>), %ptr2(p1) :: (store (<2 x s32>), align 4, addrspace 1)
158 %src1:_(<2 x s32>) = COPY $vgpr0_vgpr1
159 %src2:_(<2 x s32>) = COPY $vgpr2_vgpr3
160 %ptr1:_(p1) = COPY $vgpr4_vgpr5
161 %ptr2:_(p1) = COPY $vgpr6_vgpr7
162 %div:_(<2 x s32>) = G_UDIV %src1:_(<2 x s32>), %src2:_(<2 x s32>)
163 G_STORE %div:_(<2 x s32>), %ptr1:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
164 %rem:_(<2 x s32>) = G_UREM %src1:_(<2 x s32>), %src2:_(<2 x s32>)
165 G_STORE %rem:_(<2 x s32>), %ptr2:_(p1) :: (store (<2 x s32>), addrspace 1, align 4)
168 name: test_sdiv_srem_extra_sdiv
169 tracksRegLiveness: true
173 liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
174 ; CHECK-LABEL: name: test_sdiv_srem_extra_sdiv
175 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
177 ; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
178 ; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
179 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
180 ; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
181 ; CHECK-NEXT: %ptr3:_(p1) = COPY $vgpr6_vgpr7
182 ; CHECK-NEXT: %div:_(s32) = G_SDIV %src1, %src2
183 ; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
184 ; CHECK-NEXT: %rem:_(s32) = G_SREM %src1, %src2
185 ; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
186 ; CHECK-NEXT: %div2:_(s32) = G_SDIV %src1, %src2
187 ; CHECK-NEXT: G_STORE %div2(s32), %ptr3(p1) :: (store (s32), addrspace 1)
188 %src1:_(s32) = COPY $vgpr0
189 %src2:_(s32) = COPY $vgpr1
190 %ptr1:_(p1) = COPY $vgpr2_vgpr3
191 %ptr2:_(p1) = COPY $vgpr4_vgpr5
192 %ptr3:_(p1) = COPY $vgpr6_vgpr7
193 %div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
194 G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
195 %rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
196 G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
197 %div2:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
198 G_STORE %div2:_(s32), %ptr3:_(p1) :: (store (s32), addrspace 1, align 4)
201 name: test_sdiv_srem_extra_srem
202 tracksRegLiveness: true
206 liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
207 ; CHECK-LABEL: name: test_sdiv_srem_extra_srem
208 ; CHECK: liveins: $vgpr0, $vgpr1, $vgpr2_vgpr3, $vgpr4_vgpr5, $vgpr6_vgpr7
210 ; CHECK-NEXT: %src1:_(s32) = COPY $vgpr0
211 ; CHECK-NEXT: %src2:_(s32) = COPY $vgpr1
212 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
213 ; CHECK-NEXT: %ptr2:_(p1) = COPY $vgpr4_vgpr5
214 ; CHECK-NEXT: %ptr3:_(p1) = COPY $vgpr6_vgpr7
215 ; CHECK-NEXT: %div:_(s32) = G_SDIV %src1, %src2
216 ; CHECK-NEXT: G_STORE %div(s32), %ptr1(p1) :: (store (s32), addrspace 1)
217 ; CHECK-NEXT: %rem:_(s32) = G_SREM %src1, %src2
218 ; CHECK-NEXT: G_STORE %rem(s32), %ptr2(p1) :: (store (s32), addrspace 1)
219 ; CHECK-NEXT: %rem2:_(s32) = G_SREM %src1, %src2
220 ; CHECK-NEXT: G_STORE %rem2(s32), %ptr3(p1) :: (store (s32), addrspace 1)
221 %src1:_(s32) = COPY $vgpr0
222 %src2:_(s32) = COPY $vgpr1
223 %ptr1:_(p1) = COPY $vgpr2_vgpr3
224 %ptr2:_(p1) = COPY $vgpr4_vgpr5
225 %ptr3:_(p1) = COPY $vgpr6_vgpr7
226 %div:_(s32) = G_SDIV %src1:_(s32), %src2:_(s32)
227 G_STORE %div:_(s32), %ptr1:_(p1) :: (store (s32), addrspace 1, align 4)
228 %rem:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
229 G_STORE %rem:_(s32), %ptr2:_(p1) :: (store (s32), addrspace 1, align 4)
230 %rem2:_(s32) = G_SREM %src1:_(s32), %src2:_(s32)
231 G_STORE %rem2:_(s32), %ptr3:_(p1) :: (store (s32), addrspace 1, align 4)