[llvm] [LV] Emit truncate for widen-induction in VPlan during construction. (PR #225991)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 03:33:10 PDT 2026
================
@@ -7539,6 +7539,20 @@ static void preparePlanForEpilogueVectorLoop(
IRPhiToResumeForEpi.at(IndPhi)->getUnderlyingValue());
}
assert(ResumeVPV && "Must have a resume value");
+ auto *PhiR = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R);
+ // A truncated widen induction has narrower type than resume value, so
+ // create a scalar cast to match the type.
+ if (PhiR && PhiR->getScalarType() != ResumeVPV->getScalarType()) {
+ assert(ResumeVPV->getScalarType()->getScalarSizeInBits() >
+ PhiR->getScalarType()->getScalarSizeInBits() &&
+ "Widen induction type should always narrower or same as resume "
+ "value type.");
+ VPBuilder PHBuilder(Plan.getVectorPreheader(),
+ Plan.getVectorPreheader()->getFirstNonPhi());
+ ResumeVPV = PHBuilder.createScalarCast(Instruction::Trunc, ResumeVPV,
----------------
artagnon wrote:
createScalarZExtOrTrunc, which is a no-op when sizes are equal?
https://github.com/llvm/llvm-project/pull/225991
More information about the llvm-commits
mailing list