LICM pass stopped working
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript, wasm
- Domain
- compilers
Research direction
Start with the minimal TypeScript loop example and compare its unoptimized and optimized WAT output, then inspect the LICM pass and the changes referenced in #4059, #4077, and #4076. Done means the load is safely hoisted before the loop and the optimized output matches the expected WAT behavior.
Written by the indexing model from the issue text.
Description
After some of this changes: #4059 or #4077 or #4076
LICM pass stopped working.
Here minimal example:
export function loop1(n: i32, ptr: usize): void {
let acc = 0;
for (let i = 0; i < n; i++) {
acc += load<i32>(ptr);
}
}
Unoptimized version (original):
(module
(type $i32_i32_=>_none (func (param i32 i32)))
(memory $0 0)
(export "loop1" (func $loop-test/loop1))
(export "memory" (memory $0))
(func $loop-test/loop1 (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
i32.const 0
local.set $2
i32.const 0
local.set $3
loop $for-loop|0
local.get $3
local.get $0
i32.lt_s
local.set $4
local.get $4
if
local.get $2
local.get $1
i32.load
i32.add
local.set $2
local.get $3
i32.const 1
i32.add
local.set $3
br $for-loop|0
end
end
)
)
Optimized:
(module
(type $i32_i32_=>_none (func (param i32 i32)))
(memory $0 0)
(export "loop1" (func $loop-test/loop1))
(export "memory" (memory $0))
(func $loop-test/loop1 (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
loop $for-loop|0
local.get $0
local.get $2
i32.gt_s
if
local.get $1
i32.load
local.get $3
i32.add
local.set $3
local.get $2
i32.const 1
i32.add
local.set $2
br $for-loop|0
end
end
)
)
Expected:
(module
(type $i32_i32_=>_none (func (param i32 i32)))
(memory $0 0)
(export "loop1" (func $module/loop1))
(export "memory" (memory $0))
(func $module/loop1 (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
local.get $1
i32.load
local.set $1
loop $for-loop|0
local.get $0
local.get $2
i32.gt_s
if
local.get $1
local.get $3
i32.add
local.set $3
local.get $2
i32.const 1
i32.add
local.set $2
br $for-loop|0
end
end
)
)
- 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