diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -1518,6 +1518,22 @@ return CV->getSplatValue(); if (const ConstantVector *CV = dyn_cast(this)) return CV->getSplatValue(AllowUndefs); + + // Check if this is a constant expression splat of the form returned by + // ConstantVector::getSplat() + Constant *SplatVal = nullptr; + ConstantInt *Index = nullptr; + + match(this, + m_Shuffle(m_InsertElt(m_Undef(), m_Constant(SplatVal), m_ConstantInt()), + m_Undef())); + + if (Index && Index->getValue() == 0) { + if (SplatVal) { + return SplatVal; + } + } + return nullptr; }