[llvm] [LLVM][VPlan] Keep all VPBlend masks until VPlan transformation. (PR #104015)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 16:11:38 PDT 2024
================
@@ -989,15 +989,47 @@ void VPlanTransforms::clearReductionWrapFlags(VPlan &Plan) {
/// Try to simplify recipe \p R.
static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
using namespace llvm::VPlanPatternMatch;
- // Try to remove redundant blend recipes.
+
if (auto *Blend = dyn_cast<VPBlendRecipe>(&R)) {
- VPValue *Inc0 = Blend->getIncomingValue(0);
+ // Try to remove redundant blend recipes.
+ SmallPtrSet<VPValue *, 4> UniqueValues;
+ if (Blend->isNormalized() || !match(Blend->getMask(0), m_False()))
+ UniqueValues.insert(Blend->getIncomingValue(0));
for (unsigned I = 1; I != Blend->getNumIncomingValues(); ++I)
- if (Inc0 != Blend->getIncomingValue(I) &&
- !match(Blend->getMask(I), m_False()))
- return;
- Blend->replaceAllUsesWith(Inc0);
+ if (!match(Blend->getMask(I), m_False()))
+ UniqueValues.insert(Blend->getIncomingValue(I));
+
+ if (UniqueValues.size() == 1) {
+ Blend->replaceAllUsesWith(*UniqueValues.begin());
+ Blend->eraseFromParent();
----------------
ayalz wrote:
Worth running recursivelyDeleteDeadRecipes() in this case too - on all masks? Or does the elimination of Blend here suffice to trigger dce.
https://github.com/llvm/llvm-project/pull/104015
More information about the llvm-commits
mailing list