[PATCH] D68257: [Support] Add mathematical constants
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 14:54:26 PDT 2019
efriedma requested changes to this revision.
efriedma added inline comments.
This revision now requires changes to proceed.
================
Comment at: llvm/include/llvm/Support/MathExtras.h:66
+ inv_sqrtpi = 0.5641895835477563, // https://oeis.org/A087197
+ sqrt2 = 1.414213562373095, // https://oeis.org/A002193
+ inv_sqrt2 = 0.7071067811865475,
----------------
The correct value of sqrt(2) in double-precision is 1.4142135623730951.
And now I don't trust any of the other values...
================
Comment at: llvm/include/llvm/Support/MathExtras.h:71
+ phi = 1.618033988749895; // https://oeis.org/A001622
+constexpr float ef = 2.718282, // https://oeis.org/A001113
+ egammaf = 0.5772157, // https://oeis.org/A001620
----------------
Please mark the constants with "f", e.g. `2.718282f`, so there isn't an extra rounding step.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:1944
+ // FIXME: The `long double` type is not fully supported by the classes
+ // `APFloat` and `Constant`.
+ Eul = ConstantFP::get(Log->getType(), numbers::e);
----------------
I'm not sure this describes the issue correctly. You can specify a long double as a string, or raw bits. It can't interoperate with the native long double because that might have the wrong width.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68257/new/
https://reviews.llvm.org/D68257
More information about the llvm-commits
mailing list