[PATCH] D33186: [InstCombine] Canonicalize clamp of float types to minmax in fast mode.

Andrei Elovikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 04:52:23 PDT 2017


a.elovikov added a comment.

In https://reviews.llvm.org/D33186#754812, @jmolloy wrote:

> Hi,
>
> > On the other hand, some backends (e.g. X86) have only
>
> FMIN/FMAX nodes that do not care about NaNS and the former NAN/NUM
>  nodes are illegal thus selection is not happening.
>
> For my own reference so I can more effectively review this, could you please explain this a bit more? What is the defined behaviour for such instructions when given a NaN?


I was referring to the following comment from the X86ISelLowering.cpp:

  // There are 4 possibilities involving NaN inputs, and these are the required
  // outputs:
  //                   Op1
  //               Num     NaN
  //            ----------------
  //       Num  |  Max  |  Op0 |
  // Op0        ----------------
  //       NaN  |  Op1  |  NaN |
  //            ----------------
  //
  // The SSE FP max/min instructions were not designed for this case, but rather
  // to implement:
  //   Min = Op1 < Op0 ? Op1 : Op0
  //   Max = Op1 > Op0 ? Op1 : Op0
  //
  // So they always return Op0 if either input is a NaN. However, we can still
  // use those instructions for fmaxnum by selecting away a NaN input.


https://reviews.llvm.org/D33186





More information about the llvm-commits mailing list