[flang-commits] [flang] [llvm] [NVPTX] Set default value of nvptx-allow-ftz-atomics to false (PR #231429)

Christian Sigg via flang-commits flang-commits at lists.llvm.org
Fri Oct 16 05:48:37 PDT 2026


chsigg wrote:

Thank you for looking into the other frontends and passes!

`AutoUpgrade.cpp` and Flang CUDA Fortran were both oversights on my part:
- **`AutoUpgrade.cpp`**: `@llvm.nvvm.atomic.load.add.f32.*` and `@llvm.nvvm.atomic.add.gen.f.*` specifically targeted PTX `atom.add`. Attaching `!atomic.ignore.denormal.mode` during upgrade keeps them lowering to `atom.add` and also removes the `atomics.ll` diff from this PR. I put up <AutoUpgrade PR> for this.
- **Flang CUDA Fortran**: `CUDAIntrinsicCall.cpp:genAtomicAdd` lowers CUDA Fortran `atomicadd`, which has the same semantics as CUDA C++ `atomicAdd()` (#217587). I put up <Flang PR> to set `ignore_denormal_mode` on `LLVM::AtomicRMWOp` there.

For the other cases from your scan, I think not setting the metadata is what we want:
- **General-purpose frontends (C/C++ `<atomic>`, Rust, Julia, standard Fortran) and target-independent MLIR lowerings (`MemRefToLLVM`, `OpenACC`, `SCFToOpenMP`)**: If a kernel is compiled with `-fcuda-flush-denormals-to-zero` (`-mdenormal-fp-math-f32=preserve-sign`), its denormal mode already matches PTX `atom.add.f32` and NVPTX still emits the native instruction without metadata. In default IEEE mode, preserving denormals via the CAS loop seems safer unless the user/frontend explicitly opts out.
- **Clang OpenMP GPU reductions**: `setTargetAtomicMetadata` is only called for C/C++ `<atomic>` (`CGAtomic.cpp`), and OpenMP reductions don't set `!atomic.ignore.denormal.mode` on AMDGPU either.

Downstream compilers that emit `atomicrmw fadd` in IEEE mode and want fast FP atomics do need to attach the attribute (similar to AMDGPU and SPIR-V). We already updated XLA to set `ignore_denormal_mode` on `llvm.atomicrmw fadd` for both CUDA and ROCm, and other downstream users will likely need a similar change.

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


More information about the flang-commits mailing list