Optimize block tails where a dropped br_if's value is redundant#7506
Optimize block tails where a dropped br_if's value is redundant#7506kripken merged 25 commits intoWebAssembly:mainfrom
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>
kripken
left a comment
There was a problem hiding this comment.
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_iffollowed by a value that is the same as thebr_if's value (and has no side effects), the value ofbr_ifandbr_ifitself are redundant and can be removed. For example:Fixes: #7489