Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Oct 28, 2025

A struct.get of a global, where the global creates a struct, can be
optimized by other passes, but not in all cases: Precompute can only
handle Literals (as it uses the interpreter), and GUFA works on a type-
based manner. The general case is important too, which looks like this:

;; Global struct, immutable.
(global $vtable (ref $vtable)
  (struct.new $vtable
    (global.get $imported)
  )
)

;; Code reads the global, then a field. This can be a read of $imported.
(struct.get $vtable 0
  (global.get $vtable)
)

This PR adds it to GlobalStructInference. That pass has a bunch of
useful infrastructure for it (parsing of struct.news, unnesting of values,
etc.), making it simple there.

Fixes #8002

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.

Missing simple store-to-load forward optimization for globals

1 participant