Index: lib/AsmParser/LLParser.cpp =================================================================== --- lib/AsmParser/LLParser.cpp +++ lib/AsmParser/LLParser.cpp @@ -3193,17 +3193,17 @@ ExplicitTypeLoc, "explicit pointee type doesn't match operand's pointee type"); + unsigned GEPWidth = + BaseType->isVectorTy() ? BaseType->getVectorNumElements() : 0; + ArrayRef Indices(Elts.begin() + 1, Elts.end()); for (Constant *Val : Indices) { Type *ValTy = Val->getType(); if (!ValTy->getScalarType()->isIntegerTy()) return Error(ID.Loc, "getelementptr index must be an integer"); - if (ValTy->isVectorTy() != BaseType->isVectorTy()) - return Error(ID.Loc, "getelementptr index type missmatch"); if (ValTy->isVectorTy()) { unsigned ValNumEl = ValTy->getVectorNumElements(); - unsigned PtrNumEl = BaseType->getVectorNumElements(); - if (ValNumEl != PtrNumEl) + if (GEPWidth && (ValNumEl != GEPWidth)) return Error( ID.Loc, "getelementptr vector index has a wrong number of elements"); Index: test/Assembler/getelementptr_vec_ce.ll =================================================================== --- test/Assembler/getelementptr_vec_ce.ll +++ test/Assembler/getelementptr_vec_ce.ll @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | llvm-dis | FileCheck %s + +@G = global [4 x i32] zeroinitializer + +; CHECK-LABEL: @foo +; CHECK: ret <4 x i32*> getelementptr ([4 x i32], [4 x i32]* @G, <4 x i32> zeroinitializer, <4 x i32> ) +define <4 x i32*> @foo() { + ret <4 x i32*> getelementptr ([4 x i32], [4 x i32]* @G, i32 0, <4 x i32> ) +}