4 ms·
That is, compile an array access a[i] into an array of size N as a[i&M] where M is one less than the next power of two larger than N. Doesn't that still permit
by danieldk 9y ago
That is, compile an array access a[i] into an array of size N as a[i&M] where M is one less than the next power of two larger than N.
Doesn't that still permit speculatively getting an out-of-bound element, where the problem gets worse with larger arrays?
The following LWN article describes a more sophisticated masking approach by Alexei Starovoitov:
https://lwn.net/Articles/744287/ https://lwn.net/Articles/744287/
Of course, the same question still applies: why not use this cheaper masking approach. Are there known problems with it?