[flang-commits] [flang] [llvm] [mlir] [Flang] [OpenMP] atomic compare (PR #184761)
via flang-commits
flang-commits at lists.llvm.org
Tue May 12 22:12:32 PDT 2026
SunilKuravinakop wrote:
> Codex had a couple of criticisms I missed
>
> Plus
>
> ```
> [P2] Retry zero-sign races before declaring compare failure
>
> For floating-point atomic compare, the new zero handling does a cmpxchg using the bit pattern from a prior load
> when both X and E compare equal to zero. If another thread changes the stored value between +0.0 and -0.0 after
> that load but before the cmpxchg, the cmpxchg fails even though OpenMP comparison semantics still say +0.0 ==
> -0.0.
>
> For non-weak atomic compare, that failure should be retried instead of treating the compare as failed, otherwise
> a required update can be dropped.
> ```
>
> This is hard to write a reproducer for to verify but it looks correct to me.
This is going in the direction of CAS loop, away from the test-and-set instructions like cmpxchg (an atomic instruction). CAS loop is not an atomic instruction. If you want to have this then we can make this another issue and avoid it here.
https://github.com/llvm/llvm-project/pull/184761
More information about the flang-commits
mailing list