diff options
Diffstat (limited to 'llvm/lib/Target/X86/X86ISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 8921bd44b34..56c6bd9d268 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -30833,14 +30833,19 @@ static SDValue combineBitcast(SDNode *N, SelectionDAG &DAG, // it's better to handle them early to be sure we emit efficient code by // avoiding store-load conversions. if (VT == MVT::x86mmx) { - // Detect zero-extended MMX constant vectors. + // Detect MMX constant vectors. APInt UndefElts; - SmallVector<APInt, 2> EltBits; - if (getTargetConstantBitsFromNode(N0, 32, UndefElts, EltBits) && - EltBits[1] == 0) { + SmallVector<APInt, 1> EltBits; + if (getTargetConstantBitsFromNode(N0, 64, UndefElts, EltBits)) { SDLoc DL(N0); - return DAG.getNode(X86ISD::MMX_MOVW2D, DL, VT, - DAG.getConstant(EltBits[0], DL, MVT::i32)); + // Handle zero-extension of i32 with MOVD. + if (EltBits[0].countLeadingZeros() >= 32) + return DAG.getNode(X86ISD::MMX_MOVW2D, DL, VT, + DAG.getConstant(EltBits[0].trunc(32), DL, MVT::i32)); + // Else, bitcast to a double. + // TODO - investigate supporting sext 32-bit immediates on x86_64. + APFloat F64(APFloat::IEEEdouble(), EltBits[0]); + return DAG.getBitcast(VT, DAG.getConstantFP(F64, DL, MVT::f64)); } // Detect bitcasts to x86mmx low word. |