Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -10527,8 +10527,9 @@ // instruction is uniform inwhich case generate only the first lane for each // of the UF parts. unsigned EndLane = IsUniform ? 1 : State.VF.getKnownMinValue(); - assert((!State.VF.isScalable() || IsUniform) && - "Can't scalarize a scalable vector"); + assert((!State.VF.isScalable() || IsUniform) || + getUnderlyingInstr()->getOpcode() == Instruction::Freeze && + "Can't scalarize a scalable vector"); for (unsigned Part = 0; Part < State.UF; ++Part) for (unsigned Lane = 0; Lane < EndLane; ++Lane) State.ILV->scalarizeInstruction(getUnderlyingInstr(), this, @@ -10841,7 +10842,9 @@ set(Def, VectorValue, Part); } else { // Initialize packing with insertelements to start from undef. - assert(!VF.isScalable() && "VF is assumed to be non scalable."); + assert(!VF.isScalable() || + (LastInst && LastInst->getOpcode() == Instruction::Freeze) && + "VF is assumed to be non scalable."); Value *Undef = PoisonValue::get(VectorType::get(LastInst->getType(), VF)); set(Def, Undef, Part); for (unsigned Lane = 0; Lane < VF.getKnownMinValue(); ++Lane) Index: llvm/test/Transforms/LoopVectorize/AArch64/vector-freeze-sve.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/LoopVectorize/AArch64/vector-freeze-sve.ll @@ -0,0 +1,43 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -loop-vectorize -mattr=+sve -mtriple aarch64-linux-gnu -S < %s | FileCheck %s + +target triple = "aarch64-unknown-linux-gnu" + +; Function Attrs: argmemonly nofree nosync nounwind willreturn +declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #0 + +; Function Attrs: argmemonly nofree nosync nounwind willreturn +declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #0 + +define void @_Z14PDF_NameEncodeRK14CFX_ByteString() #1 personality i8* undef { +; CHECK-LABEL: @_Z14PDF_NameEncodeRK14CFX_ByteString( +; CHECK: ret void +; +for.body.preheader: + br label %for.body + +for.body: ; preds = %if.end, %for.body.preheader + %indvars.iv132 = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next133, %if.end ] + %arrayidx = getelementptr inbounds [1 x i8], [1 x i8]* undef, i64 0, i64 %indvars.iv132 + %0 = load i8, i8* %arrayidx, align 1 + br i1 false, label %if.end, label %lor.lhs.false + +lor.lhs.false: ; preds = %for.body + %.fr122 = freeze i8 %0 + %cmp9 = icmp eq i8 %.fr122, 0 + br i1 %cmp9, label %if.end, label %switch.early.test + +switch.early.test: ; preds = %lor.lhs.false + br label %if.end + +if.end: ; preds = %switch.early.test, %lor.lhs.false, %for.body + %indvars.iv.next133 = add nuw nsw i64 %indvars.iv132, 1 + %exitcond136.not = icmp eq i64 %indvars.iv.next133, 0 + br i1 %exitcond136.not, label %for.end.loopexit, label %for.body + +for.end.loopexit: ; preds = %if.end + ret void +} + +attributes #0 = { argmemonly nofree nosync nounwind willreturn } +attributes #1 = { "target-features"="+aes,+crypto,+neon,+sha2,+v8a" }