-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(perf): Expand RC optimization pass to search return block for inc_rcs #6116
Conversation
… happen after simplifying cfg
Changes to Brillig bytecode sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
Hmm it does feel like marginal benefits for running this pass again. Although in general we can expand the scope of the RC opt pass, perhaps just not with this PR. I'll leave it up for comments though. This mainly removes paired inc/dec rc instructions on arrays returned from black boxes.
Where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benefits seem a bit marginal to me to add another SSA pass for it.
It'd be nice if we had timing metrics for the compiler itself so we could see exactly how much new compiler passes impact it.
Yeah I agree. I'm going to look at how I can continue to make the pass less conservative where it may justify running the pass again.
Agreed, that would definitely helpful info as we continue to update the SSA pass. |
Description
Problem*
Resolves #6088 (comment) (at least attempts to do so)
Part of general effort to lower Brillig bytecode sizes.
Summary*
inc/dec rc instructions take 3 brillig opcodes. We should look to remove unnecessary ones. The current RC opt pass is very conservative. This PR is an initial effort to expand the scope of the RC opt pass.
We currently only search for inc_rc instructions issued in the entry block. This greatly simplifies the pass as we do not have to account for inc/dec rc in loops. However, a simple low-hanging fruit would be to also search for inc_rc instructions in an exit block with a return terminator as we know that we are no longer in a loop after the exit block is executed.
I also updated the array sets scan to not just keep all inc rcs of the same type. Now we keep all rcs with an array set of the same type where rc instruction has the same value or the rc value comes from a function of block param.
I also moved the RC opt pass to happen after simplifying the cfg. After simplification we may have blocks that can be simplified into the return block for which we would not be catching these possible optimizations.
Additional Context
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.