[PATCH] D50991: [AMDGPU] Consider loads from flat addrspace to be potentially divergent

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 21 14:25:20 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL340343: [AMDGPU] Consider loads from flat addrspace to be potentially divergent (authored by scott.linder, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50991?vs=161723&id=161823#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50991

Files:
  llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/trunk/test/Analysis/DivergenceAnalysis/AMDGPU/loads.ll


Index: llvm/trunk/test/Analysis/DivergenceAnalysis/AMDGPU/loads.ll
===================================================================
--- llvm/trunk/test/Analysis/DivergenceAnalysis/AMDGPU/loads.ll
+++ llvm/trunk/test/Analysis/DivergenceAnalysis/AMDGPU/loads.ll
@@ -0,0 +1,15 @@
+; RUN: opt -mtriple=amdgcn-- -analyze -divergence %s | FileCheck %s
+
+; Test that we consider loads from flat and private addrspaces to be divergent.
+
+; CHECK: DIVERGENT: %val = load i32, i32* %flat, align 4
+define amdgpu_kernel void @flat_load(i32* %flat) {
+  %val = load i32, i32* %flat, align 4
+  ret void
+}
+
+; CHECK: DIVERGENT: %val = load i32, i32 addrspace(5)* %priv, align 4
+define amdgpu_kernel void @private_load(i32 addrspace(5)* %priv) {
+  %val = load i32, i32 addrspace(5)* %priv, align 4
+  ret void
+}
Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -545,14 +545,16 @@
   if (const Argument *A = dyn_cast<Argument>(V))
     return !isArgPassedInSGPR(A);
 
-  // Loads from the private address space are divergent, because threads
-  // can execute the load instruction with the same inputs and get different
-  // results.
+  // Loads from the private and flat address spaces are divergent, because
+  // threads can execute the load instruction with the same inputs and get
+  // different results.
   //
   // All other loads are not divergent, because if threads issue loads with the
   // same arguments, they will always get the same result.
   if (const LoadInst *Load = dyn_cast<LoadInst>(V))
-    return Load->getPointerAddressSpace() == ST->getAMDGPUAS().PRIVATE_ADDRESS;
+    return Load->getPointerAddressSpace() ==
+               ST->getAMDGPUAS().PRIVATE_ADDRESS ||
+           Load->getPointerAddressSpace() == ST->getAMDGPUAS().FLAT_ADDRESS;
 
   // Atomics are divergent because they are executed sequentially: when an
   // atomic operation refers to the same address in each thread, then each


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50991.161823.patch
Type: text/x-patch
Size: 2133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180821/41e0b7cb/attachment.bin>


More information about the llvm-commits mailing list