Stream: git-wasmtime

Topic: wasmtime / PR #12135 Cranelift: Remove redundant select +...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 07 2025 at 19:48):

jameshu15869 opened PR #12135 from claby2:main to bytecodealliance:main:

Collaborators: @claby2 @bisheshank

Cranelift may generate code where a select followed by an icmp can be directly substituted with the select instruction's condition. Specifically, we can perform this optimization when we encounter code of the form

...
v1 = select v0, k1, k2
v2 = icmp eq v1, k1
...

Here, we can optimize to v2 = v0 given that k1 and k2 are constants.

In the language of the example above, this PR handles icmp eq and icmp ne when k1 or k2 are the icmp condition. We use the ISLE rewrite icmp ne x 0 as a "cast" to handle the case where the inner condition of the select is not restricted to 0 or 1 (See non_icmp_inner in issue-11578-semantics.clif)

Fixes #11578

view this post on Zulip Wasmtime GitHub notifications bot (Dec 07 2025 at 19:48):

jameshu15869 requested wasmtime-compiler-reviewers for a review on PR #12135.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 07 2025 at 19:48):

jameshu15869 requested cfallin for a review on PR #12135.


Last updated: Dec 13 2025 at 19:03 UTC