[llvm] [AMDGPU] Allocate i1 argument to SGPRs (PR #72461)

Jun Wang via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 15:55:05 PDT 2024


================
@@ -0,0 +1,506 @@
+; RUN: llc -global-isel -stop-after=irtranslator -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs -o - %s | FileCheck -check-prefixes=GFX9 -enable-var-scope %s
+; RUN: llc -global-isel -stop-after=irtranslator -mtriple=amdgcn -mcpu=gfx1100 -verify-machineinstrs -o - %s | FileCheck -check-prefixes=GFX11 -enable-var-scope %s
+
+define void @void_func_i1(i1 %arg0) {
+; GFX9-LABEL: name: void_func_i1
+; GFX9: bb.1 (%ir-block.0):
+; GFX9-NEXT:   liveins: $sgpr4_sgpr5
+; GFX9-NEXT: {{  $}}
+; GFX9-NEXT:    [[COPY:%[0-9]+]]:sreg_64(s1) = COPY $sgpr4_sgpr5
+; GFX9-NEXT:    [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF  
+; GFX9-NEXT:    G_STORE [[COPY]](s1), [[DEF]](p1) :: (store (s1) into `ptr addrspace(1) undef`, addrspace 1)
+; GFX9-NEXT:    SI_RETURN
+;
+; GFX11-LABEL: name: void_func_i1
+; GFX11: bb.1 (%ir-block.0):
+; GFX11-NEXT:   liveins: $sgpr0
+; GFX11-NEXT: {{  $}}
+; GFX11-NEXT:    [[COPY:%[0-9]+]]:sreg_32(s1) = COPY $sgpr0
+; GFX11-NEXT:    [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF  
+; GFX11-NEXT:    G_STORE [[COPY]](s1), [[DEF]](p1) :: (store (s1) into `ptr addrspace(1) undef`, addrspace 1)
+; GFX11-NEXT:    SI_RETURN
+  store i1 %arg0, ptr addrspace(1) undef
+  ret void
+}
+
+define void @test_call_void_func_i1() {
+; GFX9-LABEL: name: test_call_void_func_i1
+; GFX9: bb.1 (%ir-block.0):
+; GFX9-NEXT:    [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF  
+; GFX9-NEXT:    [[LOAD:%[0-9]+]]:_(s1) = G_LOAD [[DEF]](p1) :: (load (s1) from `ptr addrspace(1) undef`, addrspace 1)
+; GFX9-NEXT:    ADJCALLSTACKUP 0, 0, implicit-def $scc
+; GFX9-NEXT:    [[GLOBAL:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @void_func_i1  
+; GFX9-NEXT:    $sgpr0_sgpr1 = COPY [[LOAD]](s1)
+; GFX9-NEXT:    [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
+; GFX9-NEXT:    $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY]](<4 x s32>)
+; GFX9-NEXT:    $sgpr30_sgpr31 = noconvergent G_SI_CALL [[GLOBAL]](p0), @void_func_i1, csr_amdgpu, implicit $sgpr0_sgpr1, implicit $sgpr0_sgpr1_sgpr2_sgpr3
+; GFX9-NEXT:    ADJCALLSTACKDOWN 0, 0, implicit-def $scc
+; GFX9-NEXT:    SI_RETURN
+;
+; GFX11-LABEL: name: test_call_void_func_i1
+; GFX11: bb.1 (%ir-block.0):
+; GFX11-NEXT:    [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF  
+; GFX11-NEXT:    [[LOAD:%[0-9]+]]:_(s1) = G_LOAD [[DEF]](p1) :: (load (s1) from `ptr addrspace(1) undef`, addrspace 1)
+; GFX11-NEXT:    ADJCALLSTACKUP 0, 0, implicit-def $scc
+; GFX11-NEXT:    [[GLOBAL:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @void_func_i1  
+; GFX11-NEXT:    $sgpr0 = COPY [[LOAD]](s1)
+; GFX11-NEXT:    $sgpr30_sgpr31 = noconvergent G_SI_CALL [[GLOBAL]](p0), @void_func_i1, csr_amdgpu, implicit $sgpr0
+; GFX11-NEXT:    ADJCALLSTACKDOWN 0, 0, implicit-def $scc
+; GFX11-NEXT:    SI_RETURN
+  %val = load i1, ptr addrspace(1) undef
+  call void @void_func_i1(i1 %val)
+  ret void
+}
+
+define void @void_func_i1_zeroext(i1 zeroext %arg0) {
+; GFX9-LABEL: name: void_func_i1_zeroext
+; GFX9: bb.1 (%ir-block.0):
+; GFX9-NEXT:    liveins: $sgpr4_sgpr5
+; GFX9-NEXT: {{  $}}
+; GFX9-NEXT:    [[COPY:%[0-9]+]]:sreg_64(s1) = COPY $sgpr4_sgpr5
+; GFX9-NEXT:    [[CONST:%[0-9]+]]:_(s32) = G_CONSTANT i32 12
+; GFX9-NEXT:    [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF
+; GFX9-NEXT:    [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[COPY]](s1)
+; GFX9-NEXT:    [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ZEXT]], [[CONST]]
+; GFX9-NEXT:    G_STORE [[ADD]](s32), [[DEF]](p1) :: (store (s32) into `ptr addrspace(1) undef`, addrspace 1)
+; GFX9-NEXT:    SI_RETURN
+;
+; GFX11-LABEL: name: void_func_i1_zeroext
+; GFX11: bb.1 (%ir-block.0):
+; GFX11-NEXT:    liveins: $sgpr0
+; GFX11-NEXT: {{  $}}
+; GFX11-NEXT:    [[COPY:%[0-9]+]]:sreg_32(s1) = COPY $sgpr0
+; GFX11-NEXT:    [[CONST:%[0-9]+]]:_(s32) = G_CONSTANT i32 12
+; GFX11-NEXT:    [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF
+; GFX11-NEXT:    [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[COPY]](s1)
+; GFX11-NEXT:    [[ADD:%[0-9]+]]:_(s32) = G_ADD [[ZEXT]], [[CONST]]
+; GFX11-NEXT:    G_STORE [[ADD]](s32), [[DEF]](p1) :: (store (s32) into `ptr addrspace(1) undef`, addrspace 1)
+; GFX11-NEXT:    SI_RETURN
+  %ext = zext i1 %arg0 to i32
+  %add = add i32 %ext, 12
+  store i32 %add, ptr addrspace(1) undef
+  ret void
+}
+
+define void @test_call_void_func_i1_zeroext() {
+; GFX9-LABEL: name: test_call_void_func_i1_zeroext
+; GFX9: bb.1 (%ir-block.0):
+; GFX9-NEXT:    [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF  
+; GFX9-NEXT:    [[LOAD:%[0-9]+]]:_(s1) = G_LOAD [[DEF]](p1) :: (load (s1) from `ptr addrspace(1) undef`, addrspace 1)
+; GFX9-NEXT:    ADJCALLSTACKUP 0, 0, implicit-def $scc
+; GFX9-NEXT:    [[GLOBAL:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @void_func_i1_zeroext 
+; GFX9-NEXT:    $sgpr0_sgpr1 = COPY [[LOAD]](s1)
+; GFX9-NEXT:    [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $sgpr0_sgpr1_sgpr2_sgpr3
+; GFX9-NEXT:    $sgpr0_sgpr1_sgpr2_sgpr3 = COPY [[COPY]](<4 x s32>)
+; GFX9-NEXT:    $sgpr30_sgpr31 = noconvergent G_SI_CALL [[GLOBAL]](p0), @void_func_i1_zeroext, csr_amdgpu, implicit $sgpr0_sgpr1, implicit $sgpr0_sgpr1_sgpr2_sgpr3
+; GFX9-NEXT:    ADJCALLSTACKDOWN 0, 0, implicit-def $scc
+; GFX9-NEXT:    SI_RETURN
+;
+; GFX11-LABEL: name: test_call_void_func_i1_zeroext
+; GFX11: bb.1 (%ir-block.0):
+; GFX11-NEXT:    [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF  
+; GFX11-NEXT:    [[LOAD:%[0-9]+]]:_(s1) = G_LOAD [[DEF]](p1) :: (load (s1) from `ptr addrspace(1) undef`, addrspace 1)
+; GFX11-NEXT:    ADJCALLSTACKUP 0, 0, implicit-def $scc
+; GFX11-NEXT:    [[GLOBAL:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @void_func_i1_zeroext 
+; GFX11-NEXT:    $sgpr0 = COPY [[LOAD]](s1)
+; GFX11-NEXT:    $sgpr30_sgpr31 = noconvergent G_SI_CALL [[GLOBAL]](p0), @void_func_i1_zeroext, csr_amdgpu, implicit $sgpr0
+; GFX11-NEXT:    ADJCALLSTACKDOWN 0, 0, implicit-def $scc
+; GFX11-NEXT:    SI_RETURN
+  %val = load i1, ptr addrspace(1) undef
+  call void @void_func_i1_zeroext(i1 %val)
+  ret void
+}
+
+define void @void_func_i1_signext(i1 signext %arg0) {
----------------
jwanggit86 wrote:

Added the following test functions: `void_func_zeroext_i1_i1_inreg(), void_func_i1_inreg_zeroext_i1(), void_func_signext_i1_i1_inreg(), void_func_i1_inreg_signext_i1()`.


https://github.com/llvm/llvm-project/pull/72461


More information about the llvm-commits mailing list