Skip to content

[REFACTOR][TIR][ARITH] Phase out ControlFlowGraph, NarrowPredicateExpression, and rename Simplify to StmtSimplify#19604

Merged
spectrometerHBH merged 4 commits into
apache:mainfrom
tqchen:tvm-cleanup-simplification
May 26, 2026
Merged

[REFACTOR][TIR][ARITH] Phase out ControlFlowGraph, NarrowPredicateExpression, and rename Simplify to StmtSimplify#19604
spectrometerHBH merged 4 commits into
apache:mainfrom
tqchen:tvm-cleanup-simplification

Conversation

@tqchen

@tqchen tqchen commented May 25, 2026

Copy link
Copy Markdown
Member

Summary

This PR cleans up technical debt in the TIR simplification machinery via two commits:

Commit 1: Phase out ControlFlowGraph and NarrowPredicateExpression

  • Remove ControlFlowGraph (~2360 lines) from src/tirx/analysis/ — used only in
    non-default config paths that are no longer maintained
  • Remove NarrowPredicateExpression from src/arith/ — sole non-test caller was ControlFlowGraph
  • Remove gated config fields propagate_knowns_to_prove_conditional and
    propagate_knowns_to_simplify_expressions from SimplifyConfig
  • Remove use_dataflow_analysis from RemoveNoOpConfig
  • Delete the associated test files and test cases that tested the now-removed paths
  • ~3800 lines deleted

Commit 2: Rename Simplify → StmtSimplify

  • Rename src/tirx/transform/simplify.{h,cc}stmt_simplify.{h,cc}
  • Rename C++ identifiers: SimplifyStmtSimplify, SimplifyConfigStmtSimplifyConfig
  • Rename FFI keys: "tirx.Simplify""tirx.StmtSimplify", "tirx.transform.Simplify""tirx.transform.StmtSimplify"
  • Update Python wrappers and all call sites (~40 files)
  • Clarifies that this pass operates on statements (distinct from expression-level arith::Analyzer::Simplify())

Test plan

  • tests/python/tirx-transform/test_tir_transform_simplify.py — 52 tests pass
  • tests/python/tirx-transform/test_tir_transform_remove_no_op.py — 18 pass, 5 xfail
  • tests/python/arith/ — full arith test suite passes
  • tests/python/tirx-transform/ — full suite: 315 passed, 8 xfailed, 1 xpassed (pre-existing vectorize failure unrelated to this change)
  • pre-commit run --all-files — all hooks pass

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the dataflow analysis functionality from the TIR simplification and no-op removal passes. Specifically, it deletes the ControlFlowGraph and NarrowPredicateExpression utilities, removes the use_dataflow_analysis configuration option, and renames the Simplify pass to StmtSimplify to reflect its statement-level scope. The review comments identify a minor grammatical typo in a docstring in stmt_simplify.cc and suggest updating a test docstring in test_tir_transform_remove_no_op.py to clarify that dataflow analysis is no longer supported.

Comment thread src/tirx/transform/stmt_simplify.cc
Comment thread tests/python/tirx-transform/test_tir_transform_remove_no_op.py Outdated
tqchen added a commit to tqchen/tvm that referenced this pull request May 25, 2026
…lize_device_passes

The bare `tir.transform.X()` form in s_tir/pipeline.py
finalize_device_passes() resolved at runtime to tvm.tirx.transform,
but the post-rename module no longer exposes Simplify (it's
StmtSimplify). Without this fix, calling finalize_device_passes()
raises AttributeError. The CI suite did not exercise this code path,
so the regression slipped through PR apache#19604.

Switch all four lines to use the explicit `tirx.transform` form
(already imported) and rename Simplify → StmtSimplify.
tqchen added 4 commits May 26, 2026 14:08
…Expression

All production callers of ControlFlowGraph are gated by config flags
(propagate_knowns_to_prove_conditional, propagate_knowns_to_simplify_expressions
in SimplifyConfig; use_dataflow_analysis in RemoveNoOpConfig) that no
standard lowering pipeline turns on. The dataflow-analysis path is
effectively dead code in practice.

Remove ControlFlowGraph and its sole dependent NarrowPredicateExpression
entirely. Drop the config flags and their associated code paths from
StmtSimplifier and NoOpRemover. The remaining simplification logic
(transitively_prove_inequalities, convert_boolean_to_and_of_ors,
apply_constraints_to_boolean_branches, max_simplification_steps) is
unaffected. Delete the tests that exercised the removed paths.
Rename clarifies that this is statement-level simplification (distinct from
expression-level arithmetic simplifiers in src/arith/). The file names
simplify.{h,cc} become stmt_simplify.{h,cc}, and all associated C++ types,
free functions, pass functions, and FFI keys are renamed accordingly:
tirx::Simplify -> tirx::StmtSimplify, tirx::transform::Simplify ->
tirx::transform::StmtSimplify, SimplifyConfig -> StmtSimplifyConfig.
Python wrappers and all call sites are updated to match.
Fix grammatical typo in apply_constraints_to_boolean_branches docstring
and update the remove_no_op test docstring to reflect that
dataflow-analysis is no longer a supported option (rather than just
"not used here").
…lize_device_passes

The bare `tir.transform.X()` form in s_tir/pipeline.py
finalize_device_passes() resolved at runtime to tvm.tirx.transform,
but the post-rename module no longer exposes Simplify (it's
StmtSimplify). Without this fix, calling finalize_device_passes()
raises AttributeError. The CI suite did not exercise this code path,
so the regression slipped through PR apache#19604.

Switch all four lines to use the explicit `tirx.transform` form
(already imported) and rename Simplify → StmtSimplify.
@tqchen tqchen force-pushed the tvm-cleanup-simplification branch from 0ccd4da to 0580136 Compare May 26, 2026 14:17
@spectrometerHBH spectrometerHBH merged commit 02b1302 into apache:main May 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants