[llvm] [VPlan] Fix VPTypeAnalysis cache clobbering in EVL transform (PR #120252)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 09:50:25 PST 2024


================
@@ -1565,10 +1567,17 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
         VPValue *CurVPV = CurRecipe->getVPSingleValue();
         CurVPV->replaceAllUsesWith(NewRecipe->getVPSingleValue());
       }
-      CurRecipe->eraseFromParent();
+      // Defer erasing recipes till the end so that we don't invalidate the
+      // VPTypeAnalysis cache
+      ToErase.push_back(CurRecipe);
     }
-    recursivelyDeleteDeadRecipes(HeaderMask);
----------------
lukel97 wrote:

Some of the recipes are stores with zero values, but I was able to copy the trick from optimizeForVFAndUF where you erase the recipe and then call recursivelyDeleteDeadRecipes on its operands

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


More information about the llvm-commits mailing list