[llvm] [VPlan] Add VPInstruction to unpack vector values to scalars. (PR #155670)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 14:00:53 PDT 2025
================
@@ -3789,6 +3796,48 @@ 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,
+ VPDerivedIVRecipe, VPCanonicalIVPHIRecipe>(&R))
+ continue;
+ for (VPValue *Def : R.definedValues()) {
+ // Skip recipes that are single-scalar or only have their first lane
+ // used.
+ // TODO: The Defs skipped here may or may not be vector values.
+ // Introduce Unpacks, and remove them later, if they are guaranteed to
+ // produce scalar values.
+ if (vputils::isSingleScalar(Def) || vputils::onlyFirstLaneUsed(Def))
+ continue;
+
+ // At the moment, we only create unpacks for scalar users outside
+ // replicate regions. Recipes inside replicate regions still manually
+ // extract the required lanes.
----------------
ayalz wrote:
```suggestion
// replicate regions. Recipes inside replicate regions still extract the
// required lanes implicitly.
```
https://github.com/llvm/llvm-project/pull/155670
More information about the llvm-commits
mailing list