binaryen
binaryen copied to clipboard
Simple/Local Dead Store Elimination
This begins to add dead store elimination to the optimizer. It provides the basic infrastructure, and implements simple and local DSE on top. All that can do so far is remove obviously-trampled stores inside a function. Future work will add whole-program analysis, and more things than just removing dead stores (like forwarding loads).
This does show how the single framework can handle multiple notions of "stores" and "loads". It uses almost the exact same code to optimize
- Globals:
global.set/get
- Memory:
*.store, *.load
- GC heap:
struct.set/get
This level of generality has some downsides to speed, but the simplicity is hopefully worth it, see details in comments.
This does not enable the pass by default. Until it is more powerful, there is little point, and also it will likely need to be tuned for speed (as it does not have a simple guarantee of running in linear time).
See: #3772
(added a small unreachability fix for a fuzzer issue)
@kripken Hi, is there any chance of merge with main branch? Or is something blocking this PR?
@MaxGraey The problem is that I haven't seen this help in a significant way on benchmarks. It would be significant work to get this done and landed, so I'm focusing on other things for now (like #4598).
Thanks! Yes, I did not expect serious performance improvements because Wasm engines (except interpreted ones) have similar optimization pass, but this pass in theory could improve module size, at least for some non-LLVM languages.