[llvm] [VPlan] Add convertToUniformRecipe transform. (PR #139150)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 15:46:32 PDT 2025


================
@@ -1084,6 +1084,40 @@ void VPlanTransforms::simplifyRecipes(VPlan &Plan, Type &CanonicalIVTy) {
   }
 }
 
+static void convertToUniformRecipes(VPlan &Plan) {
+  auto TryToNarrow = [](VPBasicBlock *VPBB) {
+    for (VPRecipeBase &R : make_early_inc_range(reverse(*VPBB))) {
+      // Try to narrow wide and replicating recipes to uniform recipes, based on
+      // VPlan analysis.
+      auto *Def = dyn_cast<VPSingleDefRecipe>(&R);
+      if (!Def || !isa<VPReplicateRecipe, VPWidenRecipe>(Def) ||
+          !Def->getUnderlyingValue())
+        continue;
+
+      auto *RepR = dyn_cast<VPReplicateRecipe>(&R);
+      if (RepR && RepR->isUniform())
+        continue;
----------------
ayalz wrote:

```suggestion
      auto *RepR = dyn_cast<VPReplicateRecipe>(&R);
      if (!RepR && !isa<VPWidenRecipe>(&R))
        continue;

      if (RepR && RepR->isUniform())
        continue;
```


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


More information about the llvm-commits mailing list