[PATCH] D141852: [amdgpu] Change LDS lowering default to hybrid
Jon Chesterfield via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 24 07:27:54 PST 2023
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbf579a7049a6: [amdgpu] Change LDS lowering default to hybrid (authored by JonChesterfield).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141852/new/
https://reviews.llvm.org/D141852
Files:
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
llvm/test/CodeGen/AMDGPU/lower-module-lds-via-hybrid.ll
Index: llvm/test/CodeGen/AMDGPU/lower-module-lds-via-hybrid.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/lower-module-lds-via-hybrid.ll
+++ llvm/test/CodeGen/AMDGPU/lower-module-lds-via-hybrid.ll
@@ -30,13 +30,12 @@
; GCN-LABEL: f0:
; GCN: ; %bb.0:
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GCN-NEXT: s_mov_b64 s[0:1], s[6:7]
-; GCN-NEXT: s_trap 2
+; GCN-NEXT: v_mov_b32_e32 v0, 0
; GCN-NEXT: s_mov_b32 m0, -1
-; GCN-NEXT: ds_read_b32 v0, v0
+; GCN-NEXT: ds_read_b32 v1, v0 offset:4
; GCN-NEXT: s_waitcnt lgkmcnt(0)
-; GCN-NEXT: v_add_f32_e32 v0, v0, v0
-; GCN-NEXT: ds_write_b32 v0, v0
+; GCN-NEXT: v_add_f32_e32 v1, v1, v1
+; GCN-NEXT: ds_write_b32 v0, v1 offset:4
; GCN-NEXT: s_waitcnt lgkmcnt(0)
; GCN-NEXT: s_setpc_b64 s[30:31]
%ld = load float, ptr addrspace(3) @v0
@@ -120,13 +119,12 @@
; GCN-LABEL: f3:
; GCN: ; %bb.0:
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GCN-NEXT: s_mov_b64 s[0:1], s[6:7]
-; GCN-NEXT: s_trap 2
+; GCN-NEXT: v_mov_b32_e32 v0, 0
; GCN-NEXT: s_mov_b32 m0, -1
-; GCN-NEXT: ds_read_u8 v0, v0
+; GCN-NEXT: ds_read_u8 v1, v0 offset:8
; GCN-NEXT: s_waitcnt lgkmcnt(0)
-; GCN-NEXT: v_mul_lo_u32 v0, v0, 5
-; GCN-NEXT: ds_write_b8 v0, v0
+; GCN-NEXT: v_mul_lo_u32 v1, v1, 5
+; GCN-NEXT: ds_write_b8 v0, v1 offset:8
; GCN-NEXT: s_waitcnt lgkmcnt(0)
; GCN-NEXT: s_setpc_b64 s[30:31]
%ld = load i8, ptr addrspace(3) @v3
Index: llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -162,7 +162,7 @@
cl::opt<LoweringKind> LoweringKindLoc(
"amdgpu-lower-module-lds-strategy",
cl::desc("Specify lowering strategy for function LDS access:"), cl::Hidden,
- cl::init(LoweringKind::module),
+ cl::init(LoweringKind::hybrid),
cl::values(
clEnumValN(LoweringKind::table, "table", "Lower via table lookup"),
clEnumValN(LoweringKind::module, "module", "Lower via module struct"),
Index: llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
@@ -1329,6 +1329,18 @@
GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(Op);
const GlobalValue *GV = G->getGlobal();
+ if (G->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) {
+ if (!MFI->isModuleEntryFunction()) {
+ if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV)) {
+ if (AMDGPUMachineFunction::isKnownAddressLDSGlobal(*GVar)) {
+ unsigned Offset =
+ AMDGPUMachineFunction::calculateKnownAddressOfLDSGlobal(*GVar);
+ return DAG.getConstant(Offset, SDLoc(Op), Op.getValueType());
+ }
+ }
+ }
+ }
+
if (G->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS ||
G->getAddressSpace() == AMDGPUAS::REGION_ADDRESS) {
if (!MFI->isModuleEntryFunction() &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141852.500200.patch
Type: text/x-patch
Size: 3169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230224/bec6f386/attachment.bin>
More information about the llvm-commits
mailing list