[Nasm-bugs] [Bug 3392368] "exponent 32 is too large" undefined behavior at float.c line 559.

noreply-nasm at gorcunov.org noreply-nasm at gorcunov.org
Mon Nov 26 14:46:55 PST 2018


--- Comment #13 from H. Peter Anvin <hpa at zytor.com> ---
Ah, now I remember: we can't do that either, because in that case we end up
with ms == -LIMB_BItS and we end up with the same failure on line 553.

One of these *mp |= statements has to be conditionalized, or v has to be cast
to fp_2limb.

Which one is correct?  It turns out it doesn't matter; in one case (ms <= 0) we
advance mp after filling in the last digit, and in the other (ms < 0) we end up
advancing mp before filling in the first digit of the next limb.

In either case the current code is outright wrong and will produce the
incorrect answer.

I'm going to change it to use the cast to (fp_2limb) and (ms < 0), since that
is free on x86-64, the host architecture that matters most, and should not be
too impactful on i386, since unlike the (ms <= 0) case, is only executed on
each mp increment.

For i386, gcc in fact produces very nice code for this case, combining a shrd
and an shr instruction instead of recalculating the %cl shift, so in either
case the code produced is better than a conditional.

You are receiving this mail because:
You are watching all bug changes.
You are on the CC list for the bug.

More information about the Nasm-bugs mailing list