[llvm] [SPIR-V] Avoid exponential path enumeration in findPathsToMatch (PR #212933)

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 04:57:03 PDT 2026


================
@@ -213,29 +214,52 @@ class ConvergenceRegionAnalyzer {
   SmallPtrSet<BasicBlock *, 0>
   findPathsToMatch(LoopInfo &LI, BasicBlock *From,
                    std::function<bool(const BasicBlock *)> isMatch) const {
-    SmallPtrSet<BasicBlock *, 0> Output;
-
-    if (isMatch(From))
-      Output.insert(From);
+    // Compute the postorder of the blocks forward-reachable from |From|,
+    // ignoring back edges. Successors therefore always appear before their
+    // predecessors in the resulting list.
+    SmallVector<BasicBlock *, 16> PostOrder;
----------------
jmmartinez wrote:

Could the iterators from `llvm/ADT/PostOrderIterator.h` help with this ?

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


More information about the llvm-commits mailing list