[llvm] [DirectX] Cast the pointer for atomics whose value type differs (PR #226563)
Joshua Batista via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 16:52:59 PDT 2026
================
@@ -1,17 +1,32 @@
; RUN: llc --filetype=obj %s --stop-after=dxil-write-bitcode -o %t.bc
; RUN: dxil-dis %t.bc -o - | FileCheck %s
-; Verify that the DXIL reader supports the atomicrmw record.
+; Verify that the DXIL reader supports the atomicrmw and the cmpxchg records.
+; A float allocation needs a pointer cast, because the atomic value is an
+; integer and a DXIL pointer carries the element type.
target triple = "dxil-pc-shadermodel6.0-compute"
@gsm = internal addrspace(3) global i32 zeroinitializer, align 4
+ at gsm_float = internal addrspace(3) global float zeroinitializer, align 4
+ at gsm_float_arr = internal addrspace(3) global [4 x float] zeroinitializer, align 4
; CHECK-LABEL: define void @main()
-; CHECK: atomicrmw add i32 addrspace(3)* @gsm, i32 1 monotonic
+; An integer allocation already agrees with the value, so it gets no cast.
----------------
bob80905 wrote:
Yes, the atomic pointer must have type `i32*`. The GEP from the integer array already produces that type, so no additional bitcast is needed. I added a test for this case.
https://github.com/llvm/llvm-project/pull/226563
More information about the llvm-commits
mailing list