[llvm] [VPlan] Use RPOT in CSE, fixing potential crash (PR #187548)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 02:15:59 PDT 2026


================
@@ -2630,8 +2630,9 @@ void VPlanTransforms::cse(VPlan &Plan) {
   VPDominatorTree VPDT(Plan);
   DenseMap<VPSingleDefRecipe *, VPSingleDefRecipe *, VPCSEDenseMapInfo> CSEMap;
 
-  for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
-           vp_depth_first_deep(Plan.getEntry()))) {
+  ReversePostOrderTraversal<VPBlockDeepTraversalWrapper<VPBlockBase *>> RPOT(
+      Plan.getEntry());
----------------
lukel97 wrote:

It would be nice to have `vp_rpot_{deep,shallow}` helpers to match `vp_depth_first_{deep,shallow}`. Maybe something for another PR?

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


More information about the llvm-commits mailing list