Stream: cranelift

Topic: When to use `subsume`?


view this post on Zulip Bongjun Jang (Nov 23 2025 at 11:05):

Hi, reading https://github.com/bytecodealliance/wasmtime/blob/68a6afd4f925724fd359c13a27fac5a6163d12f4/cranelift/codegen/src/opts/README.md,

I find it a little challenging to decide whether I should use subsume or not,
and I think it would be a good idea to clarify more on using subsumes.

It only says to use subsume when the rule discards values on LHS, and not to use it when it only discards constants. However, there are rules contradictory to the principle:

these rules only discard constants but use subsume:
https://github.com/bytecodealliance/wasmtime/blob/68a6afd4f925724fd359c13a27fac5a6163d12f4/cranelift/codegen/src/opts/arithmetic.isle#L7-L16

these rules use subsume does not discard any value on LHS:
https://github.com/bytecodealliance/wasmtime/blob/68a6afd4f925724fd359c13a27fac5a6163d12f4/cranelift/codegen/src/opts/arithmetic.isle#L34-L39

Thanks for reading!

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant - bytecodealliance/wasmtime
A lightweight WebAssembly runtime that is fast, secure, and standards-compliant - bytecodealliance/wasmtime
A lightweight WebAssembly runtime that is fast, secure, and standards-compliant - bytecodealliance/wasmtime

view this post on Zulip Chris Fallin (Nov 23 2025 at 19:39):

We have the "available locations" analysis now that makes rule 2 unnecessary there -- I should update that README, sorry!

view this post on Zulip Chris Fallin (Nov 23 2025 at 19:39):

In general, subsume is quite important for compilation performance (I have some data showing this I'll present at some point) but use of it is not necessary semantically. You can think of it as "I am so sure that this rewrite makes things better that you should always take it and discard the original"

view this post on Zulip Chris Fallin (Nov 23 2025 at 19:40):

so for example, with constant propagation we use it because it's always better to replace a dynamic ALU operation with a literal constant

view this post on Zulip Bongjun Jang (Nov 24 2025 at 06:31):

thanks!


Last updated: Dec 06 2025 at 07:03 UTC