[llvm] VPlan: introduce worklist in simplifyRecipes (PR #105699)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 24 14:11:12 PDT 2024


================
@@ -1009,8 +1015,16 @@ static void simplifyRecipes(VPlan &Plan, LLVMContext &Ctx) {
       Plan.getEntry());
   VPTypeAnalysis TypeInfo(Plan.getCanonicalIV()->getScalarType(), Ctx);
   for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT)) {
-    for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
-      simplifyRecipe(R, TypeInfo);
+    // Populate a Worklist, as simplifyRecipe might return a new recipe that we
----------------
artagnon wrote:

> Instead of simplifying (X && Y) || (X && !Y) directly into X, we can first simplify into (X && (Y || Z)) where Z is !Y, introducing two new recipes. Then the new recipe (Y || Z) should be visited and simplified into 'true' followed by visiting the other new recipe (X && 'true') and simplifying it into X. How will the two new recipes be simplified if they are visited in the other order?

Ah, yes. Interesting caveat here: sub-recipes should be simplified before the root recipes, and hence added to the worklist before the root recipes, right?

Regarding front versus back, agreed. Another interesting caveat.

Regarding moving forward, I will update #93998 in the morning with the two noted caveats; does this patch look okay though, as a preparatory step? (It was originally split from #93998 on Florian's request).

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


More information about the llvm-commits mailing list