[LLVMdev] Issues in compiler-rt __truncdfsf2 and __extendsfdf2 functions?

Jordy Potman jordy.potman at recoresystems.com
Wed Nov 2 09:54:19 PDT 2011


Hi all,

We are using compiler-rt for floating point emulation on our DSP core. I
am currently investigating two issues found by running TestFloat [1] on
our core.

The first issue is in __truncdfsf2. __truncdfsf2(0x1p+128) produces
0x1p-128, while the expected result is inf. __truncdfsf2(-0x1p+128)
produces -0x1p-128, while the expected result is -inf. I think the
condition of the else if on line 137 of truncdfsf2.c should be (aAbs >=
overflow) instead of the current (aAbs > overflow) because overflow is
0x1p+128 which cannot be represented as a float. Changing the condition
to (aAbs >= overflow) fixes this issue. The attached patch does this.

The second issue is in how __extendsfdf2 handles signaling NaNs.
Currently __extendsfdf2 extends a float signaling NaN to a double
signaling NaN. TestFloat expects the result to be a double quiet NaN. I
think the IEEE-754 standard defines that an operation involving a
signaling NaN should deliver a quiet NaN as its result but I don't know
if conversion from float to double qualifies as an operation. So I am
not sure what is the correct result here. 

Next to these issues the TestFloat division tests fail because the
__divsf3 and __divdf3 implementations currently flush denormals to zero.
So I might want to have a go at trying to implement gradual underflow
with correct rounding, but I am not a floating point emulation expert so
any pointers on how to do that would be appreciated!

Jordy

[1] http://www.jhauser.us/arithmetic/TestFloat.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: truncdfsf2.patch
Type: text/x-patch
Size: 409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111102/ebf2c6e6/attachment.bin>


More information about the llvm-dev mailing list