Avoid undefined behavior by masking the shift amount.

Should hopefully fix the mips bots.