blob: 2f960806753230c49dbc03f18ee6d41fe9e7892f [file] [edit]
# RUN: llc -mtriple=amdgpu9.00-amd-amdhsa -passes='greedy<sgpr>' %s -o - | FileCheck %s
--- |
define void @one_use() { ret void }
define void @implicit_def() { ret void }
define void @two_uses() { ret void }
define void @hot_loop_use() { ret void }
declare void @callee()
...
# A value used once after the call is rematerialized instead of using a CSR.
---
name: one_use
tracksRegLiveness: true
frameInfo:
adjustsStack: true
body: |
; CHECK-LABEL: name: one_use
; CHECK-NOT: assigned-phys: '$sgpr54'
; CHECK: %[[MASK:[0-9]+]]:sreg_32 = S_MOV_B32 2147483647
; CHECK-NEXT: %{{[0-9]+}}:vgpr_32 = V_BFI_B32_e64 %[[MASK]], %{{[0-9]+}}, %{{[0-9]+}}, implicit $exec
bb.0:
liveins: $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr12, $sgpr13, $sgpr14, $sgpr15, $sgpr32
%0:sgpr_64 = COPY $sgpr4_sgpr5
%1:sgpr_64 = COPY $sgpr6_sgpr7
%2:sgpr_64 = COPY $sgpr8_sgpr9
%3:sgpr_64 = COPY $sgpr10_sgpr11
%4:sgpr_32 = COPY $sgpr12
%5:sgpr_32 = COPY $sgpr13
%6:sgpr_32 = COPY $sgpr14
%7:sgpr_32 = COPY $sgpr15
%8:sreg_32 = S_MOV_B32 2147483647
ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
%9:sreg_64_xexec = IMPLICIT_DEF
dead $sgpr30_sgpr31 = SI_CALL %9, @callee, csr_amdgpu, implicit-def $vgpr0
ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
S_NOP 0, implicit %0, implicit %1, implicit %2, implicit %3, implicit %4, implicit %5, implicit %6, implicit %7
%10:vgpr_32 = IMPLICIT_DEF
%11:vgpr_32 = IMPLICIT_DEF
%12:vgpr_32 = V_BFI_B32_e64 %8, %10, %11, implicit $exec
S_NOP 0, implicit %12
S_ENDPGM 0
...
# An implicit definition used after the call is also rematerialized.
---
name: implicit_def
tracksRegLiveness: true
frameInfo:
adjustsStack: true
body: |
; CHECK-LABEL: name: implicit_def
; CHECK-NOT: assigned-phys: '$sgpr54'
; CHECK: %[[MASK:[0-9]+]]:sreg_32 = IMPLICIT_DEF
; CHECK-NEXT: %{{[0-9]+}}:vgpr_32 = V_BFI_B32_e64 %[[MASK]], %{{[0-9]+}}, %{{[0-9]+}}, implicit $exec
bb.0:
liveins: $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr12, $sgpr13, $sgpr14, $sgpr15, $sgpr32
%0:sgpr_64 = COPY $sgpr4_sgpr5
%1:sgpr_64 = COPY $sgpr6_sgpr7
%2:sgpr_64 = COPY $sgpr8_sgpr9
%3:sgpr_64 = COPY $sgpr10_sgpr11
%4:sgpr_32 = COPY $sgpr12
%5:sgpr_32 = COPY $sgpr13
%6:sgpr_32 = COPY $sgpr14
%7:sgpr_32 = COPY $sgpr15
%8:sreg_32 = IMPLICIT_DEF
ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
%9:sreg_64_xexec = IMPLICIT_DEF
dead $sgpr30_sgpr31 = SI_CALL %9, @callee, csr_amdgpu, implicit-def $vgpr0
ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
S_NOP 0, implicit %0, implicit %1, implicit %2, implicit %3, implicit %4, implicit %5, implicit %6, implicit %7
%10:vgpr_32 = IMPLICIT_DEF
%11:vgpr_32 = IMPLICIT_DEF
%12:vgpr_32 = V_BFI_B32_e64 %8, %10, %11, implicit $exec
S_NOP 0, implicit %12
S_ENDPGM 0
...
# A value used on both sides of the call is rematerialized for the later use.
---
name: two_uses
tracksRegLiveness: true
frameInfo:
adjustsStack: true
body: |
; CHECK-LABEL: name: two_uses
; CHECK-NOT: assigned-phys: '$sgpr54'
; CHECK: %[[MASK0:[0-9]+]]:sreg_32 = S_MOV_B32 2147483647
; CHECK: %{{[0-9]+}}:vgpr_32 = V_AND_B32_e64 %[[MASK0]], %{{[0-9]+}}, implicit $exec
; CHECK: %[[MASK1:[0-9]+]]:sreg_32 = S_MOV_B32 2147483647
; CHECK-NEXT: %{{[0-9]+}}:vgpr_32 = V_BFI_B32_e64 %[[MASK1]], %{{[0-9]+}}, %{{[0-9]+}}, implicit $exec
bb.0:
liveins: $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr12, $sgpr13, $sgpr14, $sgpr15, $sgpr32
%0:sgpr_64 = COPY $sgpr4_sgpr5
%1:sgpr_64 = COPY $sgpr6_sgpr7
%2:sgpr_64 = COPY $sgpr8_sgpr9
%3:sgpr_64 = COPY $sgpr10_sgpr11
%4:sgpr_32 = COPY $sgpr12
%5:sgpr_32 = COPY $sgpr13
%6:sgpr_32 = COPY $sgpr14
%7:sgpr_32 = COPY $sgpr15
%8:sreg_32 = S_MOV_B32 2147483647
%10:vgpr_32 = IMPLICIT_DEF
%11:vgpr_32 = V_AND_B32_e64 %8, %10, implicit $exec
ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
%9:sreg_64_xexec = IMPLICIT_DEF
dead $sgpr30_sgpr31 = SI_CALL %9, @callee, csr_amdgpu, implicit-def $vgpr0
ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
S_NOP 0, implicit %0, implicit %1, implicit %2, implicit %3, implicit %4, implicit %5, implicit %6, implicit %7
%12:vgpr_32 = IMPLICIT_DEF
%13:vgpr_32 = V_BFI_B32_e64 %8, %11, %12, implicit $exec
S_NOP 0, implicit %13
S_ENDPGM 0
...
# A use in a hot loop makes rematerialization costlier than assigning a CSR.
---
name: hot_loop_use
tracksRegLiveness: true
frameInfo:
adjustsStack: true
body: |
; CHECK-LABEL: name: hot_loop_use
; The use in bb.1 is more expensive to rematerialize than using a CSR.
; CHECK: - { id: 8, class: sreg_32, preferred-register: '', flags: [ ], assigned-phys: '$sgpr53' }
bb.0:
successors: %bb.1
liveins: $sgpr4_sgpr5, $sgpr6_sgpr7, $sgpr8_sgpr9, $sgpr10_sgpr11, $sgpr12, $sgpr13, $sgpr14, $sgpr15, $sgpr32
%0:sgpr_64 = COPY $sgpr4_sgpr5
%1:sgpr_64 = COPY $sgpr6_sgpr7
%2:sgpr_64 = COPY $sgpr8_sgpr9
%3:sgpr_64 = COPY $sgpr10_sgpr11
%4:sgpr_32 = COPY $sgpr12
%5:sgpr_32 = COPY $sgpr13
%6:sgpr_32 = COPY $sgpr14
%7:sgpr_32 = COPY $sgpr15
%8:sreg_32 = S_MOV_B32 2147483647
S_BRANCH %bb.1
bb.1:
successors: %bb.1(0x7f000000), %bb.2(0x01000000)
liveins: $sgpr32
ADJCALLSTACKUP 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
%9:sreg_64_xexec = IMPLICIT_DEF
dead $sgpr30_sgpr31 = SI_CALL %9, @callee, csr_amdgpu, implicit-def $vgpr0
ADJCALLSTACKDOWN 0, 0, implicit-def dead $scc, implicit-def $sgpr32, implicit $sgpr32
%10:vgpr_32 = IMPLICIT_DEF
%11:vgpr_32 = V_BFI_B32_e64 %8, %10, %10, implicit $exec
S_CBRANCH_SCC1 %bb.1, implicit undef $scc
S_BRANCH %bb.2
bb.2:
S_NOP 0, implicit %0, implicit %1, implicit %2, implicit %3, implicit %4, implicit %5, implicit %6, implicit %7, implicit %11
S_ENDPGM 0
...