diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -4274,9 +4274,9 @@ // We can't combine several GEPs into one vector if they operate on // different types. - Type *Ty0 = VL0->getOperand(0)->getType(); + Type *Ty0 = cast(VL0)->getSourceElementType(); for (Value *V : VL) { - Type *CurTy = cast(V)->getOperand(0)->getType(); + Type *CurTy = cast(V)->getSourceElementType(); if (Ty0 != CurTy) { LLVM_DEBUG(dbgs() << "SLP: not-vectorizable GEP (different types).\n"); diff --git a/llvm/test/Transforms/SLPVectorizer/X86/opaque-ptr-2.ll b/llvm/test/Transforms/SLPVectorizer/X86/opaque-ptr-2.ll --- a/llvm/test/Transforms/SLPVectorizer/X86/opaque-ptr-2.ll +++ b/llvm/test/Transforms/SLPVectorizer/X86/opaque-ptr-2.ll @@ -6,12 +6,12 @@ define void @test(ptr %arg, ptr %arg1, ptr %arg2) { ; CHECK-LABEL: @test( -; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x ptr> poison, ptr [[ARG1:%.*]], i32 0 -; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x ptr> [[TMP1]], ptr [[ARG2:%.*]], i32 1 -; CHECK-NEXT: [[TMP3:%.*]] = getelementptr ptr, <2 x ptr> [[TMP2]], <2 x i64> +; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds i8, ptr [[ARG2:%.*]], i64 128 +; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds ptr, ptr [[ARG1:%.*]], i64 -1 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds ptr, ptr [[ARG:%.*]], i64 0 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds ptr, ptr [[ARG]], i64 1 -; CHECK-NEXT: store <2 x ptr> [[TMP3]], ptr [[TMP4]], align 8 +; CHECK-NEXT: store ptr [[TMP3]], ptr [[TMP4]], align 8 +; CHECK-NEXT: store ptr [[TMP]], ptr [[TMP5]], align 8 ; CHECK-NEXT: ret void ; %tmp = getelementptr inbounds i8, ptr %arg2, i64 128