[llvm] [VPlan] Add VPInstruction to unpack vector values to scalars. (PR #155670)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 6 05:25:41 PDT 2025
================
@@ -3789,6 +3796,42 @@ void VPlanTransforms::materializeBuildVectors(VPlan &Plan) {
});
}
}
+
+ // Create explicit VPInstructions to convert vectors to scalars.
+ for (VPBasicBlock *VPBB : VPBBsInsideLoopRegion) {
+ for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
+ if (isa<VPReplicateRecipe, VPInstruction, VPScalarIVStepsRecipe>(&R))
+ continue;
+ for (VPValue *Def : R.definedValues()) {
+ if (vputils::isSingleScalar(Def) || vputils::onlyFirstLaneUsed(Def))
+ continue;
+
+ auto IsInsideReplicateRegion = [LoopRegion](VPUser *U) {
+ VPRegionBlock *ParentRegion =
+ cast<VPRecipeBase>(U)->getParent()->getParent();
+ return ParentRegion && ParentRegion != LoopRegion;
+ };
+ // At the moment, we only create unpacks for scalar users outside
+ // replicate regions. Recipes inside replicate regions still manually
+ // extract the required lanes. TODO: Remove once replicate regions are
+ // unrolled explicitly.
+ if (none_of(Def->users(), [Def, &IsInsideReplicateRegion](VPUser *U) {
+ return !IsInsideReplicateRegion(U) && U->usesScalars(Def);
----------------
fhahn wrote:
done thanks
https://github.com/llvm/llvm-project/pull/155670
More information about the llvm-commits
mailing list