Open MaxGraey opened 3 years ago
Makes sense. This is the sort of pattern I hope to get optimized by DeadStoreElimination and extensions to it (store-load forwarding, etc.). That has begun in #3858
Is something blocking #3858 now? Or do you need to double-check everything more carefully?
It needs to be checked and reviewed carefully, and it's large - that's the main slowdown I think.
Actually, I wonder if maybe we can start with something simpler - this type of optimization in a single basic block should be easy to do. And likely it would give most of the benefit. We could extend it later to the whole CFG depending on how much is left. I'll look into that.
https://github.com/WebAssembly/binaryen/pull/4079 should help here.
Thanks!
4079 should help here.
Btw it make caching only for more that one global reads (usages), right? For single read it's unnecessary. If it's part of CSE I guess that's really going on but if it's handling somehow specially...
It looks for expressions that appear more than once. So it should not do anything for a single read (unless there's a bug).
This is a fairly common pattern, which looks suboptimal for performance:
will be great optimize to something like this which may optimize more in next passes:
Another similar case:
witch cache:
But usually this increase size