WebAssembly / WebAssembly/binaryen

wasm-opt: Optimize out store of load with traps-never-happen

Open
#5,118 4 comments 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

Such WebAssembly code snippet will not be optimized by wasm-opt

    (local $var i32)
    ...
    local.tee $var
    local.get $var
    i32.load
    i32.store

However, this equals

*var = *var

which is safe to remove.

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 with wasm-opt and reproduce the provided local.tee/local.get, i32.load, and i32.store pattern under the traps-never-happen assumption. Trace the optimization behavior for this sequence and add a regression check; done means wasm-opt removes the redundant store while preserving the intended result.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.