[llvm] VPlan: use worklist in simplifyRecipes (PR #93998)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 01:25:39 PDT 2024
================
@@ -986,83 +986,140 @@ void VPlanTransforms::clearReductionWrapFlags(VPlan &Plan) {
}
}
-/// Try to simplify recipe \p R.
-static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
+/// Try to simplify recipe \p R. Returns candidates for further simplification.
+static SmallVector<VPRecipeBase *>
+simplifyRecipe(VPRecipeBase *R, VPTypeAnalysis &TypeInfo, LLVMContext &Ctx) {
using namespace llvm::VPlanPatternMatch;
// Try to remove redundant blend recipes.
- if (auto *Blend = dyn_cast<VPBlendRecipe>(&R)) {
+ if (auto *Blend = dyn_cast<VPBlendRecipe>(R)) {
VPValue *Inc0 = Blend->getIncomingValue(0);
for (unsigned I = 1; I != Blend->getNumIncomingValues(); ++I)
if (Inc0 != Blend->getIncomingValue(I) &&
!match(Blend->getMask(I), m_False()))
- return;
+ return {};
Blend->replaceAllUsesWith(Inc0);
Blend->eraseFromParent();
- return;
+ return {};
}
- VPValue *A;
- if (match(&R, m_Trunc(m_ZExtOrSExt(m_VPValue(A))))) {
- VPValue *Trunc = R.getVPSingleValue();
+ VPValue *X, *X1, *Y, *Z;
----------------
fhahn wrote:
Would be good to limit to changes adding the worklist and include other potential changes as NFC follow up? For this one, would be good to keep variables defined closer to their uses.
https://github.com/llvm/llvm-project/pull/93998
More information about the llvm-commits
mailing list