Index: lib/CodeGen/CGExprScalar.cpp =================================================================== --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -1216,7 +1216,15 @@ Value *LHS = nullptr, *RHS = nullptr; if (CurIdx == 0) { // insert into undef -> shuffle (src, undef) - Args.push_back(C); + // shufflemask must use an i32 + if (C->getBitWidth() == 32) { + Args.push_back(C); + } else { + 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();