Index: llvm/lib/IR/DataLayout.cpp =================================================================== --- llvm/lib/IR/DataLayout.cpp +++ llvm/lib/IR/DataLayout.cpp @@ -814,7 +814,7 @@ unsigned NumBits = getIndexTypeSizeInBits(Ty); IntegerType *IntTy = IntegerType::get(Ty->getContext(), NumBits); if (VectorType *VecTy = dyn_cast(Ty)) - return FixedVectorType::get(IntTy, VecTy->getNumElements()); + return VectorType::get(IntTy, VecTy); return IntTy; } Index: llvm/test/Transforms/InstCombine/gep-vector.ll =================================================================== --- llvm/test/Transforms/InstCombine/gep-vector.ll +++ llvm/test/Transforms/InstCombine/gep-vector.ll @@ -138,20 +138,36 @@ ; Negative test - avoid doing bitcast on i8*, because '16' should be scaled by 'vscale'. define i8* @test_accumulate_constant_offset_vscale_nonzero( %pg, i8* %base) { -; CHECK-LABEL: @test_accumulate_constant_offset_vscale_nonzero -; CHECK-NEXT: %bc = bitcast i8* %base to * -; CHECK-NEXT: %gep = getelementptr , * %bc, i64 1, i64 4 -; CHECK-NEXT: ret i8* %gep +; CHECK-LABEL: @test_accumulate_constant_offset_vscale_nonzero( +; CHECK-NEXT: [[BC:%.*]] = bitcast i8* [[BASE:%.*]] to * +; CHECK-NEXT: [[GEP:%.*]] = getelementptr , * [[BC]], i64 1, i64 4 +; CHECK-NEXT: ret i8* [[GEP]] +; %bc = bitcast i8* %base to * %gep = getelementptr , * %bc, i64 1, i64 4 ret i8* %gep } define i8* @test_accumulate_constant_offset_vscale_zero( %pg, i8* %base) { -; CHECK-LABEL: @test_accumulate_constant_offset_vscale_zero -; CHECK-NEXT: %[[RES:.*]] = getelementptr i8, i8* %base, i64 4 -; CHECK-NEXT: ret i8* %[[RES]] +; CHECK-LABEL: @test_accumulate_constant_offset_vscale_zero( +; CHECK-NEXT: [[TMP1:%.*]] = getelementptr i8, i8* [[BASE:%.*]], i64 4 +; CHECK-NEXT: ret i8* [[TMP1]] +; %bc = bitcast i8* %base to * %gep = getelementptr , * %bc, i64 0, i64 4 ret i8* %gep } + +@GLOBAL = internal global i32 zeroinitializer + +define i32* @gep_cvbase_w_cv_idx( %base, i64 %raw_addr) { +; CHECK-LABEL: @gep_cvbase_w_cv_idx( +; CHECK-NEXT: ret i32* extractelement ( shufflevector ( insertelement ( undef, i32* @GLOBAL, i32 0), undef, zeroinitializer), i32 0) +; + %ins1 = insertelement undef, i32* @GLOBAL, i32 0 + %splat1 = shufflevector %ins1, undef, zeroinitializer + %gep = getelementptr i32, %splat1, zeroinitializer + %ee = extractelement %gep, i32 0 + ret i32* %ee +} +