WebAssembly / WebAssembly/binaryen

LIFO order optimization?

Open
#2,458 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

Not sure about this, but I find out code like this:

...
let lo = (code >>> 10) | 0xD800;
let hi = (code & 0x03FF) | 0xDC00;
u32.store(codes + (j << 1), lo | (hi << 16));
...

produce smaller (less get/set for locals) output than

...
let lo = (code >>> 10) | 0xD800;
let hi = (code & 0x03FF) | 0xDC00;
u32.store(codes + (j << 1), (hi << 16) | lo);
...

It seems will be great have pass which could reorder local assignments (hi, lo) or reorder arguments in expressions if this possible in LIFO style

Unfortunately I can't reproduce this in small example it seems we should have some extra factors so link to before/after diff

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the before/after diff linked in the issue and investigate whether the observed output difference is caused by local-assignment or expression ordering. Reproduce the larger example that shows the effect, then determine whether a LIFO-style reordering pass is feasible and define tests demonstrating smaller output without changing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, wasm
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.