diff options
author | Alon Zakai <azakai@google.com> | 2024-08-14 10:45:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-14 10:45:01 -0700 |
commit | 39553a0247eb39c2f58c883cd6fb6b7e00f559ad (patch) | |
tree | 13a422451627b4011e2963c1b1e6304fa65421f5 /scripts | |
parent | 0c84afe87ea67239c4d7bf885b43b5c4f52322af (diff) | |
download | binaryen-39553a0247eb39c2f58c883cd6fb6b7e00f559ad.tar.gz binaryen-39553a0247eb39c2f58c883cd6fb6b7e00f559ad.tar.bz2 binaryen-39553a0247eb39c2f58c883cd6fb6b7e00f559ad.zip |
Monomorphization: Add a flag to control the required improvement (#6837)
The argument is the minimum benefit we must see for us to decide to optimize, e.g.
--monomorphize --pass-arg=monomorphize-min-benefit@50
When the minimum benefit is 50% then if we reduce the cost by 50% through
monomorphization then we optimize there. 95% would only optimize when we
remove almost all the cost, etc.
In practice I see 95% will actually tend to reduce code size overall, as while we add
monomorphized versions of functions, we only do so when we remove a lot of
work and size, and after inlining we gain benefits. However, 50% or even lower can
lead to better benchmark results, in return for larger code size, just like with
inlining. To be careful, the default is set to 95%.
Previously we optimized whenever we saw any benefit at all, which is the same
as requiring a minimum benefit of 0%. Old tests have the flag applied in this PR
to set that value, so they do not change.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/fuzz_opt.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index a4adb7b79..4087abed1 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -1566,7 +1566,10 @@ opt_choices = [ ("--memory-packing",), ("--merge-blocks",), ('--merge-locals',), - ('--monomorphize',), + # test a few monomorphization levels, and also -always + ('--monomorphize', '--pass-arg=monomorphize-min-benefit@0'), + ('--monomorphize', '--pass-arg=monomorphize-min-benefit@50'), + ('--monomorphize', '--pass-arg=monomorphize-min-benefit@95'), ('--monomorphize-always',), ('--no-stack-ir',), ('--once-reduction',), |