[llvm] [VPlan] Extract reverse mask from reverse accesses (PR #155579)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 27 02:57:31 PDT 2025


================
@@ -6939,6 +6939,29 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
             cast<VPRecipeWithIRFlags>(R).getPredicate() !=
                 cast<CmpInst>(UI)->getPredicate())
           return true;
+
+        if (auto *MemR = dyn_cast<VPWidenMemoryRecipe>(&R)) {
+          bool IsReverse = CostCtx.CM.getWideningDecision(UI, VF) ==
+                           LoopVectorizationCostModel::CM_Widen_Reverse;
----------------
Mel-Chen wrote:

@fhahn I think this is the most straightforward approach.  
Currently, we could check whether the operand or user is a reverse operation, but in the future reverse operations might be simplified away, so relying on reverse operation is not a long-term approach.
The last option is to use the address for the check, since only reverse operations need to use VPVectorEndPointer.  
What do you think?

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


More information about the llvm-commits mailing list