Add CSE pass to Slinky - #375
Conversation
This is a pretty direct port of Halide's CSE code to Slinky. Opening as draft because I want to do more testing before landing, but it's ready for comment.
|
I think this PR is in good state for what it actually does, but per offline discussion, it doesn't quite do enough in real-world work to pay for itself; it likely needs to be upgraded to handle cse'ing across Stmts where possible. |
| case intrinsic::semaphore_init: | ||
| case intrinsic::semaphore_signal: | ||
| case intrinsic::semaphore_wait: return false; | ||
| default: return true; |
There was a problem hiding this comment.
free, trace_begin, and trace_end aren't pure either
There was a problem hiding this comment.
Cool, will add
There was a problem hiding this comment.
It would be better to flip this around and return true when the intrinsic is pure and false otherwise. That way, when someone adds an intrinsic, and they forget to mark it as pure, the failure is lack of CSE, rather than likely very hard to find bugs.
|
|
||
| result = deshadow(result, ctx); | ||
| result = simplify(result); | ||
| result = common_subexpression_elimination(result, ctx); |
There was a problem hiding this comment.
I think we should put this after optimize_symbols below.
This reverts commit 0757597.
|
I reverted the change for now because the inefficient pass is indeed crazy-inefficient; we can't use a visitor to detect purity on-demand (it needs to be cached somehow). |
This is a pretty direct port of Halide's CSE code to Slinky. Opening as draft because I want to do more testing before landing, but it's ready for comment.