Skip to content

mem: add an immediate offset to Load/Store ops.#44

Draft
eddyb wants to merge 7 commits intoeddyb/vectorfrom
eddyb/qptr-imm-offsets
Draft

mem: add an immediate offset to Load/Store ops.#44
eddyb wants to merge 7 commits intoeddyb/vectorfrom
eddyb/qptr-imm-offsets

Conversation

@eddyb
Copy link
Copy Markdown
Member

@eddyb eddyb commented Apr 27, 2026

Note: this PR is a draft to avoid accidental merging onto its "base" branch (used as a form of ad-hoc PR stacking), and will remain as such, until its "base" branch can be set to main, i.e. all prerequisite PRs will have landed, up to and including this PR (whose branch is the "base" of this one):


Originally submitted as (description mostly copied from there):


While separate offseting works fine in general, having an immediate offset inside loads and stores (as this PR adds) can make the simplest case (i.e. no array indexing or buffers - especially local variables) easier.

There's two usecases that motivated this change:

  • qptr::lower support for Disaggregate by-value OpTypeStruct/OpTypeArray inputs/outputs. #45
    • specifically, one Op{Load,Store} would need to turn into N MemOp::{Load,Store} (one per aggregate leaf), and needing N QPtrOp::Offsets as well would be an annoying drawback
  • I'm considering a simple alternative to LLVM-style mem2reg+SROA, which specifically only propagates stores to loads, within local variables, and treats all other uses of the local variable base pointer as "escaping" (i.e. the contents of the variable can't be known anymore)

TODO: changelog, maybe a comparison example (kinda hard tho).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant