search for: rotateinloop

Displaying 2 results from an estimated 2 matches for "rotateinloop".

2018 May 14
5
Rotates, once again
...31)) but this is a substantially more complicated sub-dag than the OR of two shifts you would see for a compile-time constant rotate distance, and there are more opportunities for things to go wrong along the way. Bug 37387 contains a few examples, the simplest of which was given by Sanjay: void rotateInLoop(unsigned *x, unsigned N, unsigned *a, int b) { for (unsigned i = 0; i < N; ++i) x[ (a[i] >> b) | (a[i] << (32 - b)) ] = i; // shift amt is loop invariant } "32 - b" is loop-invariant and gets hoisted, and what's left of the expression doesn't match a known &q...
2018 May 15
0
Rotates, once again
...tantially more complicated sub-dag than the OR of two > shifts you would see for a compile-time constant rotate distance, and there > are more opportunities for things to go wrong along the way. Bug 37387 > contains a few examples, the simplest of which was given by Sanjay: > > void rotateInLoop(unsigned *x, unsigned N, unsigned *a, int b) { > for (unsigned i = 0; i < N; ++i) > x[ (a[i] >> b) | (a[i] << (32 - b)) ] = i; // shift amt is loop > invariant > } > > "32 - b" is loop-invariant and gets hoisted, and what's left of the > expre...