[llvm] [VPlan] Extract reverse mask from reverse accesses (PR #155579)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 31 01:19:53 PDT 2026
================
@@ -3799,9 +3815,29 @@ InstructionCost VPWidenMemoryRecipe::computeCost(ElementCount VF,
// TODO: Using the original IR may not be accurate.
// Currently, ARM will use the underlying IR to calculate gather/scatter
// instruction cost.
- assert(!Reverse &&
- "Inconsecutive memory access should not have the order.");
+#ifndef NDEBUG
+ auto IsReverse = [this]() {
+ // Check if mask is reversed
+ if (VPValue *Mask = getMask())
+ if (match(Mask, m_Reverse(m_VPValue())))
+ return true;
+
+ // For loads, check if the single user is a reverse operation
+ if (isa<VPWidenLoadRecipe, VPWidenLoadEVLRecipe>(this)) {
+ auto *U = getVPSingleValue()->getSingleUser();
+ return U && match(cast<VPRecipeBase>(U), m_Reverse(m_VPValue()));
+ }
+ // For stores, check if the stored value is reversed
----------------
Mel-Chen wrote:
c4b9848f66df8d2b280129e4549c701a17afd5d6
https://github.com/llvm/llvm-project/pull/155579
More information about the llvm-commits
mailing list