[llvm] [VPlan] Add initial CFG simplification, removing BranchOnCond true. (PR #106748)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 05:35:41 PDT 2024


================
@@ -1124,6 +1124,49 @@ void VPlanTransforms::truncateToMinimalBitwidths(
          "some entries in MinBWs haven't been processed");
 }
 
+/// Remove BranchOnCond recipes with constant conditions together with removing
+/// dead edges to their successors. Remove blocks that become dead (no remaining
+/// predecessors())
+static void simplifyCFG(VPlan &Plan) {
+  using namespace llvm::VPlanPatternMatch;
+  SmallVector<VPBasicBlock *> WorkList;
+  for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
+           vp_depth_first_deep(Plan.getEntry()))) {
+    VPRecipeBase *Term = VPBB->getTerminator();
+    if (!Term || !match(Term, m_BranchOnCond(m_True())))
----------------
david-arm wrote:

Should we also be looking for `m_BranchOnCond(m_False())`?

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


More information about the llvm-commits mailing list