# REQUIRES: amdgpu-registered-target
# RUN: llvm-reduce -abort-on-invalid-reduction -simplify-mir --delta-passes=instructions -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg --check-prefix=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t 2> %t.log
# RUN: FileCheck --match-full-lines --check-prefix=RESULT %s < %t
# CHECK-INTERESTINGNESS: G_LOAD
# CHECK-INTERESTINGNESS: G_LOAD
# CHECK-INTERESTINGNESS: G_LOAD
# CHECK-INTERESTINGNESS: G_LOAD
# CHECK-INTERESTINGNESS: G_STORE
# CHECK-INTERESTINGNESS: G_STORE
# CHECK-INTERESTINGNESS: G_STORE
# CHECK-INTERESTINGNESS: G_LOAD
# CHECK-INTERESTINGNESS: G_LOAD
# CHECK-INTERESTINGNESS: G_LOAD
# CHECK-INTERESTINGNESS: G_LOAD
# CHECK-INTERESTINGNESS: G_STORE
# CHECK-INTERESTINGNESS: G_STORE
# RESULT: %{{[0-9]+}}:_(<2 x s16>) = G_LOAD %{{[0-9]+}}(p1) :: (load (<2 x s16>) from %ir.argptr0, align 32, addrspace 1)
# RESULT: %{{[0-9]+}}:_(<2 x s32>) = G_LOAD %{{[0-9]+}}(p1) :: (load (<2 x s32>) from %ir.argptr1, addrspace 3)
# RESULT: %{{[0-9]+}}:_(<2 x s32>) = G_LOAD %{{[0-9]+}}(p1) :: (load (<2 x s32>) from %ir.argptr1 + 8, addrspace 3)
# RESULT: %{{[0-9]+}}:_(<2 x s32>) = G_LOAD %{{[0-9]+}}(p1) :: (load (<2 x s32>) from %ir.argptr1 + 12, align 4, basealign 8, addrspace 3)
# RESULT: G_STORE %{{[0-9]+}}(<2 x s32>), %{{[0-9]+}}(p3) :: (store (<2 x s32>) into %fixed-stack.0, addrspace 5)
# RESULT: G_STORE %{{[0-9]+}}(<2 x s32>), %{{[0-9]+}}(p3) :: (store (<2 x s32>) into %stack.0, addrspace 5)
# RESULT: G_STORE %{{[0-9]+}}(p3), %{{[0-9]+}}(p3) :: (store (p3), addrspace 5)
# RESULT: %{{[0-9]+}}:_(s32) = G_LOAD %{{[0-9]+}}(p0) :: (load (s32) from call-entry @foo, addrspace 4)
# RESULT: %{{[0-9]+}}:_(s32) = G_LOAD %{{[0-9]+}}(p1) :: (load (s32) from constant-pool, addrspace 1)
# RESULT: %{{[0-9]+}}:_(p1) = G_LOAD %{{[0-9]+}}(p0) :: (load (p1) from got, addrspace 4)
# RESULT: %{{[0-9]+}}:_(p1) = G_LOAD %{{[0-9]+}}(p0) :: (load (p1) from jump-table, addrspace 4)
# RESULT: G_STORE %{{[0-9]+}}(<3 x s32>), %{{[0-9]+}}(p5) :: (store (<3 x s32>) into stack, align 8, addrspace 5)
# RESULT: G_STORE %{{[0-9]+}}(<3 x s32>), %{{[0-9]+}}(p5) :: (store (<3 x s32>) into stack + 12, align 4, basealign 8, addrspace 5)
--- |
declare i32 @foo(i32)
define void @func(<2 x i16> addrspace(1)* %argptr0, <2 x i32> addrspace(3)* %argptr1) {
ret void
}
...
---
name: func
tracksRegLiveness: true
fixedStack:
- { id: 0, offset: 16, size: 8, alignment: 4 }
stack:
- { id: 0, size: 4, alignment: 16 }
body: |
bb.0:
S_WAITCNT 0
S_NOP 0
%0:_(p1) = G_IMPLICIT_DEF
%1:_(<2 x s16>) = G_LOAD %0 :: (load (<2 x s16>) from %ir.argptr0, align 32, addrspace 1)
%2:_(<2 x s32>) = G_ZEXT %1
%3:_(<2 x s32>) = G_LOAD %0 :: (load (<2 x s32>) from %ir.argptr1, addrspace 3)
%4:_(<2 x s32>) = G_LOAD %0 :: (load (<2 x s32>) from %ir.argptr1 + 8, addrspace 3)
%5:_(<2 x s32>) = G_LOAD %0 :: (load (<2 x s32>) from %ir.argptr1 + 12, addrspace 3)
%6:_(<2 x s32>) = G_ADD %2, %3
%7:_(<2 x s32>) = G_ADD %6, %4
%8:_(<2 x s32>) = G_ADD %7, %5
%9:_(p3) = G_IMPLICIT_DEF
G_STORE %8, %9 :: (store (<2 x s32>) into %fixed-stack.0, addrspace 5)
G_STORE %8, %9 :: (store (<2 x s32>) into %stack.0, addrspace 5)
; Check address space, no value
G_STORE %9, %9 :: (store (p3), addrspace 5)
%10:_(p0) = G_IMPLICIT_DEF
%11:_(s32) = G_LOAD %10 :: (load (s32) from call-entry @foo, addrspace 4)
%12:_(s32) = G_LOAD %0 :: (load (s32) from constant-pool, addrspace 1)
%13:_(p1) = G_LOAD %10 :: (load (p1) from got, addrspace 4)
%14:_(p1) = G_LOAD %10 :: (load (p1) from jump-table, addrspace 4)
%15:_(<3 x s32>) = G_IMPLICIT_DEF
%16:_(p5) = G_IMPLICIT_DEF
G_STORE %15, %16 :: (store (<3 x s32>) into stack, align 8, addrspace 5)
G_STORE %15, %16 :: (store (<3 x s32>) into stack + 12, basealign 8, addrspace 5)
S_ENDPGM 0, implicit %10, implicit %12, implicit %13, implicit %14
...