| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 | |
| ; RUN: llc -global-isel=0 -mtriple=amdgpu12.00-- < %s | FileCheck %s --check-prefixes=GFX12,GFX12-SDAG | |
| ; RUN: llc -global-isel=1 -mtriple=amdgpu12.00-- < %s | FileCheck %s --check-prefixes=GFX12,GFX12-GISEL | |
| ; VGPR "as memory" (address space 13) pointers round-trip through the generic | |
| ; address space via a synthetic aperture, preserving the value, including the | |
| ; -1 null pointer. | |
| define ptr @vgpr_to_flat(ptr addrspace(13) %ptr) { | |
| ; GFX12-SDAG-LABEL: vgpr_to_flat: | |
| ; GFX12-SDAG: ; %bb.0: | |
| ; GFX12-SDAG-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-SDAG-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-SDAG-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-SDAG-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-SDAG-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-SDAG-NEXT: v_cmp_ne_u32_e32 vcc_lo, -1, v0 | |
| ; GFX12-SDAG-NEXT: s_mov_b64 s[0:1], src_shared_base | |
| ; GFX12-SDAG-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-SDAG-NEXT: s_or_b32 s0, s1, 3 | |
| ; GFX12-SDAG-NEXT: s_wait_alu depctr_sa_sdst(0) depctr_va_vcc(0) | |
| ; GFX12-SDAG-NEXT: v_cndmask_b32_e64 v1, 0, s0, vcc_lo | |
| ; GFX12-SDAG-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc_lo | |
| ; GFX12-SDAG-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX12-GISEL-LABEL: vgpr_to_flat: | |
| ; GFX12-GISEL: ; %bb.0: | |
| ; GFX12-GISEL-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-GISEL-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-GISEL-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-GISEL-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-GISEL-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-GISEL-NEXT: v_cmp_ne_u32_e32 vcc_lo, -1, v0 | |
| ; GFX12-GISEL-NEXT: s_mov_b64 s[0:1], src_shared_base | |
| ; GFX12-GISEL-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-GISEL-NEXT: s_or_b32 s0, s1, 3 | |
| ; GFX12-GISEL-NEXT: s_wait_alu depctr_va_vcc(0) | |
| ; GFX12-GISEL-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc_lo | |
| ; GFX12-GISEL-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-GISEL-NEXT: v_cndmask_b32_e64 v1, 0, s0, vcc_lo | |
| ; GFX12-GISEL-NEXT: s_setpc_b64 s[30:31] | |
| %flat = addrspacecast ptr addrspace(13) %ptr to ptr | |
| ret ptr %flat | |
| } | |
| define ptr addrspace(13) @flat_to_vgpr(ptr %flat) { | |
| ; GFX12-LABEL: flat_to_vgpr: | |
| ; GFX12: ; %bb.0: | |
| ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-NEXT: v_cmp_ne_u64_e32 vcc_lo, 0, v[0:1] | |
| ; GFX12-NEXT: s_wait_alu depctr_va_vcc(0) | |
| ; GFX12-NEXT: v_cndmask_b32_e32 v0, -1, v0, vcc_lo | |
| ; GFX12-NEXT: s_setpc_b64 s[30:31] | |
| %v = addrspacecast ptr %flat to ptr addrspace(13) | |
| ret ptr addrspace(13) %v | |
| } | |
| ; With the pointer known to be non-null the null checks are gone. | |
| define ptr @vgpr_to_flat_nonnull(ptr addrspace(13) %ptr) { | |
| ; GFX12-LABEL: vgpr_to_flat_nonnull: | |
| ; GFX12: ; %bb.0: | |
| ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-NEXT: s_mov_b64 s[0:1], src_shared_base | |
| ; GFX12-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-NEXT: s_or_b32 s0, s1, 3 | |
| ; GFX12-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-NEXT: v_mov_b32_e32 v1, s0 | |
| ; GFX12-NEXT: s_setpc_b64 s[30:31] | |
| %flat = addrspacecast nonnull ptr addrspace(13) %ptr to ptr | |
| ret ptr %flat | |
| } | |
| define ptr addrspace(13) @flat_to_vgpr_nonnull(ptr %flat) { | |
| ; GFX12-LABEL: flat_to_vgpr_nonnull: | |
| ; GFX12: ; %bb.0: | |
| ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-NEXT: s_setpc_b64 s[30:31] | |
| %v = addrspacecast nonnull ptr %flat to ptr addrspace(13) | |
| ret ptr addrspace(13) %v | |
| } | |
| define ptr addrspace(13) @vgpr_roundtrip(ptr addrspace(13) %ptr) { | |
| ; GFX12-LABEL: vgpr_roundtrip: | |
| ; GFX12: ; %bb.0: | |
| ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-NEXT: s_setpc_b64 s[30:31] | |
| %flat = addrspacecast ptr addrspace(13) %ptr to ptr | |
| %v = addrspacecast ptr %flat to ptr addrspace(13) | |
| ret ptr addrspace(13) %v | |
| } | |
| ; Vectors of pointers are cast lane by lane, each with its own null check. | |
| define <2 x ptr> @vgpr_to_flat_v2(<2 x ptr addrspace(13)> %ptr) { | |
| ; GFX12-SDAG-LABEL: vgpr_to_flat_v2: | |
| ; GFX12-SDAG: ; %bb.0: | |
| ; GFX12-SDAG-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-SDAG-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-SDAG-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-SDAG-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-SDAG-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-SDAG-NEXT: v_cmp_ne_u32_e32 vcc_lo, -1, v0 | |
| ; GFX12-SDAG-NEXT: s_mov_b64 s[0:1], src_shared_base | |
| ; GFX12-SDAG-NEXT: v_cmp_ne_u32_e64 s0, -1, v1 | |
| ; GFX12-SDAG-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-SDAG-NEXT: s_or_b32 s1, s1, 3 | |
| ; GFX12-SDAG-NEXT: s_wait_alu depctr_sa_sdst(0) depctr_va_vcc(0) | |
| ; GFX12-SDAG-NEXT: v_cndmask_b32_e64 v4, 0, s1, vcc_lo | |
| ; GFX12-SDAG-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc_lo | |
| ; GFX12-SDAG-NEXT: v_cndmask_b32_e64 v3, 0, s1, s0 | |
| ; GFX12-SDAG-NEXT: v_cndmask_b32_e64 v2, 0, v1, s0 | |
| ; GFX12-SDAG-NEXT: s_delay_alu instid0(VALU_DEP_4) | |
| ; GFX12-SDAG-NEXT: v_mov_b32_e32 v1, v4 | |
| ; GFX12-SDAG-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX12-GISEL-LABEL: vgpr_to_flat_v2: | |
| ; GFX12-GISEL: ; %bb.0: | |
| ; GFX12-GISEL-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-GISEL-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-GISEL-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-GISEL-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-GISEL-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-GISEL-NEXT: s_mov_b64 s[0:1], src_shared_base | |
| ; GFX12-GISEL-NEXT: v_cmp_ne_u32_e32 vcc_lo, -1, v0 | |
| ; GFX12-GISEL-NEXT: v_cmp_ne_u32_e64 s0, -1, v1 | |
| ; GFX12-GISEL-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-GISEL-NEXT: s_or_b32 s1, s1, 3 | |
| ; GFX12-GISEL-NEXT: s_wait_alu depctr_va_vcc(0) | |
| ; GFX12-GISEL-NEXT: v_cndmask_b32_e32 v0, 0, v0, vcc_lo | |
| ; GFX12-GISEL-NEXT: v_cndmask_b32_e64 v2, 0, v1, s0 | |
| ; GFX12-GISEL-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-GISEL-NEXT: v_cndmask_b32_e64 v1, 0, s1, vcc_lo | |
| ; GFX12-GISEL-NEXT: v_cndmask_b32_e64 v3, 0, s1, s0 | |
| ; GFX12-GISEL-NEXT: s_setpc_b64 s[30:31] | |
| %flat = addrspacecast <2 x ptr addrspace(13)> %ptr to <2 x ptr> | |
| ret <2 x ptr> %flat | |
| } | |
| define <2 x ptr addrspace(13)> @flat_to_vgpr_v2(<2 x ptr> %flat) { | |
| ; GFX12-LABEL: flat_to_vgpr_v2: | |
| ; GFX12: ; %bb.0: | |
| ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-NEXT: v_cmp_ne_u64_e32 vcc_lo, 0, v[0:1] | |
| ; GFX12-NEXT: s_wait_alu depctr_va_vcc(0) | |
| ; GFX12-NEXT: v_cndmask_b32_e32 v0, -1, v0, vcc_lo | |
| ; GFX12-NEXT: v_cmp_ne_u64_e32 vcc_lo, 0, v[2:3] | |
| ; GFX12-NEXT: s_wait_alu depctr_va_vcc(0) | |
| ; GFX12-NEXT: v_cndmask_b32_e32 v1, -1, v2, vcc_lo | |
| ; GFX12-NEXT: s_setpc_b64 s[30:31] | |
| %v = addrspacecast <2 x ptr> %flat to <2 x ptr addrspace(13)> | |
| ret <2 x ptr addrspace(13)> %v | |
| } | |
| define <2 x ptr> @vgpr_to_flat_nonnull_v2(<2 x ptr addrspace(13)> %ptr) { | |
| ; GFX12-LABEL: vgpr_to_flat_nonnull_v2: | |
| ; GFX12: ; %bb.0: | |
| ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-NEXT: s_mov_b64 s[0:1], src_shared_base | |
| ; GFX12-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-NEXT: s_or_b32 s0, s1, 3 | |
| ; GFX12-NEXT: s_wait_alu depctr_sa_sdst(0) | |
| ; GFX12-NEXT: v_dual_mov_b32 v2, v1 :: v_dual_mov_b32 v1, s0 | |
| ; GFX12-NEXT: v_mov_b32_e32 v3, s0 | |
| ; GFX12-NEXT: s_setpc_b64 s[30:31] | |
| %flat = addrspacecast nonnull <2 x ptr addrspace(13)> %ptr to <2 x ptr> | |
| ret <2 x ptr> %flat | |
| } | |
| define <2 x ptr addrspace(13)> @flat_to_vgpr_nonnull_v2(<2 x ptr> %flat) { | |
| ; GFX12-LABEL: flat_to_vgpr_nonnull_v2: | |
| ; GFX12: ; %bb.0: | |
| ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-NEXT: v_mov_b32_e32 v1, v2 | |
| ; GFX12-NEXT: s_setpc_b64 s[30:31] | |
| %v = addrspacecast nonnull <2 x ptr> %flat to <2 x ptr addrspace(13)> | |
| ret <2 x ptr addrspace(13)> %v | |
| } | |
| define <2 x ptr addrspace(13)> @vgpr_roundtrip_v2(<2 x ptr addrspace(13)> %ptr) { | |
| ; GFX12-LABEL: vgpr_roundtrip_v2: | |
| ; GFX12: ; %bb.0: | |
| ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0 | |
| ; GFX12-NEXT: s_wait_expcnt 0x0 | |
| ; GFX12-NEXT: s_wait_samplecnt 0x0 | |
| ; GFX12-NEXT: s_wait_bvhcnt 0x0 | |
| ; GFX12-NEXT: s_wait_kmcnt 0x0 | |
| ; GFX12-NEXT: s_setpc_b64 s[30:31] | |
| %flat = addrspacecast <2 x ptr addrspace(13)> %ptr to <2 x ptr> | |
| %v = addrspacecast <2 x ptr> %flat to <2 x ptr addrspace(13)> | |
| ret <2 x ptr addrspace(13)> %v | |
| } |