AMDGPU: Fix DAG divergence not reporting flat loads

Match behavior in DAG of r340343

llvm-svn: 341393
This commit is contained in:
Matt Arsenault 2018-09-04 18:58:19 +00:00
parent a6f32f4015
commit 813613c494
2 changed files with 34 additions and 4 deletions

View File

@ -9206,10 +9206,10 @@ bool SITargetLowering::isSDNodeSourceOfDivergence(const SDNode * N,
} }
break; break;
case ISD::LOAD: { case ISD::LOAD: {
const LoadSDNode *L = dyn_cast<LoadSDNode>(N); const LoadSDNode *L = cast<LoadSDNode>(N);
// FIXME: Also needs to handle flat. unsigned AS = L->getAddressSpace();
if (L->getMemOperand()->getAddrSpace() == AMDGPUAS::PRIVATE_ADDRESS) // A flat load may access private memory.
return true; return AS == AMDGPUAS::PRIVATE_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS;
} break; } break;
case ISD::CALLSEQ_END: case ISD::CALLSEQ_END:
return true; return true;

View File

@ -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_dword s
; GCN: flat_load_dword
; GCN-NOT: s_load_dword 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
}