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

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 11 02:14:53 PST 2026


================
@@ -263,6 +263,18 @@ void VPRecipeBase::moveBefore(VPBasicBlock &BB,
 }
 
 InstructionCost VPRecipeBase::cost(ElementCount VF, VPCostContext &Ctx) {
+  // Skip the reverse operation cost for the mask.
+  // TODO: Remove this once redundant mask reverse operations can be eliminated
+  // by VPlanTransforms::cse before cost computation.
+  auto SkipReverseMask = [this]() {
+    if (!match(this,
+               m_CombineOr(m_Reverse(m_VPValue()),
+                           m_Intrinsic<Intrinsic::experimental_vp_reverse>())))
+      return false;
+    auto *Def = cast<VPSingleDefRecipe>(this);
+    auto *Mem = dyn_cast_or_null<VPWidenMemoryRecipe>(Def->getSingleUser());
+    return Mem && Mem->getMask() == Def;
+  };
----------------
Mel-Chen wrote:

Sure. Hopefully, we can remove this FIXME soon. 
0b7bb951993cd82c6defa82bb47ebe0f4b8f5844

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


More information about the llvm-commits mailing list