Stream: cranelift

Topic: Where do istore{8,16,32} come from?


view this post on Zulip Alex Crichton (May 31 2024 at 16:39):

I've personally always been a little perplexed by the istore* instructions in cranelift and and I also just ran into a bug on #8719 where I broke istore8 for example (I thought it took an 8-bit operand but apparently it takes a 16-64-bit operand). It's well-documented so this was just me missing the docs, but where does this instruction come from? I can't actually find anywhere in Cranelift that generates the instruction...

And perhaps orthogonally is this something that needs to be kept around nowadays? Or can the instructions be removed? (similar questions for uload8/sload8/friends)

This commit is similar to #8701 in that it adds a special case to store operations to use the zero register when applicable.

view this post on Zulip Chris Fallin (May 31 2024 at 16:42):

I wonder if these are artifacts of the earlier more direct approach to incremental rewriting from Wasm to machine code; they seem to correspond to Wasm's "I only deal in 32 bits but sure I'll load/store a byte for you" instructions

view this post on Zulip Chris Fallin (May 31 2024 at 16:42):

+1 to removing them if we don't use them in cranelift-wasm!

view this post on Zulip Chris Fallin (May 31 2024 at 16:42):

(or rewriting the latter to use extends/truncates if we do!)

view this post on Zulip Afonso Bordado (May 31 2024 at 16:42):

I think we had an issue filed to remove them, let me see if I can find it

view this post on Zulip Alex Crichton (May 31 2024 at 16:43):

Yeah that's what I figured their origins were from, but I'm still perplexed why tests broke when I broke the lowerings of the instructions because as far as I can tell nothing actually uses the instructions

view this post on Zulip Alex Crichton (May 31 2024 at 16:43):

oh I lied it's right there in the code translator

view this post on Zulip Alex Crichton (May 31 2024 at 16:43):

I was searching for "istore8" and turns out it's Istore8 in the translator

view this post on Zulip Alex Crichton (May 31 2024 at 16:43):

ok well that explains that

view this post on Zulip Afonso Bordado (May 31 2024 at 16:44):

https://github.com/bytecodealliance/wasmtime/issues/6056

Here it is

{u,s}load{8,16,32} these are all equivalent to load.i{8,16,32} followed by {u,s}extend. We should just use that larger sequence and backends that have special lowerings for uload8() that are better...

view this post on Zulip Alex Crichton (May 31 2024 at 16:44):

nice thanks


Last updated: Dec 23 2024 at 13:07 UTC