[llvm] [VPlan] Extract reverse operation for reverse accesses (PR #146525)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 00:40:53 PST 2025
================
@@ -2625,6 +2648,34 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
}
}
ToErase.push_back(CurRecipe);
+
+ // Convert general reverse operations on loaded results into vp.reverse,
+ // when the VPVectorEndPointerRecipe adjusting the access address uses EVL
+ // instead of VF.
+ if (auto *LoadR = dyn_cast<VPWidenLoadEVLRecipe>(EVLRecipe)) {
----------------
Mel-Chen wrote:
I don’t think this transformation can be moved into optimizeMaskToEVL. Strictly speaking, we can move it there right now, but this won’t hold in the future. The long-term goal of this patch is to reduce the number of reverse operations, and several situations may occur:
1. The number of reverse operations may be reduced to zero. In that case, a reverse load could become something like:
`Load(VecEndPtr(addr, VF), Reverse(mask))`.
2.The total number of reverse operations may be reduced but not fully eliminated, and some of them may be moved. In that case, the reverse load may appear in forms such as:
`Reverse(BinOp(Load(VecEndPtr(addr, VF), Reverse(mask)), ...))`.
Because of this, we ultimately won’t be able to simply match and transform reverse loads inside optimizeMaskToEVL using a pattern like
`m_Reverse(m_Load(m_VecEndPtr(addr, VF), m_Reverse(mask)))`.
https://github.com/llvm/llvm-project/pull/146525
More information about the llvm-commits
mailing list