Issue 74013
Summary Use of rccps leads to incorrect results for large values
Labels backend:X86, floating-point
Assignees
Reporter andykaylor
    When the arcp and ninf flags are set, the x86 backend uses an rccps instruction plus Newton-Raphson refinement to lower single precision vector division. Unfortunately, the rccps instruction returns zero if the result is denormal. This leads to incorrect results for simple division when the divisor is near FLT_MAX.

Here's a reproducer:

https://godbolt.org/z/9c6TK471o

Note that this happens without regard to whether FTZ/DAZ are enabled.

FWIW, gcc has this same behavior, though gcc requires -funsafe-math-optimizations and -ffinite-math-only and a comment at X86TargetLowering::getRecipEstimate indicates that it intends to match gcc behavior. This problem can be avoided using -mrecip=none.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to