Skip to content

Cranelift: Remove istore{8,16,32} and {s,u}load{8,16,32} instructions - #14163

Open
fitzgen wants to merge 2 commits into
bytecodealliance:mainfrom
fitzgen:remove-narrow-and-extending-stores-and-loads
Open

Cranelift: Remove istore{8,16,32} and {s,u}load{8,16,32} instructions#14163
fitzgen wants to merge 2 commits into
bytecodealliance:mainfrom
fitzgen:remove-narrow-and-extending-stores-and-loads

Conversation

@fitzgen

@fitzgen fitzgen commented Aug 19, 2026

Copy link
Copy Markdown
Member

The former is identical to an ireduce followed by a regular store, and the
latter is identical to a regular load of the narrow width followed by an
extend. No need to have fused versions of these operations in CLIF, our lowering
backends can match on these patterns to generate the desired machine code just
fine.

Large diff, but it's mostly just golden test expectations.

Depends on #14162

Do not forward the value from a store at memory location `L` to a load of `L`
when the store was big endian and the load is little endian, or vice
versa. Similar for redundant-load elimination.

Note that dead-store elimination overwrites the same range of bytes in memory
regardless of byte order, so it can still happen when the dead store is big and
the overwriter is little or vice versa, so long as we update the memory state to
correctly record the overwriter's byte order.
…ions

The former is identical to an `ireduce` followed by a regular store, and the
latter is identical to a regular load of the narrow width followed by an
extend. No need to have fused versions of these operations in CLIF, our lowering
backends can match on these patterns to generate the desired machine code just
fine.

Large diff, but its mostly just golden test expectations.
@fitzgen
fitzgen requested review from a team as code owners August 19, 2026 18:16
@fitzgen
fitzgen requested review from cfallin and removed request for a team August 19, 2026 18:16
@alexcrichton

Copy link
Copy Markdown
Member

I have a vague recollection that in the past we attempted this and concluded that the increase in compile times and IR size meant that it wasn't worth the change, but I also can't seem to find that context now. Perhaps this'd be worth at least running through sightglass though?

@cfallin

cfallin commented Aug 19, 2026

Copy link
Copy Markdown
Member

I agree that this is a good simplification in principle but also want to make sure we minimize performance impact -- so +1 to a Sightglass run, but also skimming through the test expectations, I see at least a few cases (e.g., here) where load becomes a load+extend in machine code so we should make sure we have all the equivalent lowerings to re-fuse load+extend (and reduce+store).

@github-actions github-actions Bot added cranelift Issues related to the Cranelift code generator cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen cranelift:meta Everything related to the meta-language. labels Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen cranelift:meta Everything related to the meta-language. cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants