This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] AArch64 glibc port


> For the former, there are two issues with the underflow handling: it's
> determined based on the exponent after rounding (which is not correct for
> either "before rounding" or "after rounding" tininess detection - "after
> rounding" tininess detection means after rounding to the normal precision
> rather than after rounding to an actual representable value), and it has
> the test you note for whether the mantissa, after shifting, is nonzero.  I
> think the correct thing to do would be to have a test "if (X##_e == 0 &&
> !_FP_FRAC_ZEROP_##wc(X))" (which then has the existing exception-setting
> logic) immediately after the _FP_ROUND call.  That way, (a) the logic is
> before-rounding tininess, which at least is consistent with
> _FP_PACK_CANONICAL, (b) the INEXACT exception has been set by _FP_ROUND if
> applicable, as required for the logic determining whether to raise the
> underflow flag and (c) the low bits haven't yet been shifted out, so an
> exact zero can be distinguished from an inexact one by the mantissa.
>
> The code that now has "if (!_FP_EXP_NORMAL(fs, wc, X) &&
> !_FP_FRAC_ZEROP_##wc(X))" might then better test "(X##_e ==
> _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(X))" (i.e., the value is a NaN,
> the only remaining case there).
>

This resolves the majority of the outstanding issues.   The solution
above is not quite sufficient because given a true 0, FP_ROUND may set
working bits resulting in the underflow test failing.  I resolved this
by adjusting FP_ROUND such that it does not attempt to round a true
zero, is that sane? I've attached my current patch. The patch is
against glibc/soft-fp but I've actually be using it applied to
libgcc/soft-fp. What is the recommend way to test patches to soft-fp
in glibc?

/Marcus

Attachment: glibc-v3-underflow-patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]