On Dec 18, 2006, at 10:19 AM, Rask Ingemann Lambertsen wrote:
On Mon, Dec 18, 2006 at 03:19:19AM +0000, Paul Brook wrote:
Shifting >= the size of the value being shifted can and do give
nonzero
results on common hardware. Typically hardware will truncate the
shift count.
eg. x << 8 implemented with a QImode shift will give x, not 0.
This is not true on i386.
Ah, you're right:
"The count operand can be an immediate value or the CL register. The
count is masked to 5 bits (or 6 bits if in 64-bit mode and REX.W is
used). The count range is limited to 0 to 31 (or 63 if
64-bit mode and REX.W is used)."
Thus, the transformation is safe in this specific case on i386.
However, shifting a 32-bit value left by 33 bits would not be safe.
-Chris