Handle shifts by multiple of 32 correctly. Fixes #10887.