Aiken UPLC Optimization overhaul (#1052)
* Refactor and structuring optimizations to be less computationally heavy * Forgot to commit the new file containing the optimization do over * Point to correct functions in shrinker2 * Split out inline_constr_ops since it adds in builtins that can then be swept up by the builtin force reduction * Fix: issue where identity reducer was always returning true * Forward inlining on lambdas produces better results. This is due to a forward pass being able to apply an argument that may have no_inline at the top where as vice-versa would reduce the arg first. * Clippy and test fixes * Clear no_inlines when inlining a function * Convert shrinker2 to replace shrinker and update tests
This commit is contained in:
@@ -4,25 +4,39 @@ pub mod interner;
|
||||
pub mod shrinker;
|
||||
|
||||
pub fn aiken_optimize_and_intern(program: Program<Name>) -> Program<Name> {
|
||||
program
|
||||
.inline_constr_ops()
|
||||
.bls381_compressor()
|
||||
.builtin_force_reducer()
|
||||
.lambda_reducer()
|
||||
.inline_reducer()
|
||||
.identity_reducer()
|
||||
.lambda_reducer()
|
||||
.inline_reducer()
|
||||
.force_delay_reducer()
|
||||
.cast_data_reducer()
|
||||
.builtin_eval_reducer()
|
||||
.convert_arithmetic_ops()
|
||||
let mut prog = program.run_once_pass();
|
||||
|
||||
let mut prev_count = 0;
|
||||
|
||||
loop {
|
||||
let (current_program, context) = prog.multi_pass();
|
||||
|
||||
if context.node_count == prev_count {
|
||||
prog = current_program;
|
||||
break;
|
||||
} else {
|
||||
prog = current_program;
|
||||
prev_count = context.node_count;
|
||||
}
|
||||
}
|
||||
|
||||
prog = prog
|
||||
.builtin_curry_reducer()
|
||||
.lambda_reducer()
|
||||
.inline_reducer()
|
||||
.identity_reducer()
|
||||
.builtin_curry_reducer()
|
||||
.lambda_reducer()
|
||||
.inline_reducer()
|
||||
.remove_no_inlines()
|
||||
.multi_pass()
|
||||
.0
|
||||
.builtin_curry_reducer();
|
||||
|
||||
loop {
|
||||
let (current_program, context) = prog.multi_pass();
|
||||
|
||||
if context.node_count == prev_count {
|
||||
prog = current_program;
|
||||
break;
|
||||
} else {
|
||||
prog = current_program;
|
||||
prev_count = context.node_count;
|
||||
}
|
||||
}
|
||||
|
||||
prog.clean_up()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user