diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index e25dc0242878..339e3c37ee25 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -6528,11 +6528,12 @@ static bool getTargetConstantBitsFromNode(SDValue Op, unsigned EltSizeInBits, namespace llvm { namespace X86 { -bool isConstantSplat(SDValue Op, APInt &SplatVal) { +bool isConstantSplat(SDValue Op, APInt &SplatVal, bool AllowPartialUndefs) { APInt UndefElts; SmallVector EltBits; if (getTargetConstantBitsFromNode(Op, Op.getScalarValueSizeInBits(), - UndefElts, EltBits, true, false)) { + UndefElts, EltBits, true, + AllowPartialUndefs)) { int SplatIndex = -1; for (int i = 0, e = EltBits.size(); i != e; ++i) { if (UndefElts[i]) diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h index 0da22acc99de..825ddedad176 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.h +++ b/llvm/lib/Target/X86/X86ISelLowering.h @@ -722,7 +722,10 @@ namespace llvm { /// If Op is a constant whose elements are all the same constant or /// undefined, return true and return the constant value in \p SplatVal. - bool isConstantSplat(SDValue Op, APInt &SplatVal); + /// If we have undef bits that don't cover an entire element, we treat these + /// as zero if AllowPartialUndefs is set, else we fail and return false. + bool isConstantSplat(SDValue Op, APInt &SplatVal, + bool AllowPartialUndefs = true); } // end namespace X86 //===--------------------------------------------------------------------===//