Global store-to-load forwarding
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 46/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- wasm
- Domain
- compilers, performance
Research direction
Start by unpacking repro.tar.gz and running the provided wasm-opt command with the listed feature flags. Compare the resulting WAT with the requested transformations and read related issues 8016 and 8002. Done means the immutable global and struct-field loads are forwarded to the shown constants and imported global without changing behavior.
Written by the indexing model from the issue text.
Description
This is similar to https://github.com/WebAssembly/binaryen/issues/8016 & https://github.com/WebAssembly/binaryen/issues/8002
See this repro.tar.gz. The optimized version was obtained via open world compilation
% wasm-opt \
--enable-gc --enable-reference-types --enable-multivalue --enable-exception-handling --enable-nontrapping-float-to-int \
--enable-sign-ext --enable-bulk-memory --enable-threads \
--enable-simd '--no-inline=*<noInline>*' --traps-never-happen \
-g -Os -Os -Os \
repro.wasm -o repro.opt.wasm
It leaves the following behind
(type $JSExternWrapper (sub $Object (struct
(field $field0 i32)
(field $field1 (mut i32))
(field $_externRef externref))))
(global $.a (import "" "a") (ref extern))
(global $"C284 \"a\"" (ref $JSExternWrapper) (i32.const 97) (i32.const 0) (global.get $.a) (struct.new $JSExternWrapper))
(func $"findExact <noInline>" (param $var0 (ref $JSExternWrapper)) (result i64)
(local $var1 (ref $JSExternWrapper))
block $label0
block $label1
block $label2
block $label3 (result i32)
block $label4
global.get $"C284 \"a\""
local.tee $var1
struct.get $JSExternWrapper $field0
i32.const 97
i32.ne
br_if $label4
local.get $var0
struct.get $JSExternWrapper $_externRef
local.get $var1
struct.get $JSExternWrapper $_externRef
call $"wasm:js-string.equals (import)"
i32.eqz
br_if $label4
i32.const 1
br $label3
end $label4
i32.const 0
end $label3
i32.eqz
Notice that the
$C284global is a non mutable global with known values being initialized$JSExternWrapper.$field0is a non mutablei32field
Therefore the
global.get $"C284 \"a\""
local.tee $var1
struct.get $JSExternWrapper $field0
should be turned into
i32.const 97
and the
local.get $var1
struct.get $JSExternWrapper $_externRef
should be turned into
global.get $.a
- Dominant language
- WebAssembly
- Stars
- 8.6k
- Forks
- 885
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 70
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WebAssembly/binaryen
-
Difficulty 2/5 Half a day Newbie friendliness 76/100
WebAssembly/binaryen#9018 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
WebAssembly/binaryen#9123 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WebAssembly/binaryen#9122 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
WebAssembly/binaryen#9086 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
WebAssembly/binaryen#9038 · 5 comments ·
All issues in WebAssembly/binaryen
Similar issues
-
compiler/runtime
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
objectionary/eo#8869 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
EricSpencer00/Resilient#4824 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/jeo-maven-plugin#1758 ·
-
generics
Difficulty 2/5 1-3 hours Newbie friendliness 82/100