[libc-commits] [PATCH] D90906: [libc] Add implementations of fdim[f|l].
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Nov 10 06:03:19 PST 2020
lntue added inline comments.
================
Comment at: libc/utils/FPUtil/BasicOperations.h:78
+
+ return (x > y ? x - y : 0);
+}
----------------
sivachandra wrote:
> lntue wrote:
> > 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.
> SGTM. So, in general, out position is:
>
> If we use a language operator for a floating point operation, then we assume that the machine instruction (or instructions) implementing the operator conform to the IEEE-754 standard.
>
> Does that sound reasonable?
SGTM
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