[PATCH] D51592: AMDGPU: Fix DAG divergence not reporting flat loads
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 3 06:03:45 PDT 2018
arsenm created this revision.
arsenm added a reviewer: scott.linder.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl.
Match behavior in DAG of r340343
https://reviews.llvm.org/D51592
Files:
lib/Target/AMDGPU/SIISelLowering.cpp
test/CodeGen/AMDGPU/dag-divergence.ll
Index: test/CodeGen/AMDGPU/dag-divergence.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AMDGPU/dag-divergence.ll
@@ -0,0 +1,30 @@
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
+
+; GCN-LABEL: {{^}}private_load_maybe_divergent:
+; GCN: buffer_load_dword
+; GCN-NOT: s_load s
+; GCN: flat_load_dword
+; GCN-NOT: s_load s
+define amdgpu_kernel void @private_load_maybe_divergent(i32 addrspace(4)* %k, i32* %flat) {
+ %load = load volatile i32, i32 addrspace(5)* undef, align 4
+ %gep = getelementptr inbounds i32, i32 addrspace(4)* %k, i32 %load
+ %maybe.not.uniform.load = load i32, i32 addrspace(4)* %gep, align 4
+ store i32 %maybe.not.uniform.load, i32 addrspace(1)* undef
+ ret void
+}
+
+; GCN-LABEL: {{^}}flat_load_maybe_divergent:
+; GCN: s_load_dwordx4
+; GCN-NOT: s_load
+; GCN: flat_load_dword
+; GCN-NOT: s_load
+; GCN: flat_load_dword
+; GCN-NOT: s_load
+; GCN: flat_store_dword
+define amdgpu_kernel void @flat_load_maybe_divergent(i32 addrspace(4)* %k, i32* %flat) {
+ %load = load i32, i32* %flat, align 4
+ %gep = getelementptr inbounds i32, i32 addrspace(4)* %k, i32 %load
+ %maybe.not.uniform.load = load i32, i32 addrspace(4)* %gep, align 4
+ store i32 %maybe.not.uniform.load, i32 addrspace(1)* undef
+ ret void
+}
Index: lib/Target/AMDGPU/SIISelLowering.cpp
===================================================================
--- lib/Target/AMDGPU/SIISelLowering.cpp
+++ lib/Target/AMDGPU/SIISelLowering.cpp
@@ -9270,10 +9270,10 @@
}
break;
case ISD::LOAD: {
- const LoadSDNode *L = dyn_cast<LoadSDNode>(N);
- // FIXME: Also needs to handle flat.
- if (L->getMemOperand()->getAddrSpace() == AMDGPUAS::PRIVATE_ADDRESS)
- return true;
+ const LoadSDNode *L = cast<LoadSDNode>(N);
+ unsigned AS = L->getAddressSpace();
+ // A flat load may access private memory.
+ return AS == AMDGPUAS::PRIVATE_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS;
} break;
case ISD::CALLSEQ_END:
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51592.163703.patch
Type: text/x-patch
Size: 2100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180903/7ddba6ec/attachment.bin>
More information about the llvm-commits
mailing list