| # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6 |
| # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -mattr=+wavefrontsize32 --run-pass=si-fix-sgpr-copies,livevars,phi-node-elimination -o - %s | FileCheck %s --check-prefixes=W32 |
| # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -mattr=+wavefrontsize64 --run-pass=si-fix-sgpr-copies,livevars,phi-node-elimination -o - %s | FileCheck %s --check-prefixes=W64 |
| |
| # The waterfall loop computes the new EXEC value into a virtual register and |
| # writes EXEC from a terminator. PHI elimination therefore places the copy for |
| # the loop-carried lane mask before the EXEC write, while EXEC is still full. |
| |
| --- |
| name: waterfall_exec_update |
| tracksRegLiveness: true |
| liveins: |
| - { reg: '$vgpr0', virtual-reg: '%0' } |
| - { reg: '$vgpr1', virtual-reg: '%1' } |
| - { reg: '$vgpr2', virtual-reg: '%2' } |
| - { reg: '$vgpr3', virtual-reg: '%3' } |
| - { reg: '$vgpr4', virtual-reg: '%4' } |
| body: | |
| bb.0: |
| liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $vgpr4 |
| ; W32-LABEL: name: waterfall_exec_update |
| ; W32: successors: %bb.1(0x80000000) |
| ; W32-NEXT: liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $vgpr4 |
| ; W32-NEXT: {{ $}} |
| ; W32-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY killed $vgpr4 |
| ; W32-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY killed $vgpr3 |
| ; W32-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY killed $vgpr2 |
| ; W32-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY killed $vgpr1 |
| ; W32-NEXT: [[COPY4:%[0-9]+]]:vgpr_32 = COPY killed $vgpr0 |
| ; W32-NEXT: [[REG_SEQUENCE:%[0-9]+]]:vreg_128 = REG_SEQUENCE killed [[COPY4]], %subreg.sub0, killed [[COPY3]], %subreg.sub1, killed [[COPY2]], %subreg.sub2, killed [[COPY1]], %subreg.sub3 |
| ; W32-NEXT: [[S_MOV_B32_:%[0-9]+]]:sreg_32_xm0_xexec = S_MOV_B32 $exec_lo |
| ; W32-NEXT: [[S_MOV_B32_1:%[0-9]+]]:sreg_32_xm0_xexec = S_MOV_B32 $exec_lo |
| ; W32-NEXT: [[COPY5:%[0-9]+]]:sreg_32_xm0_xexec = COPY killed [[S_MOV_B32_1]] |
| ; W32-NEXT: {{ $}} |
| ; W32-NEXT: .1: |
| ; W32-NEXT: successors: %bb.2(0x80000000) |
| ; W32-NEXT: {{ $}} |
| ; W32-NEXT: [[COPY6:%[0-9]+]]:sreg_32_xm0_xexec = COPY killed [[COPY5]] |
| ; W32-NEXT: [[V_READFIRSTLANE_B32_:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[REG_SEQUENCE]].sub0, implicit $exec |
| ; W32-NEXT: [[V_READFIRSTLANE_B32_1:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[REG_SEQUENCE]].sub1, implicit $exec |
| ; W32-NEXT: [[REG_SEQUENCE1:%[0-9]+]]:sgpr_64 = REG_SEQUENCE [[V_READFIRSTLANE_B32_]], %subreg.sub0, [[V_READFIRSTLANE_B32_1]], %subreg.sub1 |
| ; W32-NEXT: [[V_READFIRSTLANE_B32_2:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[REG_SEQUENCE]].sub2, implicit $exec |
| ; W32-NEXT: [[V_READFIRSTLANE_B32_3:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[REG_SEQUENCE]].sub3, implicit $exec |
| ; W32-NEXT: [[REG_SEQUENCE2:%[0-9]+]]:sgpr_64 = REG_SEQUENCE [[V_READFIRSTLANE_B32_2]], %subreg.sub0, [[V_READFIRSTLANE_B32_3]], %subreg.sub1 |
| ; W32-NEXT: [[REG_SEQUENCE3:%[0-9]+]]:sgpr_128 = REG_SEQUENCE killed [[V_READFIRSTLANE_B32_]], %subreg.sub0, killed [[V_READFIRSTLANE_B32_1]], %subreg.sub1, killed [[V_READFIRSTLANE_B32_2]], %subreg.sub2, killed [[V_READFIRSTLANE_B32_3]], %subreg.sub3 |
| ; W32-NEXT: V_CMPX_EQ_U64_nosdst_e32_term killed [[REG_SEQUENCE1]], [[REG_SEQUENCE]].sub0_sub1, implicit-def $exec, implicit $exec |
| ; W32-NEXT: V_CMPX_EQ_U64_nosdst_e32_term killed [[REG_SEQUENCE2]], [[REG_SEQUENCE]].sub2_sub3, implicit-def $exec, implicit $exec |
| ; W32-NEXT: {{ $}} |
| ; W32-NEXT: .2: |
| ; W32-NEXT: successors: %bb.1(0x40000000), %bb.3(0x40000000) |
| ; W32-NEXT: {{ $}} |
| ; W32-NEXT: [[BUFFER_LOAD_FORMAT_X_IDXEN:%[0-9]+]]:vgpr_32 = BUFFER_LOAD_FORMAT_X_IDXEN [[COPY]], killed [[REG_SEQUENCE3]], 0, 0, 0, 0, implicit $exec |
| ; W32-NEXT: [[S_ANDN2_B32_:%[0-9]+]]:sreg_32_xm0_xexec = S_ANDN2_B32 killed [[COPY6]], $exec_lo, implicit-def dead $scc |
| ; W32-NEXT: [[COPY5:%[0-9]+]]:sreg_32_xm0_xexec = COPY [[S_ANDN2_B32_]] |
| ; W32-NEXT: $exec_lo = S_MOV_B32_term killed [[S_ANDN2_B32_]] |
| ; W32-NEXT: SI_WATERFALL_LOOP %bb.1, implicit $exec |
| ; W32-NEXT: {{ $}} |
| ; W32-NEXT: .3: |
| ; W32-NEXT: $exec_lo = S_MOV_B32 killed [[S_MOV_B32_]] |
| ; W32-NEXT: $vgpr0 = COPY killed [[BUFFER_LOAD_FORMAT_X_IDXEN]] |
| ; W32-NEXT: S_ENDPGM 0, implicit killed $vgpr0 |
| ; |
| ; W64-LABEL: name: waterfall_exec_update |
| ; W64: successors: %bb.1(0x80000000) |
| ; W64-NEXT: liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3, $vgpr4 |
| ; W64-NEXT: {{ $}} |
| ; W64-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY killed $vgpr4 |
| ; W64-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY killed $vgpr3 |
| ; W64-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY killed $vgpr2 |
| ; W64-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY killed $vgpr1 |
| ; W64-NEXT: [[COPY4:%[0-9]+]]:vgpr_32 = COPY killed $vgpr0 |
| ; W64-NEXT: [[REG_SEQUENCE:%[0-9]+]]:vreg_128 = REG_SEQUENCE killed [[COPY4]], %subreg.sub0, killed [[COPY3]], %subreg.sub1, killed [[COPY2]], %subreg.sub2, killed [[COPY1]], %subreg.sub3 |
| ; W64-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 $exec |
| ; W64-NEXT: [[S_MOV_B64_1:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 $exec |
| ; W64-NEXT: [[COPY5:%[0-9]+]]:sreg_64_xexec = COPY killed [[S_MOV_B64_1]] |
| ; W64-NEXT: {{ $}} |
| ; W64-NEXT: .1: |
| ; W64-NEXT: successors: %bb.2(0x80000000) |
| ; W64-NEXT: {{ $}} |
| ; W64-NEXT: [[COPY6:%[0-9]+]]:sreg_64_xexec = COPY killed [[COPY5]] |
| ; W64-NEXT: [[V_READFIRSTLANE_B32_:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[REG_SEQUENCE]].sub0, implicit $exec |
| ; W64-NEXT: [[V_READFIRSTLANE_B32_1:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[REG_SEQUENCE]].sub1, implicit $exec |
| ; W64-NEXT: [[REG_SEQUENCE1:%[0-9]+]]:sgpr_64 = REG_SEQUENCE [[V_READFIRSTLANE_B32_]], %subreg.sub0, [[V_READFIRSTLANE_B32_1]], %subreg.sub1 |
| ; W64-NEXT: [[V_READFIRSTLANE_B32_2:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[REG_SEQUENCE]].sub2, implicit $exec |
| ; W64-NEXT: [[V_READFIRSTLANE_B32_3:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[REG_SEQUENCE]].sub3, implicit $exec |
| ; W64-NEXT: [[REG_SEQUENCE2:%[0-9]+]]:sgpr_64 = REG_SEQUENCE [[V_READFIRSTLANE_B32_2]], %subreg.sub0, [[V_READFIRSTLANE_B32_3]], %subreg.sub1 |
| ; W64-NEXT: [[REG_SEQUENCE3:%[0-9]+]]:sgpr_128 = REG_SEQUENCE killed [[V_READFIRSTLANE_B32_]], %subreg.sub0, killed [[V_READFIRSTLANE_B32_1]], %subreg.sub1, killed [[V_READFIRSTLANE_B32_2]], %subreg.sub2, killed [[V_READFIRSTLANE_B32_3]], %subreg.sub3 |
| ; W64-NEXT: V_CMPX_EQ_U64_nosdst_e32_term killed [[REG_SEQUENCE1]], [[REG_SEQUENCE]].sub0_sub1, implicit-def $exec, implicit $exec |
| ; W64-NEXT: V_CMPX_EQ_U64_nosdst_e32_term killed [[REG_SEQUENCE2]], [[REG_SEQUENCE]].sub2_sub3, implicit-def $exec, implicit $exec |
| ; W64-NEXT: {{ $}} |
| ; W64-NEXT: .2: |
| ; W64-NEXT: successors: %bb.1(0x40000000), %bb.3(0x40000000) |
| ; W64-NEXT: {{ $}} |
| ; W64-NEXT: [[BUFFER_LOAD_FORMAT_X_IDXEN:%[0-9]+]]:vgpr_32 = BUFFER_LOAD_FORMAT_X_IDXEN [[COPY]], killed [[REG_SEQUENCE3]], 0, 0, 0, 0, implicit $exec |
| ; W64-NEXT: [[S_ANDN2_B64_:%[0-9]+]]:sreg_64_xexec = S_ANDN2_B64 killed [[COPY6]], $exec, implicit-def dead $scc |
| ; W64-NEXT: [[COPY5:%[0-9]+]]:sreg_64_xexec = COPY [[S_ANDN2_B64_]] |
| ; W64-NEXT: $exec = S_MOV_B64_term killed [[S_ANDN2_B64_]] |
| ; W64-NEXT: SI_WATERFALL_LOOP %bb.1, implicit $exec |
| ; W64-NEXT: {{ $}} |
| ; W64-NEXT: .3: |
| ; W64-NEXT: $exec = S_MOV_B64 killed [[S_MOV_B64_]] |
| ; W64-NEXT: $vgpr0 = COPY killed [[BUFFER_LOAD_FORMAT_X_IDXEN]] |
| ; W64-NEXT: S_ENDPGM 0, implicit killed $vgpr0 |
| %4:vgpr_32 = COPY $vgpr4 |
| %3:vgpr_32 = COPY $vgpr3 |
| %2:vgpr_32 = COPY $vgpr2 |
| %1:vgpr_32 = COPY $vgpr1 |
| %0:vgpr_32 = COPY $vgpr0 |
| %5:sgpr_128 = REG_SEQUENCE %0, %subreg.sub0, %1, %subreg.sub1, %2, %subreg.sub2, %3, %subreg.sub3 |
| %6:vgpr_32 = BUFFER_LOAD_FORMAT_X_IDXEN %4, killed %5, 0, 0, 0, 0, implicit $exec |
| $vgpr0 = COPY %6 |
| S_ENDPGM 0, implicit $vgpr0 |
| ... |