-
Notifications
You must be signed in to change notification settings - Fork 199
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
Attempt SSA optimizations on zero-argument functions first #5839
Comments
@TomAFrench After running the
{
"equal()"=>10,
"less()"=>3,
"inner_1()"=>3,
"inner_2()"=>3,
"inner_3()"=>6,
"new()"=>72,
"none()"=>84,
"foo()"=>1,
"regression_2903()"=>3,
"regression_2906()"=>5,
"regression_4967()"=>5,
"test_iterators()"=>2744,
"test_mut_iterators()"=>4302,
"doc_tests()"=>7882,
"x5_5_config()"=>3390,
"regression_2255()"=>1,
"zero()"=>24,
"regression_4506()"=>17,
"one()"=>11,
"ALLOCATE_HASHMAP()"=>185,
"test_retain()"=>1143,
"zeroed()"=>21
} Out of 240 programs where Notes:
|
We can make this whole file |
It would be interesting to run this on aztec-packages as it's more representative of real world usage. |
Running the same script at the root of {
"get_instance()"=>176576,
"t_main()"=>1,
"tx_overhead()"=>12,
"empty()"=>12,
"new()"=>416
} |
Notes from manually reviewing SSA emitted from compiling the
b37185():
jmp b37186()
|
There were no changes to Brillig sized from result of running SSA passes on individual functions, so dropping the 0-arg SSA pass and keeping the |
# Description ## Problem\* ~Resolves #5839 Refactors passes that only act on individual functions into `impl Function { fn do_pass() }` ## Summary\* ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
Problem
Currently in Brillig, we inline functions but don’t do loop unrolling, so we are really constrained in terms of constant folding.
It seems likely that there are plenty of functions that could be constant-folded if we separated out a category that can be easily worked with, viz. zero-argument functions (with no foreign calls).
O(n)
savings for even a few arrays could be significantWhen we
optimize_into_acir
, we run all of the passes over all of the functions in one go.Happy Case
a. functions without arguments
b. functions reachable from (a)
c. the remaining functions
NOTE:
for function in self.functions {
Workaround
Yes
Workaround Description
Optimize by hand
Additional Context
No response
Project Impact
Nice-to-have
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: