Stream: git-wasmtime

Topic: wasmtime / issue #1052 Optimize bitreverse using rotate i...


view this post on Zulip Wasmtime GitHub notifications bot (May 04 2022 at 20:54):

cfallin labeled issue #1052:

The bitreverse seqences in lib/codegen/meta-python/base/legalize.py all end with two shifts and a bitwise or that effectively swap the low half of the value and the high half:
https://github.com/CraneStation/cranelift/blob/master/lib/codegen/meta-python/base/legalize.py#L445
https://github.com/CraneStation/cranelift/blob/master/lib/codegen/meta-python/base/legalize.py#L475
and others for the other types

It would be better to replace these trailing sequences with rotl_imm.

That change is the first step, however the catch is that rotl_imm isn't implemented in isel yet so we'll need to implement that too. See the encodings for shifts and non-imm rotates as well as the encodings for imm shifts for some examples.

Of course, in the future Cranelift is expected to have a pattern-matching optimization which would automatically optimize shift+bor sequences into rotates, however it doesn't have one right now, and even when it does, it would make the code simpler to just use rotate, and it's more efficient to just use the instruction we want than to emit sequences of instructions that we know will end up getting replaced.

view this post on Zulip Wasmtime GitHub notifications bot (May 04 2022 at 20:54):

cfallin commented on issue #1052:

Marking this as x64-specific; we use the bitrev instruction in the aarch64 backend.


Last updated: Nov 22 2024 at 17:03 UTC