[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:42 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))
----------------
fhahn wrote:

Yep, I added a comment that the recipes skipped here may or may not produce a vector eventually and a TODO to introduce unpacks for them as well, and remove them once we are guaranteed to produce scalars. 

For that reason, I left the code as is here for now.

https://github.com/llvm/llvm-project/pull/155670


More information about the llvm-commits mailing list