[PATCH] D127041: [LLVM] Add the support for fmax and fmin in atomicrmw instruction

Shilei Tian via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 21:14:55 PDT 2022


tianshilei1992 marked an inline comment as done.
tianshilei1992 added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp:67-69
+    case AtomicRMWInst::FMax:
+    case AtomicRMWInst::FMin:
       return CF->isNaN();
----------------
arsenm wrote:
> This is just wrong.
> 
> I think this is questionable for the fadd/fsub case since I guess it depends if the payload bits are preserved?
I fixed the cases for `fmax` and `fmin`. That's the only case off the top of my head.

As for `fadd`/`fsub`, I think it will be fine because the operation will be changed to `Xchg`, and the result will be `CF`, which conforms with the standard that:
> An operation that propagates a NaN operand to its result and has a single NaN as an input should produce a NaN with the payload of the input NaN if representable in the destination format.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127041/new/

https://reviews.llvm.org/D127041



More information about the llvm-commits mailing list