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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 14 14:07:58 PST 2018


efriedma added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/TargetLowering.cpp:4160
   (void)apf.convertFromAPInt(x, false, APFloat::rmNearestTiesToEven);
+  SDValue Cst = DAG.getConstantFP(apf, dl, SrcVT);
+  SDValue Sel = DAG.getSetCC(dl, SetCCVT, Src, Cst, ISD::SETLT);
----------------
Do we need to check that Cst is finite?  For example, 0x80000000 doesn't fit into a half-precision float.  I guess it doesn't matter for x86, but it might matter in the future.


================
Comment at: lib/CodeGen/SelectionDAG/TargetLowering.cpp:4167
+    // Sel = Src < 0x8000000000000000
+    // Val = select Sel, Src, Src - 0x8000000000000000
+    // Ofs = select Sel, 0, 0x8000000000000000
----------------
Maybe worth explaining why the extra rounding step here doesn't matter.


Repository:
  rL LLVM

https://reviews.llvm.org/D53794





More information about the llvm-commits mailing list