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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 6 06:49:32 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())))
----------------
fhahn wrote:

Eventually yes, for now I don't think we ever form BranchOnConds on false

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


More information about the llvm-commits mailing list