-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Make fixed-size table base-address loads read-only #8200
Description
Feature
When a WebAssembly table is declared with a maximum size that equals its minimum size, we should be able to GVN the table's base address, and also hoist loads of the base address out of loops.
Benefit
Any time there is a sequence of table accesses (table.get, table.set, call_indirect) or a loop of such, this would allow us to remove all the base-address loads after the first one, as well as subsequent address computations for instructions which access the same table element.
Implementation
The egraph pass will optimize this for us as long as we add the readonly flag to those loads, but that's only safe if we know that the storage for the table won't be reallocated. We can be sure of that if the table can't grow because its size is fixed.
Alternatives
No alternatives besides keeping things as they are.
cc: @cfallin