Skip to content

Conversation

@abadams
Copy link
Member

@abadams abadams commented Jul 17, 2023

This pass called expr_uses_var in a loop while building up a potentially long let chain. This does a quadratic amount of work in the size of the let chain, which stalled compilation for a particular pathological pipeline I encountered.

This changes it to an eager algorithm that tracks the set of free variables and incrementally grows it instead of revisiting the entire expr for each new let added. It is n log(n) in the number of lets instead of n^2

This pass called expr_uses_var in a loop while building up a potentially
long let chain. This does a quadratic amount of work in the size of the
let chain, which stalled compilation for a particular pathological
pipeline I encountered.

This changes it to an eager algorithm that tracks the set of free
variables and incrementally grows it instead of revisiting the entire
expr for each new let added. It is n log(n) in the number of lets
instead of n^2
@steven-johnson
Copy link
Contributor

asan failure should be addressed by #7687

@abadams
Copy link
Member Author

abadams commented Jul 19, 2023

Failures unrelated

@abadams abadams merged commit 0112da4 into main Jul 19, 2023
@steven-johnson steven-johnson deleted the abadams/fix_quadratic_simplify_correlated_differences branch July 19, 2023 18:30
ardier pushed a commit to ardier/Halide-mutation that referenced this pull request Mar 3, 2024
This pass called expr_uses_var in a loop while building up a potentially
long let chain. This does a quadratic amount of work in the size of the
let chain, which stalled compilation for a particular pathological
pipeline I encountered.

This changes it to an eager algorithm that tracks the set of free
variables and incrementally grows it instead of revisiting the entire
expr for each new let added. It is n log(n) in the number of lets
instead of n^2

Co-authored-by: Steven Johnson <[email protected]>
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.

4 participants