[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (work1) now available
- From: Mike Pall <mikelu-1001@...>
- Date: Thu, 14 Jan 2010 23:20:09 +0100
Doug Rogers wrote:
> I'll need to go back and read your original reasoning on (*) 'Shift
> counts should be masked by the bit width', because I would think the
> masking should occur only for rotates. For shifts, the return value of a
> overshift should be zero (or all ones, a.k.a. -1 according to the
> Summary, for a sign-extended right shift with a sign bit of one).
Just check your own code base for usage examples of bit shifts.
I've used shift count masking more often than any other specific
treatment (whether in C or Assembler or Lua).
The masking behavior makes sense for *both* shifts and rotates.
And it doesn't need a special case for arithmetic right shift.
On some CPUs (e.g. x86) the mask operation can even be optimized
away by the C compiler or a Lua compiler. And as I've mentioned,
it doesn't need a branch ...
--Mike