[PATCH] D134354: [AMDGPU][GlobalISel] Support mad/fma_mix selection

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 27 03:52:11 PDT 2022


Pierre-vh added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/Utils.cpp:665-667
+    return isKnownNeverNaN(DefMI->getOperand(1).getReg(), MRI, SNaN) &&
+           isKnownNeverNaN(DefMI->getOperand(2).getReg(), MRI, SNaN) &&
+           isKnownNeverNaN(DefMI->getOperand(3).getReg(), MRI, SNaN);
----------------
foad wrote:
> This isn't true. You can get a NaN result even if none of the inputs are NaNs, e.g. from +inf + -inf.
I just copied the SDag implementation so that one would be wrong too then
```
  case ISD::FMA:
  case ISD::FMAD: {
    if (SNaN)
      return true;
    return isKnownNeverNaN(Op.getOperand(0), SNaN, Depth + 1) &&
           isKnownNeverNaN(Op.getOperand(1), SNaN, Depth + 1) &&
           isKnownNeverNaN(Op.getOperand(2), SNaN, Depth + 1);
  }
```

What is the alternative? Can this function not handle FMA/FMAD at all then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134354



More information about the llvm-commits mailing list