[PATCH] D142178: [X86][WIP] Change precision control to FP80 during u64->fp32 conversion on Windows.
icedrocket via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 00:15:14 PST 2023
icedrocket added inline comments.
================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:37267-37290
+ // Load the old value of the control word...
+ Register OldCW = MF->getRegInfo().createVirtualRegister(&X86::GR32RegClass);
+ addFrameReference(BuildMI(*BB, MI, DL, TII->get(X86::MOVZX32rm16), OldCW),
+ OrigCWFrameIdx);
+
+ // OR 0b11 into bit 8 and 9. 0b11 is the encoding for double extended
+ // precision.
----------------
craig.topper wrote:
> icedrocket wrote:
> > icedrocket wrote:
> > > What about just set value to 0x37f instead of applying bitwise OR to original value? We can save two registers by doing this, and only need two bytes of memory to hold the static value.
> > >
> > Ah, there is still the possibility of an exception being thrown due to a stack overflow. What if the original value's rounding mode is not round to nearest?
> The compiler is managing the stack so there shouldn't be any overflow unless someone uses assembly or something to add things to the stack that the compiler doesn't know about.
>
> Rounding mode doesn't matter because the fadd is not supposed to round. Any integer than can be created should fit perfectly in an 80 bit FP.
Yes, and FADD doesn't seem to cause a stack overflow, because it doesn't push on the stack. I forgot that the modified control word only applies to FADD. So, as long as we only use FP80_ADD on LowerUINT_TO_FP, no exception will be thrown.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142178/new/
https://reviews.llvm.org/D142178
More information about the llvm-commits
mailing list