diff options
author | Craig Topper <craig.topper@intel.com> | 2018-10-30 03:27:12 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2018-10-30 03:27:12 +0000 |
commit | 67c28785012c3a11586ee118ad44a7a9c65fbed0 (patch) | |
tree | 165e673ea1d953cc44f2c6ddf21886af83fe9d6f /llvm/lib | |
parent | 676d7a7a437a39e8e51485744dad9ad6b206f0b5 (diff) | |
download | bcm5719-llvm-67c28785012c3a11586ee118ad44a7a9c65fbed0.tar.gz bcm5719-llvm-67c28785012c3a11586ee118ad44a7a9c65fbed0.zip |
[X86] Cleanup the code in LowerFABSorFNEG and LowerFCOPYSIGN a little. NFC
Use SelectionDAG::EVTToAPFloatSemantics. Make the LogicVT calculation in LowerFABSorFNEG similar to LowerFCOPYSIGN. Use APInt::getSignedMaxValue instead of ~APInt::getSignMask.
llvm-svn: 345565
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 94f3d8c6026..c7d398873d2 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -17956,43 +17956,36 @@ static SDValue LowerFABSorFNEG(SDValue Op, SelectionDAG &DAG) { MVT VT = Op.getSimpleValueType(); bool IsF128 = (VT == MVT::f128); + assert((VT == MVT::f64 || VT == MVT::f32 || VT == MVT::f128 || + VT == MVT::v2f64 || VT == MVT::v4f64 || VT == MVT::v4f32 || + VT == MVT::v8f32 || VT == MVT::v8f64 || VT == MVT::v16f32) && + "Unexpected type in LowerFABSorFNEG"); // FIXME: Use function attribute "OptimizeForSize" and/or CodeGenOpt::Level to // decide if we should generate a 16-byte constant mask when we only need 4 or // 8 bytes for the scalar case. - MVT LogicVT; - MVT EltVT; - - if (VT.isVector()) { - LogicVT = VT; - EltVT = VT.getVectorElementType(); - } else if (IsF128) { - // SSE instructions are used for optimized f128 logical operations. - LogicVT = MVT::f128; - EltVT = VT; - } else { - // There are no scalar bitwise logical SSE/AVX instructions, so we - // generate a 16-byte vector constant and logic op even for the scalar case. - // Using a 16-byte mask allows folding the load of the mask with - // the logic op, so it can save (~4 bytes) on code size. + // There are no scalar bitwise logical SSE/AVX instructions, so we + // generate a 16-byte vector constant and logic op even for the scalar case. + // Using a 16-byte mask allows folding the load of the mask with + // the logic op, so it can save (~4 bytes) on code size. + bool IsFakeVector = !VT.isVector() && !IsF128; + MVT LogicVT = VT; + if (IsFakeVector) LogicVT = (VT == MVT::f64) ? MVT::v2f64 : MVT::v4f32; - EltVT = VT; - } - unsigned EltBits = EltVT.getSizeInBits(); + unsigned EltBits = VT.getScalarSizeInBits(); // For FABS, mask is 0x7f...; for FNEG, mask is 0x80... - APInt MaskElt = - IsFABS ? APInt::getSignedMaxValue(EltBits) : APInt::getSignMask(EltBits); - const fltSemantics &Sem = - EltVT == MVT::f64 ? APFloat::IEEEdouble() : - (IsF128 ? APFloat::IEEEquad() : APFloat::IEEEsingle()); + APInt MaskElt = IsFABS ? APInt::getSignedMaxValue(EltBits) : + APInt::getSignMask(EltBits); + const fltSemantics &Sem = SelectionDAG::EVTToAPFloatSemantics(VT); SDValue Mask = DAG.getConstantFP(APFloat(Sem, MaskElt), dl, LogicVT); SDValue Op0 = Op.getOperand(0); bool IsFNABS = !IsFABS && (Op0.getOpcode() == ISD::FABS); - unsigned LogicOp = - IsFABS ? X86ISD::FAND : IsFNABS ? X86ISD::FOR : X86ISD::FXOR; + unsigned LogicOp = IsFABS ? X86ISD::FAND : + IsFNABS ? X86ISD::FOR : + X86ISD::FXOR; SDValue Operand = IsFNABS ? Op0.getOperand(0) : Op0; if (VT.isVector() || IsF128) @@ -18028,10 +18021,7 @@ static SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) { VT == MVT::v8f32 || VT == MVT::v8f64 || VT == MVT::v16f32) && "Unexpected type in LowerFCOPYSIGN"); - MVT EltVT = VT.getScalarType(); - const fltSemantics &Sem = - EltVT == MVT::f64 ? APFloat::IEEEdouble() - : (IsF128 ? APFloat::IEEEquad() : APFloat::IEEEsingle()); + const fltSemantics &Sem = SelectionDAG::EVTToAPFloatSemantics(VT); // Perform all scalar logic operations as 16-byte vectors because there are no // scalar FP logic instructions in SSE. @@ -18048,7 +18038,7 @@ static SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) { SDValue SignMask = DAG.getConstantFP( APFloat(Sem, APInt::getSignMask(EltSizeInBits)), dl, LogicVT); SDValue MagMask = DAG.getConstantFP( - APFloat(Sem, ~APInt::getSignMask(EltSizeInBits)), dl, LogicVT); + APFloat(Sem, APInt::getSignedMaxValue(EltSizeInBits)), dl, LogicVT); // First, clear all bits but the sign bit from the second operand (sign). if (IsFakeVector) |