Index: lib/CodeGen/CGExprScalar.cpp =================================================================== --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -1215,7 +1215,13 @@ Value *LHS = nullptr, *RHS = nullptr; if (CurIdx == 0) { // insert into undef -> shuffle (src, undef) - Args.push_back(C); + // extractelement index can be any integer type + // shufflemask is only allowed to contain 32 bit integers + // make sure we can savely convert to 32 bit + assert(llvm::ConstantInt::isValueValidForType(CGF.Int32Ty, + C->getZExtValue()) && + "Index operand too large for shufflevector mask!"); + Args.push_back(Builder.getInt32(C->getZExtValue())); Args.resize(ResElts, llvm::UndefValue::get(CGF.Int32Ty)); LHS = EI->getVectorOperand();