diff options
| author | hsmahesha <mahesha.comp@gmail.com> | 2021-06-08 03:58:13 +0530 |
|---|---|---|
| committer | hsmahesha <mahesha.comp@gmail.com> | 2021-06-08 03:58:13 +0530 |
| commit | 713ca2f3604fdaf0edd5a4e2869c5685e7ec4216 (patch) | |
| tree | a966f24ad8189f777a2cbab3b52f462b7fd64f09 /llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp | |
| parent | 3af5f3e69247fb3ead05eefa99832c1c029e1997 (diff) | |
[AMDGPU] Introduce command line switch to control super aligning of LDS.
Reviewed By: rampitec
Differential Revision: https://reviews.llvm.org/D103817
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp index 8e3895ee1416..8e3ce775b581 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp @@ -37,6 +37,7 @@ #include "llvm/IR/Instructions.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Transforms/Utils/ModuleUtils.h" #include <algorithm> @@ -46,6 +47,11 @@ using namespace llvm; +static cl::opt<bool> SuperAlignLDSGlobals( + "amdgpu-super-align-lds-globals", + cl::desc("Increase alignment of LDS if it is not on align boundary"), + cl::init(true), cl::Hidden); + namespace { class AMDGPULowerModuleLDS : public ModulePass { @@ -174,31 +180,27 @@ private: // Increase the alignment of LDS globals if necessary to maximise the chance // that we can use aligned LDS instructions to access them. - for (auto *GV : FoundLocalVars) { - unsigned AlignValue = GV->getAlignment(); - if (AlignValue == 0) { - GV->setAlignment(DL.getABITypeAlign(GV->getValueType())); - continue; - } + if (SuperAlignLDSGlobals) { + for (auto *GV : FoundLocalVars) { + Align Alignment = AMDGPU::getAlign(DL, GV); + TypeSize GVSize = DL.getTypeAllocSize(GV->getValueType()); + + if (GVSize > 8) { + // We might want to use a b96 or b128 load/store + Alignment = std::max(Alignment, Align(16)); + } else if (GVSize > 4) { + // We might want to use a b64 load/store + Alignment = std::max(Alignment, Align(8)); + } else if (GVSize > 2) { + // We might want to use a b32 load/store + Alignment = std::max(Alignment, Align(4)); + } else if (GVSize > 1) { + // We might want to use a b16 load/store + Alignment = std::max(Alignment, Align(2)); + } - Align Alignment(AlignValue); - TypeSize GVSize = DL.getTypeAllocSize(GV->getValueType()); - - if (GVSize > 8) { - // We might want to use a b96 or b128 load/store - Alignment = std::max(Alignment, Align(16)); - } else if (GVSize > 4) { - // We might want to use a b64 load/store - Alignment = std::max(Alignment, Align(8)); - } else if (GVSize > 2) { - // We might want to use a b32 load/store - Alignment = std::max(Alignment, Align(4)); - } else if (GVSize > 1) { - // We might want to use a b16 load/store - Alignment = std::max(Alignment, Align(2)); + GV->setAlignment(Alignment); } - - GV->setAlignment(Alignment); } // Sort by alignment, descending, to minimise padding. |
