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 @@ -1572,9 +1572,8 @@ const APInt &Constant::getUniqueInteger() const { if (const ConstantInt *CI = dyn_cast(this)) return CI->getValue(); - assert(this->getSplatValue() && "Doesn't contain a unique integer!"); - const Constant *C = this->getAggregateElement(0U); - assert(C && isa(C) && "Not a vector of numbers!"); + Constant *C = this->getSplatValue(); + assert(C && isa(C) && "Doesn't contain a unique integer!"); return cast(C)->getValue(); } diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -3220,7 +3220,7 @@ // FIXME: Check address space sizes here if (VectorType *SrcVecTy = dyn_cast(SrcTy)) if (VectorType *DestVecTy = dyn_cast(DestTy)) - if (SrcVecTy->getNumElements() == DestVecTy->getNumElements()) { + if (SrcVecTy->getElementCount() == DestVecTy->getElementCount()) { // An element by element cast. Find the appropriate opcode based on the // element types. SrcTy = SrcVecTy->getElementType(); diff --git a/llvm/test/Transforms/InstSimplify/gep.ll b/llvm/test/Transforms/InstSimplify/gep.ll --- a/llvm/test/Transforms/InstSimplify/gep.ll +++ b/llvm/test/Transforms/InstSimplify/gep.ll @@ -176,4 +176,12 @@ ret %gep } +define @scalable_vector_idx_vector() { +; CHECK-LABEL: @scalable_vector_idx_mix_scalar_vector( +; CHECK-NEXT: ret getelementptr (%struct, zeroinitializer, zeroinitializer, shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer)) +; + %gep = getelementptr %struct, zeroinitializer, i32 0, shufflevector ( insertelement ( undef, i32 1, i32 0), undef, zeroinitializer) + ret %gep +} + ; Check ConstantExpr::getGetElementPtr() using ElementCount for size queries - end.