diff options
| author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-07-26 20:39:42 +0000 |
|---|---|---|
| committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-07-26 20:39:42 +0000 |
| commit | 894e53d6ac00a54adecb2b3b1d3a68ef88929c88 (patch) | |
| tree | fba6a5e78e55544d9aeef7b918dcc26016d802a7 /llvm/lib/Target | |
| parent | ca7e6f6ea843800c03965950b66ef1da4c1aee7f (diff) | |
| download | bcm5719-llvm-894e53d6ac00a54adecb2b3b1d3a68ef88929c88.tar.gz bcm5719-llvm-894e53d6ac00a54adecb2b3b1d3a68ef88929c88.zip | |
AMDGPU: Fix using SMRD instructions for argument loads in functions
These are not actually uniform values except in kernels.
llvm-svn: 309172
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp | 30 | ||||
| -rw-r--r-- | llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h | 2 |
2 files changed, 31 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp index 67ad904ca97..f6d5853b2ba 100644 --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp @@ -730,16 +730,44 @@ bool isInlinableLiteralV216(int32_t Literal, bool HasInv2Pi) { return Lo16 == Hi16 && isInlinableLiteral16(Lo16, HasInv2Pi); } +bool isArgPassedInSGPR(const Argument *A) { + const Function *F = A->getParent(); + + // Arguments to compute shaders are never a source of divergence. + CallingConv::ID CC = F->getCallingConv(); + switch (CC) { + case CallingConv::AMDGPU_KERNEL: + case CallingConv::SPIR_KERNEL: + return true; + case CallingConv::AMDGPU_VS: + case CallingConv::AMDGPU_HS: + case CallingConv::AMDGPU_GS: + case CallingConv::AMDGPU_PS: + case CallingConv::AMDGPU_CS: + // For non-compute shaders, SGPR inputs are marked with either inreg or byval. + // Everything else is in VGPRs. + return F->getAttributes().hasParamAttribute(A->getArgNo(), Attribute::InReg) || + F->getAttributes().hasParamAttribute(A->getArgNo(), Attribute::ByVal); + default: + // TODO: Should calls support inreg for SGPR inputs? + return false; + } +} + +// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence. bool isUniformMMO(const MachineMemOperand *MMO) { const Value *Ptr = MMO->getValue(); // UndefValue means this is a load of a kernel input. These are uniform. // Sometimes LDS instructions have constant pointers. // If Ptr is null, then that means this mem operand contains a // PseudoSourceValue like GOT. - if (!Ptr || isa<UndefValue>(Ptr) || isa<Argument>(Ptr) || + if (!Ptr || isa<UndefValue>(Ptr) || isa<Constant>(Ptr) || isa<GlobalValue>(Ptr)) return true; + if (const Argument *Arg = dyn_cast<Argument>(Ptr)) + return isArgPassedInSGPR(Arg); + const Instruction *I = dyn_cast<Instruction>(Ptr); return I && I->getMetadata("amdgpu.uniform"); } diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h index 936e4921a70..ea9dcdf8f3c 100644 --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h @@ -23,6 +23,7 @@ namespace llvm { +class Argument; class FeatureBitset; class Function; class GlobalValue; @@ -347,6 +348,7 @@ bool isInlinableLiteral16(int16_t Literal, bool HasInv2Pi); LLVM_READNONE bool isInlinableLiteralV216(int32_t Literal, bool HasInv2Pi); +bool isArgPassedInSGPR(const Argument *Arg); bool isUniformMMO(const MachineMemOperand *MMO); /// \returns The encoding that will be used for \p ByteOffset in the SMRD |

