Repository navigation
Avoid exponential simplification when merging conditional boxes - #9661
Conversation
Preserve expression sharing with CSE before simplifying conditional bounds, and add standalone regression tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Have you tested this PR for performance regressions against the apps? CSE has a way of hiding necessary structure from the simplifier. We really should have a bounds inference fuzzer... |
Yes, that's what triggered this ... generators in 22.0.0-dev444 that used to take 10-30sec started timing out after 1000's of seconds. Runtime with this fix was the same before the regression got introduced, but testing has only been on my own apps. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9661 +/- ##
==========================================
+ Coverage 72.91% 73.01% +0.10%
==========================================
Files 266 266
Lines 83341 83345 +4
Branches 20468 20470 +2
==========================================
+ Hits 60765 60855 +90
+ Misses 16156 16129 -27
+ Partials 6420 6361 -59 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Just to confirm: that's the runtime performance of the app, not compilation time, right? |
Correct. I couldn't find a workaround outside of the compiler that didn't introduce a significant runtime performance regression. This PR avoids the compilation time, without impacting the original runtime performance for my specific test cases. |
Summary
Conditional box unions reference previous min/max expressions multiple times.
Across nested specializations, simplification repeatedly traverses the shared
expression DAG as an expanded tree, causing exponential compile-time growth.
Run expression CSE before simplifying conditional min/max bounds so repeated
expressions remain shared through Let bindings.
The union formulas, used predicates, infinity handling, and unconditional
merge path are unchanged.
Regression tests
conditional_box_merge: compiler-level reproducer with semantic checks.bounds_inference_specialized_spans: public-API pipeline reproducer withspecialization-dependent RDom bounds and an independent pixel oracle.
Both tests have a 60-second timeout.
Validation
The two new regressions and
bounds_internalwere run on this branch usingHalide's
ci-llvm-22toolchain.Initial verification against Halide v22.1.0 with LLVM 21.1.8:
Full upstream, cross-platform, and GPU suites have not been run.
Supersedes #9660 to use the corrected branch name.