diff options
| author | Craig Topper <craig.topper@intel.com> | 2020-01-14 16:56:17 -0800 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2020-01-14 17:05:23 -0800 |
| commit | 57eb56b83926675dd8a554fc8a8e28ee57278f90 (patch) | |
| tree | 9500a72a40746cce1e04917be6e298b89fb9725a /llvm/lib/Target/X86 | |
| parent | ab035647061272b7efa39364c42e48972cebc0ab (diff) | |
| download | bcm5719-llvm-57eb56b83926675dd8a554fc8a8e28ee57278f90.tar.gz bcm5719-llvm-57eb56b83926675dd8a554fc8a8e28ee57278f90.zip | |
[X86] Swap the 0 and the fudge factor in the constant pool for the 32-bit mode i64->f32/f64/f80 uint_to_fp algorithm.
This allows us to generate better code for selecting the fixup
to load.
Previously when the sign was set we had to load offset 0. And
when it was clear we had to load offset 4. This required a testl,
setns, zero extend, and finally a mul by 4. By switching the offsets
we can just shift the sign bit into the lsb and multiply it by 4.
Diffstat (limited to 'llvm/lib/Target/X86')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 2bf6c3e51c9..70a7f166a5f 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -19377,21 +19377,21 @@ SDValue X86TargetLowering::LowerUINT_TO_FP(SDValue Op, MVT::i64, MMO); Chain = Fild.getValue(1); - APInt FF(32, 0x5F800000ULL); // Check whether the sign bit is set. SDValue SignSet = DAG.getSetCC( dl, getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), MVT::i64), Op.getOperand(OpNo), DAG.getConstant(0, dl, MVT::i64), ISD::SETLT); - // Build a 64 bit pair (0, FF) in the constant pool, with FF in the lo bits. + // Build a 64 bit pair (FF, 0) in the constant pool, with FF in the hi bits. + APInt FF(64, 0x5F80000000000000ULL); SDValue FudgePtr = DAG.getConstantPool( - ConstantInt::get(*DAG.getContext(), FF.zext(64)), PtrVT); + ConstantInt::get(*DAG.getContext(), FF), PtrVT); // Get a pointer to FF if the sign bit was set, or to 0 otherwise. SDValue Zero = DAG.getIntPtrConstant(0, dl); SDValue Four = DAG.getIntPtrConstant(4, dl); - SDValue Offset = DAG.getSelect(dl, Zero.getValueType(), SignSet, Zero, Four); + SDValue Offset = DAG.getSelect(dl, Zero.getValueType(), SignSet, Four, Zero); FudgePtr = DAG.getNode(ISD::ADD, dl, PtrVT, FudgePtr, Offset); // Load the value out, extending it from f32 to f80. |

