[llvm] AtomicExpand: Fix creating invalid ptrmask for fat pointers (PR #94955)

Krzysztof Drewniak via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 07:48:48 PDT 2024


================
@@ -1262,6 +1262,110 @@ define bfloat @test_atomicrmw_xchg_bf16_global_agent_align4(ptr addrspace(1) %pt
   ret bfloat %res
 }
 
+define i16 @test_atomicrmw_xchg_i16_buffer_fat_agent(ptr addrspace(7) %ptr, i16 %value) {
+; CHECK-LABEL: @test_atomicrmw_xchg_i16_buffer_fat_agent(
+; CHECK-NEXT:    [[ALIGNEDADDR:%.*]] = call ptr addrspace(7) @llvm.ptrmask.p7.i32(ptr addrspace(7) [[PTR:%.*]], i32 -4)
----------------
krzysz00 wrote:

This doesn't actually guarantee an aligned pointer, since a `ptr addrspace(7)` is a `concat(i128 rsrc, i32 offset)`, or, more relevantly, an  `concat(i32 flags, i32 extent, i16 flags, i48/ptr base_address, i32 offset)`.

The address an atomic operates on is `add(base_address, zext(offset))` for these pointers, so if `base_address` is unaligned, clearing the low bits of  the offset won't do anything.

I'm not sure what, if anything, we'd want to do about this.

https://github.com/llvm/llvm-project/pull/94955


More information about the llvm-commits mailing list