So far we have been using sequences of br_ifs to hint to Binaryen that these might be suitable candidates for a br_table if conditions are dense constants potentially. While this works well, there are occasions where it is easier / more idiomatic to emit sequences of normal ifs, either manually or using the Reloopers addBranch, but these don't benefit from RemoveUnusedBrs's tablify. Typical code is:
(local.set $0 (...))
(if
(i32.or
(i32.or
(i32.eq
(local.get $0)
(i32.const 1)
)
(i32.eq
(local.get $0)
(i32.const 2)
)
)
(i32.eq
(local.get $0)
(i32.const 3)
)
)
(if
...
(call ...)
)
(call ...) ;; or unreachable
)
or
(local.set $0 (...))
(if
(i32.or
(i32.or
(i32.eq
(local.get $0)
(i32.const 1)
)
(i32.eq
(local.get $0)
(i32.const 2)
)
)
(i32.eq
(local.get $0)
(i32.const 3)
)
)
(return
(call ...)
)
)
(if
...
(return
(call ...)
)
)
(call ...) ;; or unreachable
where at some point converting to a br_table seems to become more efficient.
So far we have been using sequences of
br_ifs to hint to Binaryen that these might be suitable candidates for abr_tableif conditions are dense constants potentially. While this works well, there are occasions where it is easier / more idiomatic to emit sequences of normalifs, either manually or using theReloopersaddBranch, but these don't benefit from RemoveUnusedBrs's tablify. Typical code is:or
where at some point converting to a
br_tableseems to become more efficient.