[llvm] [VPlan] Add convertToUniformRecipe transform. (PR #139150)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu May 15 13:38:34 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;
+
+ // Skip recipes that aren't uniform and don't have only their scalar
+ // results used. In the later case, we would introduce extra broadcasts.
+ if (!vputils::isUniformAfterVectorization(Def) ||
----------------
fhahn wrote:
Agreed, this is long overdue! https://github.com/llvm/llvm-project/pull/140134
https://github.com/llvm/llvm-project/pull/139150
More information about the llvm-commits
mailing list