Skip to content

Commit 24c1561

Browse files
committed
AMDGPU/GlobalISel: Add some missing tests for non-power-of-2 cases
1 parent 044d40e commit 24c1561

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-icmp.mir

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,62 @@ body: |
161161
$vgpr0 = COPY %5
162162
...
163163

164+
---
165+
name: test_icmp_s24
166+
body: |
167+
bb.0:
168+
liveins: $vgpr0
169+
; GFX7-LABEL: name: test_icmp_s24
170+
; GFX7: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
171+
; GFX7: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
172+
; GFX7: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16777215
173+
; GFX7: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C]](s32)
174+
; GFX7: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C1]]
175+
; GFX7: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
176+
; GFX7: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C1]]
177+
; GFX7: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s32), [[AND1]]
178+
; GFX7: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C]](s32)
179+
; GFX7: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
180+
; GFX7: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[COPY3]], [[COPY4]]
181+
; GFX7: [[COPY5:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
182+
; GFX7: $vgpr0 = COPY [[COPY5]](s32)
183+
; GFX8-LABEL: name: test_icmp_s24
184+
; GFX8: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
185+
; GFX8: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
186+
; GFX8: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16777215
187+
; GFX8: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C]](s32)
188+
; GFX8: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C1]]
189+
; GFX8: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
190+
; GFX8: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C1]]
191+
; GFX8: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s32), [[AND1]]
192+
; GFX8: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C]](s32)
193+
; GFX8: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
194+
; GFX8: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[COPY3]], [[COPY4]]
195+
; GFX8: [[COPY5:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
196+
; GFX8: $vgpr0 = COPY [[COPY5]](s32)
197+
; GFX9-LABEL: name: test_icmp_s24
198+
; GFX9: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
199+
; GFX9: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
200+
; GFX9: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 16777215
201+
; GFX9: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C]](s32)
202+
; GFX9: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C1]]
203+
; GFX9: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
204+
; GFX9: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C1]]
205+
; GFX9: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s32), [[AND1]]
206+
; GFX9: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C]](s32)
207+
; GFX9: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
208+
; GFX9: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[COPY3]], [[COPY4]]
209+
; GFX9: [[COPY5:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
210+
; GFX9: $vgpr0 = COPY [[COPY5]](s32)
211+
%0:_(s24) = G_CONSTANT i24 0
212+
%1:_(s32) = COPY $vgpr0
213+
%2:_(s24) = G_TRUNC %1
214+
%3:_(s1) = G_ICMP intpred(ne), %0, %2
215+
%4:_(s24) = G_SELECT %3, %0, %2
216+
%5:_(s32) = G_ANYEXT %4
217+
$vgpr0 = COPY %5
218+
...
219+
164220
---
165221
name: test_icmp_v2s32
166222
body: |
@@ -780,3 +836,45 @@ body: |
780836
%5:_(<2 x s32>) = G_SELECT %4, %2, %3
781837
$vgpr0_vgpr1 = COPY %5
782838
...
839+
840+
---
841+
name: test_icmp_s33
842+
body: |
843+
bb.0:
844+
liveins: $vgpr0_vgpr1
845+
; GFX7-LABEL: name: test_icmp_s33
846+
; GFX7: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
847+
; GFX7: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
848+
; GFX7: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 8589934591
849+
; GFX7: [[COPY1:%[0-9]+]]:_(s64) = COPY [[C]](s64)
850+
; GFX7: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
851+
; GFX7: [[COPY2:%[0-9]+]]:_(s64) = COPY [[C]](s64)
852+
; GFX7: [[AND1:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C1]]
853+
; GFX7: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s64), [[AND1]]
854+
; GFX7: S_ENDPGM 0, implicit [[ICMP]](s1)
855+
; GFX8-LABEL: name: test_icmp_s33
856+
; GFX8: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
857+
; GFX8: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
858+
; GFX8: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 8589934591
859+
; GFX8: [[COPY1:%[0-9]+]]:_(s64) = COPY [[C]](s64)
860+
; GFX8: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
861+
; GFX8: [[COPY2:%[0-9]+]]:_(s64) = COPY [[C]](s64)
862+
; GFX8: [[AND1:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C1]]
863+
; GFX8: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s64), [[AND1]]
864+
; GFX8: S_ENDPGM 0, implicit [[ICMP]](s1)
865+
; GFX9-LABEL: name: test_icmp_s33
866+
; GFX9: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
867+
; GFX9: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
868+
; GFX9: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 8589934591
869+
; GFX9: [[COPY1:%[0-9]+]]:_(s64) = COPY [[C]](s64)
870+
; GFX9: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
871+
; GFX9: [[COPY2:%[0-9]+]]:_(s64) = COPY [[C]](s64)
872+
; GFX9: [[AND1:%[0-9]+]]:_(s64) = G_AND [[COPY2]], [[C1]]
873+
; GFX9: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s64), [[AND1]]
874+
; GFX9: S_ENDPGM 0, implicit [[ICMP]](s1)
875+
%0:_(s64) = COPY $vgpr0_vgpr1
876+
%1:_(s33) = G_TRUNC %0
877+
%2:_(s33) = G_CONSTANT i33 0
878+
%3:_(s1) = G_ICMP intpred(ne), %2, %2
879+
S_ENDPGM 0, implicit %3
880+
...

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-inttoptr.mir

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,40 @@ body: |
160160
%1:_(<2 x p0>) = G_INTTOPTR %0
161161
$vgpr0_vgpr1_vgpr2_vgpr3 = COPY %1
162162
...
163+
164+
---
165+
name: test_inttoptr_s29_to_p3
166+
body: |
167+
bb.0:
168+
liveins: $vgpr0
169+
170+
; CHECK-LABEL: name: test_inttoptr_s29_to_p3
171+
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
172+
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 536870911
173+
; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
174+
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C]]
175+
; CHECK: [[INTTOPTR:%[0-9]+]]:_(p3) = G_INTTOPTR [[AND]](s32)
176+
; CHECK: S_ENDPGM 0, implicit [[INTTOPTR]](p3)
177+
%0:_(s32) = COPY $vgpr0
178+
%1:_(s29) = G_TRUNC %0
179+
%2:_(p3) = G_INTTOPTR %1
180+
S_ENDPGM 0, implicit %2
181+
...
182+
183+
---
184+
name: test_inttoptr_s33_to_p3
185+
body: |
186+
bb.0:
187+
liveins: $vgpr0_vgpr1
188+
189+
; CHECK-LABEL: name: test_inttoptr_s33_to_p3
190+
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
191+
; CHECK: [[TRUNC:%[0-9]+]]:_(s33) = G_TRUNC [[COPY]](s64)
192+
; CHECK: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[TRUNC]](s33)
193+
; CHECK: [[INTTOPTR:%[0-9]+]]:_(p3) = G_INTTOPTR [[TRUNC1]](s32)
194+
; CHECK: S_ENDPGM 0, implicit [[INTTOPTR]](p3)
195+
%0:_(s64) = COPY $vgpr0_vgpr1
196+
%1:_(s33) = G_TRUNC %0
197+
%2:_(p3) = G_INTTOPTR %1
198+
S_ENDPGM 0, implicit %2
199+
...

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-ptrtoint.mir

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,35 @@ body: |
161161
%1:_(<2 x s32>) = G_PTRTOINT %0
162162
$vgpr0_vgpr1 = COPY %1
163163
...
164+
165+
---
166+
name: test_ptrtoint_p3_to_s29
167+
body: |
168+
bb.0:
169+
liveins: $vgpr0
170+
171+
; CHECK-LABEL: name: test_ptrtoint_p3_to_s29
172+
; CHECK: [[COPY:%[0-9]+]]:_(p3) = COPY $vgpr0
173+
; CHECK: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY]](p3)
174+
; CHECK: [[TRUNC:%[0-9]+]]:_(s29) = G_TRUNC [[PTRTOINT]](s32)
175+
; CHECK: S_ENDPGM 0, implicit [[TRUNC]](s29)
176+
%0:_(p3) = COPY $vgpr0
177+
%1:_(s29) = G_PTRTOINT %0
178+
S_ENDPGM 0, implicit %1
179+
...
180+
181+
---
182+
name: test_ptrtoint_p3_to_s33
183+
body: |
184+
bb.0:
185+
liveins: $vgpr0
186+
187+
; CHECK-LABEL: name: test_ptrtoint_p3_to_s33
188+
; CHECK: [[COPY:%[0-9]+]]:_(p3) = COPY $vgpr0
189+
; CHECK: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY]](p3)
190+
; CHECK: [[ZEXT:%[0-9]+]]:_(s33) = G_ZEXT [[PTRTOINT]](s32)
191+
; CHECK: S_ENDPGM 0, implicit [[ZEXT]](s33)
192+
%0:_(p3) = COPY $vgpr0
193+
%1:_(s33) = G_PTRTOINT %0
194+
S_ENDPGM 0, implicit %1
195+
...

0 commit comments

Comments
 (0)