[flang-commits] [flang] [flang][cuda] Relax assertion for atomicexch (PR #128582)
via flang-commits
flang-commits at lists.llvm.org
Mon Feb 24 13:34:22 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
atomicexch interfaces accepts also floating point numbers. Relax the assertion so float are also accepted.
---
Full diff: https://github.com/llvm/llvm-project/pull/128582.diff
2 Files Affected:
- (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+1-1)
- (modified) flang/test/Lower/CUDA/cuda-device-proc.cuf (+3)
``````````diff
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 3d98fa44ab7fc..2c94a70e46b3b 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -2752,7 +2752,7 @@ mlir::Value IntrinsicLibrary::genAtomicDec(mlir::Type resultType,
mlir::Value IntrinsicLibrary::genAtomicExch(mlir::Type resultType,
llvm::ArrayRef<mlir::Value> args) {
assert(args.size() == 2);
- assert(mlir::isa<mlir::IntegerType>(args[1].getType()));
+ assert(args[1].getType().isIntOrFloat());
mlir::LLVM::AtomicBinOp binOp = mlir::LLVM::AtomicBinOp::xchg;
return genAtomBinOp(builder, loc, binOp, args[0], args[1]);
diff --git a/flang/test/Lower/CUDA/cuda-device-proc.cuf b/flang/test/Lower/CUDA/cuda-device-proc.cuf
index fcfcc2e537039..94cc1526e5203 100644
--- a/flang/test/Lower/CUDA/cuda-device-proc.cuf
+++ b/flang/test/Lower/CUDA/cuda-device-proc.cuf
@@ -152,13 +152,16 @@ end subroutine
attributes(device) subroutine testAtomic()
integer :: a, istat, j
+ real :: r
istat = atomicexch(a,0)
+ istat = atomicexch(r, 0.0)
istat = atomicxor(a, j)
istat = atomiccas(a, i, 14)
end subroutine
! CHECK-LABEL: func.func @_QPtestatomic()
! CHECK: llvm.atomicrmw xchg %{{.*}}, %c0{{.*}} seq_cst : !llvm.ptr, i32
+! CHECK: llvm.atomicrmw xchg %{{.*}}, %{{.*}} seq_cst : !llvm.ptr, f32
! CHECK: llvm.atomicrmw _xor %{{.*}}, %{{.*}} seq_cst : !llvm.ptr, i32
! CHECK: %[[ADDR:.*]] = builtin.unrealized_conversion_cast %{{.*}}#1 : !fir.ref<i32> to !llvm.ptr
! CHECK: llvm.cmpxchg %[[ADDR]], %{{.*}}, %c14{{.*}} acq_rel monotonic : !llvm.ptr, i32
``````````
</details>
https://github.com/llvm/llvm-project/pull/128582
More information about the flang-commits
mailing list