Stream: git-wasmtime

Topic: wasmtime / issue #5644 Rework the switch module in cranel...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2023 at 23:05):

jameysharp commented on issue #5644:

A couple of thoughts for future work, maybe:

If build_search_branches did the subtraction of first_index instead of doing it in build_jump_table, the icmp_imm_u128 checks there could always be tests against 0. For switch cases >= 2^64 I think that would reduce the number of CLIF instructions we generate, which isn't super important. More interestingly, I think we might be able to generate fewer machine instructions on some targets that way, although I'm not sure if we need better lowering rules or anything to fully take advantage.

We might generate better code by merging contiguous case ranges that have small gaps between them. We can insert branches to the "default" block into a combined jump-table with a code-size cost proportional to the size of the gap, which may be smaller than the size of the instructions needed to check which range to evaluate. So there's a potential code-size advantage, and as long as at least one of the ranges was going to generate a jump-table anyway, I think there's always an advantage in terms of number of instructions/branches executed.


Last updated: Dec 23 2024 at 12:05 UTC