Jordy Potman
2011-Nov-02 16:54 UTC
[LLVMdev] Issues in compiler-rt __truncdfsf2 and __extendsfdf2 functions?
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>
Reasonably Related Threads
- [LLVMdev] Latency of true depency of store followed by aliased load in ScheduleDAGInstrs
- [LLVMdev] Latency of true depency of store followed by aliased load in ScheduleDAGInstrs
- [LLVMdev] Error messages in llvm-test
- [compiler-rt] Undefined negation in float emulation functions
- [compiler-rt] Undefined negation in float emulation functions