[PATCH] D68257: [Support] Add mathematical constants

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 15:38:45 PDT 2019


efriedma added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:4998
+        DAG.getNode(ISD::FMUL, dl, MVT::f32, Exp,
+                    DAG.getConstantFP(numbers::ln2, dl, MVT::f32));
 
----------------
I don't like taking a 64-bit constant and truncating it to 32 bits.  For most common mathematical constants, it probably produces the right result, but it's not correctly rounded in general.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:1943
     if (ArgLb == ExpLb || ArgID == Intrinsic::exp)
-      // FIXME: The Euler number should be M_E, but it's place of definition
-      // is not quite standard.
-      Eul = ConstantFP::get(Log->getType(), 2.7182818284590452354);
+      Eul = ConstantFP::get(Log->getType(), numbers::e);
     else if (ArgLb == Exp2Lb || ArgID == Intrinsic::exp2)
----------------
Do we actually have enough precision here if the type is long double?


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

https://reviews.llvm.org/D68257





More information about the llvm-commits mailing list