================
@@ -478,4 +480,67 @@ bool isClobberedInFunction(const LoadInst *Load, MemorySSA 
*MSSA,
   return false;
 }
 
+SIAtomicAddrSpace toSIAtomicAddrSpace(unsigned AS) {
+  if (AS == AMDGPUAS::FLAT_ADDRESS)
+    return SIAtomicAddrSpace::FLAT;
+  if (AS == AMDGPUAS::GLOBAL_ADDRESS)
+    return SIAtomicAddrSpace::GLOBAL;
+  if (AS == AMDGPUAS::LOCAL_ADDRESS)
+    return SIAtomicAddrSpace::LDS;
+  if (AS == AMDGPUAS::PRIVATE_ADDRESS)
+    return SIAtomicAddrSpace::SCRATCH;
+  if (AS == AMDGPUAS::REGION_ADDRESS)
+    return SIAtomicAddrSpace::GDS;
+  if (AS == AMDGPUAS::BUFFER_FAT_POINTER || AS == AMDGPUAS::BUFFER_RESOURCE ||
+      AS == AMDGPUAS::BUFFER_STRIDED_POINTER)
+    return SIAtomicAddrSpace::GLOBAL;
+
+  // Constant addrspaces map to OTHER because there is no point in atomic
----------------
ritter-x2a wrote:

> > Arguably, these waits are unnecessary since the accessed memory is not 
> > supposed to change (which means there is not much sense in doing a volatile 
> > load in the first place).
> 
> Not sure how we model `volatile` for AMDGPU, but in general, a `volatile` 
> load can have unknown side-effects even if it appears to return the same 
> constant value loaded from the same constant location.

Fair, on the language side it might make some sense to write a volatile load 
from the constant addrspace. Then, the question is if, when we lower a volatile 
load from the constant addrspace to a `global_load_...`, are we certain enough 
that no such side-effects happen, or do we actually want to wait for completion 
after each `global_load_...` that implements a volatile load, even if it's from 
constant memory?

https://github.com/llvm/llvm-project/pull/231854
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to