[libc-commits] [PATCH] D90906: [libc] Add implementations of fdim[f|l].

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Nov 9 22:20:54 PST 2020


lntue marked an inline comment as done.
lntue added inline comments.


================
Comment at: libc/test/src/math/FDimTest.h:24
+  void testNaNArg(FuncPtr func) {
+    DECLARE_SPECIAL_CONSTANTS(T)
+    EXPECT_FP_EQ(nan, func(nan, inf));
----------------
sivachandra wrote:
> Can you move this declaration out of the method? This way, other methods can also use them without redeclarations?
FPBits class cannot be constexpr yet, so we cannot have these constants as static members of the class yet.  I moved them out as const members instead.


================
Comment at: libc/utils/FPUtil/BasicOperations.h:78
+
+  return (x > y ? x - y : 0);
+}
----------------
sivachandra wrote:
> The operation `x - y` can lead to overflow or underflow. Shouldn't we detect that and return the appropriate value as specified by the standard? Or, should we assume that the machine instruction does the right thing?
We are assuming CPU's supporting IEEE 754 arithmetic, so the machine instruction will do the right thing.  For example the spec specified to return HUGE_VAL in case of overflow, which is resolved to inf for IEEE 754 standard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90906



More information about the libc-commits mailing list