[PATCH] D53794: [TargetLowering] expandFP_TO_UINT - avoid FPE due to out of range conversion (PR17686)

Ulrich Weigand via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 29 07:42:43 PDT 2018


uweigand added a subscriber: kpn.
uweigand added a comment.

So I had thought that normal LLVM floating-point IR operations are defined to assume that FP exceptions are disabled, and therefore transformations do not need to preserve the FP exception status.

If you rely on FP exceptions, you should instead use the new family of "strict" floating-point intrinsics.

In particular, this very issue came up in the context of correctly lowering the STRICT_FP_TO_UINT operation, where @kpn suggested to lower this directly to an if-then-else sequence at the IR level, before even getting to the DAG.  This hasn't gone in the tree yet, but the discussion is ongoing here: https://reviews.llvm.org/D43515

The proposed new pass is here: https://reviews.llvm.org/D43515?id=144714#change-iPGnktlSiYV3

Now, the solution suggested in **this** patch is also interesting since it can be done without introducing new basic blocks (and therefore can be done in SelectionDAG, without needed a new pass).  However, in order to generate efficient code we probably still need to get to the same assembler code we'd have gotten from that new pass -- but now instead the burden is on the back-end to recover the if-then-else block from a series of select statements.  Not sure what is better here.

In any case, the current code I see e.g. in the SystemZ tests is definitely worse than what we have today.


Repository:
  rL LLVM

https://reviews.llvm.org/D53794





More information about the llvm-commits mailing list