[all-commits] [llvm/llvm-project] 61df57: [mlir] Avoid rewriting unreachable blocks in the g...

Vijay Kandiah via All-commits all-commits at lists.llvm.org
Fri Sep 25 05:59:39 PDT 2026


  Branch: refs/heads/users/mamini/greedy-rewrite-reachability
  Home:   https://github.com/llvm/llvm-project
  Commit: 61df57bcd53cf40ead1aa29e07629a3993137b64
      https://github.com/llvm/llvm-project/commit/61df57bcd53cf40ead1aa29e07629a3993137b64
  Author: Vijay Kandiah <vkandiah at nvidia.com>
  Date:   2026-09-25 (Fri, 25 Sep 2026)

  Changed paths:
    M mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h
    M mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
    M mlir/test/Transforms/canonicalize-dce.mlir
    A mlir/test/Transforms/greedy-cfg-reachability.mlir
    M mlir/test/Transforms/test-strict-pattern-driver.mlir
    M mlir/test/lib/Dialect/Test/TestPatterns.cpp

  Log Message:
  -----------
  [mlir] Avoid rewriting unreachable blocks in the greedy driver

A rewrite can disconnect a block after the iteration's initial CFG sweep.
Track reachability through rewriter notifications and skip worklist
operations in unreachable blocks until the next iteration removes them.

Cache reachability per region and compare final successors after each
rewrite. Preserve the cache for successor-equivalent changes, added edges,
and block merges that keep surviving blocks reachable. Recompute for other
CFG changes, including entry changes and cross-region block moves.

Keep cache updates separate from reachability queries, returning failure
when a full traversal is required. Collect each successor set once for
validation and retain compact vector snapshots in the cache. Entry-block
queries return before cache lookup or CFG traversal.

Cover inserted and redirected blocks, blocks connected before rewrite
completion, nested regions, block moves and merges, and explicit op lists.
Use observer diagnostics to check whether affected operations are processed
within a single greedy iteration. Document that skipped operations are not
automatically retried if a later rewrite makes their block reachable, and
test that behavior in each strictness mode.

In the same Release build, canonicalizing 32,000 sibling single-block
regions took 22.7 ms with this commit versus 22.5 ms with the parent
driver. With 16,000 such regions containing folds, the times were 25.2 ms
and 24.0 ms, respectively. Nesting to 256 levels took 0.9 ms versus
0.8 ms.

On a synthetic CFG chain whose conditional branches have identical
successors, median CanonicalizerPass times with region simplification
disabled were 0.35, 0.7, 1.3, and 2.5 ms with the parent driver, versus
0.4, 0.7, 1.4, and 2.7 ms with this commit, for 500, 1,000, 2,000, and
4,000 blocks respectively. Both used the same Release build.

Assisted-by: Codex



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list