This is an alternative to D141074 to fix the problem by adjusting
the precision control dynamically.
Posting for early review so we can do some testing of this solution.
Paths
| Differential D142178
[X86] Change precision control to FP80 during u64->fp32 conversion on Windows. ClosedPublic Authored by craig.topper on Jan 19 2023, 10:31 PM.
Details Summary This is an alternative to D141074 to fix the problem by adjusting Posting for early review so we can do some testing of this solution.
Diff Detail
Event TimelineThis revision was not accepted when it landed; it landed in state Needs Review.Jan 20 2023, 12:34 AM Closed by commit rG928a1764d6bd: [X86][WIP] Change precision control to FP80 during u64->fp32 conversion on… (authored by craig.topper). · Explain Why This revision was automatically updated to reflect the committed changes. Comment Actions This looks a good way to solve the problem.
Comment Actions Use the load version of fadd when possible. Only handling the case of loading an f32 value. craig.topper retitled this revision from [X86][WIP] Change precision control to FP80 during u64->fp32 conversion on Windows. to [X86] Change precision control to FP80 during u64->fp32 conversion on Windows..Jan 29 2023, 10:14 PM Comment Actions Could you update the diff? The current diff is outdated and cannot be applied to main branch automatically.
Comment Actions Remove unrelated comment change. The line is longer than 80 columns, but isn't near code this is touching.
Comment Actions
clang-format test failed. We need to fix the comment. Comment Actions
I'll fix in a separate pre-commit. It's a distraction for this review.
Comment Actions I wrote some code to verify that u64 to f64 conversion using FILD+FADD with 53-bit precision is accurate. I tested it with 10^12 cases and the results are: u64 to f32 conversion failed frequently, but u64 to f64 conversion does not failed. https://reviews.llvm.org/F26366621 This revision is now accepted and ready to land.Feb 4 2023, 7:03 AM Comment Actions
The u64->f64 conversion can only fail if PC is set to single precision. The original bug we are fixing is that with PC set to double precision we round from fp80 to fp64 then to fp32. If PC is set to single precision we have a lot more problems with f64. Closed by commit rG11fb09ec0afa: [X86] Change precision control to FP80 during u64->fp32 conversion on Windows. (authored by craig.topper). · Explain WhyFeb 6 2023, 7:35 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 494399 llvm/lib/Target/X86/X86ISelLowering.h
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86InstrFPStack.td
llvm/test/CodeGen/X86/uint64-to-float.ll
|
clang-format not found in user’s local PATH; not linting file.