-
Notifications
You must be signed in to change notification settings - Fork 783
Optimize block tails where a dropped br_if's value is redundant #7506
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
Optimize block tails where a dropped br_if's value is redundant #7506
Conversation
Co-authored-by: Alon Zakai <alonzakai@gmail.com>
Thanks! Learned a lot from your comments and good coding taste. I've updated as you suggested. |
Avoid redundant constant Co-authored-by: Alon Zakai <alonzakai@gmail.com>
Co-authored-by: Alon Zakai <alonzakai@gmail.com>
Co-authored-by: Alon Zakai <alonzakai@gmail.com>
Co-authored-by: Alon Zakai <alonzakai@gmail.com>
Co-authored-by: Alon Zakai <alonzakai@gmail.com>
Co-authored-by: Alon Zakai <alonzakai@gmail.com>
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.
Looks good aside from two final comments. Also please fuzz this for a while.
Co-authored-by: Alon Zakai <alonzakai@gmail.com>
(Fixed) Bad news, the fuzzer told me that this PR aborts when dealing with the following wat code: (module
(rec
(type $0 (struct))
(type $1 (func (param funcref) (result (ref $0))))
(type $2 (func))
)
(func $0 (type $2)
(nop)
)
(func $1 (type $1) (param $0 funcref) (result (ref $0))
(block $block (result (ref $0))
(drop
(br_on_cast $block (ref $0) (ref $0)
(struct.new_default $0)
)
)
(struct.new_default $0)
)
)
(func $2 (type $2)
(drop
(call $1
(ref.func $0)
)
)
)
) Above code saved as Compile option: wasm-opt complains at
Obviously, the optimization meets all the condition and performs the update, however, the Fixed. Updated: I've fuzzing for one hour, all is well. |
Good, nice, this is exactly what the fuzzer is helpful with! |
After updating all you suggested, I've also fuzzing for about 15 minutes; and all is well. |
If a block ends with a
br_if
followed by a value that is the same as thebr_if
's value (and has no side effects), the value ofbr_if
andbr_if
itself are redundant and can be removed. For example:Fixes: #7489