[llvm] [VPlan] Extract reverse mask from reverse accesses (PR #155579)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 2 03:26:45 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;
+ };
----------------
lukel97 wrote:
For the vp.reverse case, could we just have added a check for `if (Ty == i1 && ID == experimental_vp_reverse) return 0;` in VPWidenIntrinsicRecipe::computeCost?
That check would only be temporary and would go away once we either remove vp.reverse, or start costing the mask in the legacy cost model.
https://github.com/llvm/llvm-project/pull/155579
More information about the llvm-commits
mailing list