[AMDGPU] Remove -amdgpu-spill-sgpr-to-smem.
Summary: The implementation was never completed and never used except in tests.
Reviewers: arsenm, mareko
Subscribers: qcolombet, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69163
llvm-svn: 375293
2019-10-19 05:48:22 +08:00
|
|
|
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck -check-prefix=TOSGPR -check-prefix=ALL %s
|
2016-11-26 01:37:09 +08:00
|
|
|
|
AMDGPU: Add pass to lower kernel arguments to loads
This replaces most argument uses with loads, but for
now not all.
The code in SelectionDAG for calling convention lowering
is actively harmful for amdgpu_kernel. It attempts to
split the argument types into register legal types, which
results in low quality code for arbitary types. Since
all kernel arguments are passed in memory, we just want the
raw types.
I've tried a couple of methods of mitigating this in SelectionDAG,
but it's easier to just bypass this problem alltogether. It's
possible to hack around the problem in the initial lowering,
but the real problem is the DAG then expects to be able to use
CopyToReg/CopyFromReg for uses of the arguments outside the block.
Exposing the argument loads in the IR also has the advantage
that the LoadStoreVectorizer can merge them.
I'm not sure the best approach to dealing with the IR
argument list is. The patch as-is just leaves the IR arguments
in place, so all the existing code will still compute the same
kernarg size and pointlessly lowers the arguments.
Arguably the frontend should emit kernels with an empty argument
list in the first place. Alternatively a dummy array could be
inserted as a single argument just to reserve space.
This does have some disadvantages. Local pointer kernel arguments can
no longer have AssertZext placed on them as the equivalent !range
metadata is not valid on pointer typed loads. This is mostly bad
for SI which needs to know about the known bits in order to use the
DS instruction offset, so in this case this is not done.
More importantly, this skips noalias arguments since this pass
does not yet convert this to the equivalent !alias.scope and !noalias
metadata. Producing this metadata correctly seems to be tricky,
although this logically is the same as inlining into a function which
doesn't exist. Additionally, exposing these loads to the vectorizer
may result in degraded aliasing information if a pointer load is
merged with another argument load.
I'm also not entirely sure this is preserving the current clover
ABI, although I would greatly prefer if it would stop widening
arguments and match the HSA ABI. As-is I think it is extending
< 4-byte arguments to 4-bytes but doesn't align them to 4-bytes.
llvm-svn: 335650
2018-06-27 03:10:00 +08:00
|
|
|
; FIXME: Vectorization can increase required SGPR count beyond limit.
|
|
|
|
|
2020-01-22 06:27:57 +08:00
|
|
|
; ALL-LABEL: {{^}}max_10_sgprs:
|
2016-10-29 03:43:31 +08:00
|
|
|
|
2016-11-26 01:37:09 +08:00
|
|
|
; ALL: SGPRBlocks: 1
|
2020-01-22 06:27:57 +08:00
|
|
|
; ALL: NumSGPRsForWavesPerEU: 10
|
|
|
|
define amdgpu_kernel void @max_10_sgprs() #0 {
|
AMDGPU: Add pass to lower kernel arguments to loads
This replaces most argument uses with loads, but for
now not all.
The code in SelectionDAG for calling convention lowering
is actively harmful for amdgpu_kernel. It attempts to
split the argument types into register legal types, which
results in low quality code for arbitary types. Since
all kernel arguments are passed in memory, we just want the
raw types.
I've tried a couple of methods of mitigating this in SelectionDAG,
but it's easier to just bypass this problem alltogether. It's
possible to hack around the problem in the initial lowering,
but the real problem is the DAG then expects to be able to use
CopyToReg/CopyFromReg for uses of the arguments outside the block.
Exposing the argument loads in the IR also has the advantage
that the LoadStoreVectorizer can merge them.
I'm not sure the best approach to dealing with the IR
argument list is. The patch as-is just leaves the IR arguments
in place, so all the existing code will still compute the same
kernarg size and pointlessly lowers the arguments.
Arguably the frontend should emit kernels with an empty argument
list in the first place. Alternatively a dummy array could be
inserted as a single argument just to reserve space.
This does have some disadvantages. Local pointer kernel arguments can
no longer have AssertZext placed on them as the equivalent !range
metadata is not valid on pointer typed loads. This is mostly bad
for SI which needs to know about the known bits in order to use the
DS instruction offset, so in this case this is not done.
More importantly, this skips noalias arguments since this pass
does not yet convert this to the equivalent !alias.scope and !noalias
metadata. Producing this metadata correctly seems to be tricky,
although this logically is the same as inlining into a function which
doesn't exist. Additionally, exposing these loads to the vectorizer
may result in degraded aliasing information if a pointer load is
merged with another argument load.
I'm also not entirely sure this is preserving the current clover
ABI, although I would greatly prefer if it would stop widening
arguments and match the HSA ABI. As-is I think it is extending
< 4-byte arguments to 4-bytes but doesn't align them to 4-bytes.
llvm-svn: 335650
2018-06-27 03:10:00 +08:00
|
|
|
%one = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
%two = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
%three = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
%four = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
%five = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
%six = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
%seven = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
%eight = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
%nine = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
%ten = load volatile i32, i32 addrspace(4)* undef
|
2020-01-22 06:27:57 +08:00
|
|
|
%eleven = load volatile i32, i32 addrspace(4)* undef
|
|
|
|
call void asm sideeffect "", "s,s,s,s,s,s,s,s,s,s"(i32 %one, i32 %two, i32 %three, i32 %four, i32 %five, i32 %six, i32 %seven, i32 %eight, i32 %nine, i32 %ten)
|
AMDGPU: Add pass to lower kernel arguments to loads
This replaces most argument uses with loads, but for
now not all.
The code in SelectionDAG for calling convention lowering
is actively harmful for amdgpu_kernel. It attempts to
split the argument types into register legal types, which
results in low quality code for arbitary types. Since
all kernel arguments are passed in memory, we just want the
raw types.
I've tried a couple of methods of mitigating this in SelectionDAG,
but it's easier to just bypass this problem alltogether. It's
possible to hack around the problem in the initial lowering,
but the real problem is the DAG then expects to be able to use
CopyToReg/CopyFromReg for uses of the arguments outside the block.
Exposing the argument loads in the IR also has the advantage
that the LoadStoreVectorizer can merge them.
I'm not sure the best approach to dealing with the IR
argument list is. The patch as-is just leaves the IR arguments
in place, so all the existing code will still compute the same
kernarg size and pointlessly lowers the arguments.
Arguably the frontend should emit kernels with an empty argument
list in the first place. Alternatively a dummy array could be
inserted as a single argument just to reserve space.
This does have some disadvantages. Local pointer kernel arguments can
no longer have AssertZext placed on them as the equivalent !range
metadata is not valid on pointer typed loads. This is mostly bad
for SI which needs to know about the known bits in order to use the
DS instruction offset, so in this case this is not done.
More importantly, this skips noalias arguments since this pass
does not yet convert this to the equivalent !alias.scope and !noalias
metadata. Producing this metadata correctly seems to be tricky,
although this logically is the same as inlining into a function which
doesn't exist. Additionally, exposing these loads to the vectorizer
may result in degraded aliasing information if a pointer load is
merged with another argument load.
I'm also not entirely sure this is preserving the current clover
ABI, although I would greatly prefer if it would stop widening
arguments and match the HSA ABI. As-is I think it is extending
< 4-byte arguments to 4-bytes but doesn't align them to 4-bytes.
llvm-svn: 335650
2018-06-27 03:10:00 +08:00
|
|
|
store volatile i32 %one, i32 addrspace(1)* undef
|
|
|
|
store volatile i32 %two, i32 addrspace(1)* undef
|
|
|
|
store volatile i32 %three, i32 addrspace(1)* undef
|
|
|
|
store volatile i32 %four, i32 addrspace(1)* undef
|
|
|
|
store volatile i32 %five, i32 addrspace(1)* undef
|
|
|
|
store volatile i32 %six, i32 addrspace(1)* undef
|
|
|
|
store volatile i32 %seven, i32 addrspace(1)* undef
|
|
|
|
store volatile i32 %eight, i32 addrspace(1)* undef
|
|
|
|
store volatile i32 %nine, i32 addrspace(1)* undef
|
|
|
|
store volatile i32 %ten, i32 addrspace(1)* undef
|
2020-01-22 06:27:57 +08:00
|
|
|
store volatile i32 %eleven, i32 addrspace(1)* undef
|
2016-09-07 04:22:28 +08:00
|
|
|
ret void
|
|
|
|
}
|
2016-10-29 03:43:31 +08:00
|
|
|
|
|
|
|
; private resource: 4
|
|
|
|
; scratch wave offset: 1
|
|
|
|
; workgroup ids: 3
|
|
|
|
; dispatch id: 2
|
|
|
|
; queue ptr: 2
|
|
|
|
; flat scratch init: 2
|
|
|
|
; ---------------------
|
|
|
|
; total: 14
|
|
|
|
|
2016-12-10 03:49:48 +08:00
|
|
|
; + reserved vcc = 16
|
2016-10-29 03:43:31 +08:00
|
|
|
|
|
|
|
; Because we can't handle re-using the last few input registers as the
|
|
|
|
; special vcc etc. registers (as well as decide to not use the unused
|
|
|
|
; features when the number of registers is frozen), this ends up using
|
|
|
|
; more than expected.
|
|
|
|
|
2017-06-17 10:08:18 +08:00
|
|
|
; XALL-LABEL: {{^}}max_12_sgprs_14_input_sgprs:
|
|
|
|
; XTOSGPR: SGPRBlocks: 1
|
|
|
|
; XTOSGPR: NumSGPRsForWavesPerEU: 16
|
2016-10-29 03:43:31 +08:00
|
|
|
|
2017-06-17 10:08:18 +08:00
|
|
|
; This test case is disabled: When calculating the spillslot addresses AMDGPU
|
|
|
|
; creates an extra vreg to save/restore m0 which in a point of maximum register
|
|
|
|
; pressure would trigger an endless loop; the compiler aborts earlier with
|
|
|
|
; "Incomplete scavenging after 2nd pass" in practice.
|
|
|
|
;define amdgpu_kernel void @max_12_sgprs_14_input_sgprs(i32 addrspace(1)* %out1,
|
|
|
|
; i32 addrspace(1)* %out2,
|
|
|
|
; i32 addrspace(1)* %out3,
|
|
|
|
; i32 addrspace(1)* %out4,
|
|
|
|
; i32 %one, i32 %two, i32 %three, i32 %four) #2 {
|
|
|
|
; %x.0 = call i32 @llvm.amdgcn.workgroup.id.x()
|
|
|
|
; %x.1 = call i32 @llvm.amdgcn.workgroup.id.y()
|
|
|
|
; %x.2 = call i32 @llvm.amdgcn.workgroup.id.z()
|
|
|
|
; %x.3 = call i64 @llvm.amdgcn.dispatch.id()
|
2018-09-10 10:54:25 +08:00
|
|
|
; %x.4 = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
|
|
|
|
; %x.5 = call i8 addrspace(4)* @llvm.amdgcn.queue.ptr()
|
2017-06-17 10:08:18 +08:00
|
|
|
; store volatile i32 0, i32* undef
|
|
|
|
; br label %stores
|
|
|
|
;
|
|
|
|
;stores:
|
|
|
|
; store volatile i32 %x.0, i32 addrspace(1)* undef
|
|
|
|
; store volatile i32 %x.0, i32 addrspace(1)* undef
|
|
|
|
; store volatile i32 %x.0, i32 addrspace(1)* undef
|
|
|
|
; store volatile i64 %x.3, i64 addrspace(1)* undef
|
2018-09-10 10:54:25 +08:00
|
|
|
; store volatile i8 addrspace(4)* %x.4, i8 addrspace(4)* addrspace(1)* undef
|
|
|
|
; store volatile i8 addrspace(4)* %x.5, i8 addrspace(4)* addrspace(1)* undef
|
2017-06-17 10:08:18 +08:00
|
|
|
;
|
|
|
|
; store i32 %one, i32 addrspace(1)* %out1
|
|
|
|
; store i32 %two, i32 addrspace(1)* %out2
|
|
|
|
; store i32 %three, i32 addrspace(1)* %out3
|
|
|
|
; store i32 %four, i32 addrspace(1)* %out4
|
|
|
|
; ret void
|
|
|
|
;}
|
2016-10-29 03:43:31 +08:00
|
|
|
|
2016-12-02 06:39:51 +08:00
|
|
|
; The following test is commented out for now; http://llvm.org/PR31230
|
|
|
|
; XALL-LABEL: max_12_sgprs_12_input_sgprs{{$}}
|
2016-10-29 03:43:31 +08:00
|
|
|
; ; Make sure copies for input buffer are not clobbered. This requires
|
|
|
|
; ; swapping the order the registers are copied from what normally
|
|
|
|
; ; happens.
|
|
|
|
|
2016-12-02 06:39:51 +08:00
|
|
|
; XALL: SGPRBlocks: 2
|
|
|
|
; XALL: NumSGPRsForWavesPerEU: 18
|
2017-03-22 05:39:51 +08:00
|
|
|
;define amdgpu_kernel void @max_12_sgprs_12_input_sgprs(i32 addrspace(1)* %out1,
|
2016-12-02 06:39:51 +08:00
|
|
|
; i32 addrspace(1)* %out2,
|
|
|
|
; i32 addrspace(1)* %out3,
|
|
|
|
; i32 addrspace(1)* %out4,
|
|
|
|
; i32 %one, i32 %two, i32 %three, i32 %four) #2 {
|
|
|
|
; store volatile i32 0, i32* undef
|
|
|
|
; %x.0 = call i32 @llvm.amdgcn.workgroup.id.x()
|
|
|
|
; store volatile i32 %x.0, i32 addrspace(1)* undef
|
|
|
|
; %x.1 = call i32 @llvm.amdgcn.workgroup.id.y()
|
|
|
|
; store volatile i32 %x.0, i32 addrspace(1)* undef
|
|
|
|
; %x.2 = call i32 @llvm.amdgcn.workgroup.id.z()
|
|
|
|
; store volatile i32 %x.0, i32 addrspace(1)* undef
|
|
|
|
; %x.3 = call i64 @llvm.amdgcn.dispatch.id()
|
|
|
|
; store volatile i64 %x.3, i64 addrspace(1)* undef
|
2018-09-10 10:54:25 +08:00
|
|
|
; %x.4 = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
|
|
|
|
; store volatile i8 addrspace(4)* %x.4, i8 addrspace(4)* addrspace(1)* undef
|
2016-12-02 06:39:51 +08:00
|
|
|
;
|
|
|
|
; store i32 %one, i32 addrspace(1)* %out1
|
|
|
|
; store i32 %two, i32 addrspace(1)* %out2
|
|
|
|
; store i32 %three, i32 addrspace(1)* %out3
|
|
|
|
; store i32 %four, i32 addrspace(1)* %out4
|
|
|
|
; ret void
|
|
|
|
;}
|
2016-10-29 03:43:31 +08:00
|
|
|
|
|
|
|
declare i32 @llvm.amdgcn.workgroup.id.x() #1
|
|
|
|
declare i32 @llvm.amdgcn.workgroup.id.y() #1
|
|
|
|
declare i32 @llvm.amdgcn.workgroup.id.z() #1
|
|
|
|
declare i64 @llvm.amdgcn.dispatch.id() #1
|
2018-09-10 10:54:25 +08:00
|
|
|
declare i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr() #1
|
|
|
|
declare i8 addrspace(4)* @llvm.amdgcn.queue.ptr() #1
|
2016-10-29 03:43:31 +08:00
|
|
|
|
|
|
|
attributes #0 = { nounwind "amdgpu-num-sgpr"="14" }
|
|
|
|
attributes #1 = { nounwind readnone }
|
|
|
|
attributes #2 = { nounwind "amdgpu-num-sgpr"="12" }
|
|
|
|
attributes #3 = { nounwind "amdgpu-num-sgpr"="11" }
|