[llvm-bugs] [Bug 44549] New: [X86] uint64->f32 on 32-bit Windows without SSE can have double rounding

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 14 15:04:47 PST 2020


            Bug ID: 44549
           Summary: [X86] uint64->f32 on 32-bit Windows without SSE can
                    have double rounding
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: craig.topper at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

On 32-bit targets without SSE we use the X87 unit to do uint64_t -> f32/f64/f80
conversions by converting a 64-bit integer into 80-bit extended precision using
FILD. This is a signed conversion so then we add a fixup that is either 0 or
2^64 based on whether the original number was negative. Then we round the
result if the destination type is f32 or f64.

This should work correctly assuming the the PC field in X87's FPCW is set to
80-bit. The FILD is not subject to the PC field, but the fixup FADD is.

On Windows, the PC field defaults to 64-bit. So the fixup FADD will round to
the double precision. This means if we're doing a conversion from uint64_t to
fp32, we'll round after the fixup FADD and round again when we do the fst to
round to f32.

Conversions to f64 should fine since we'll just round after the FADD and the
final rounding operation won't do anything.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200114/0fbba07a/attachment.html>

More information about the llvm-bugs mailing list