On 06/09/2011 03:45 AM, Kirill Batuzov wrote: > + case INDEX_op_shl_i32: > +#if TCG_TARGET_REG_BITS == 64 > + y &= 0xffffffff; > + case INDEX_op_shl_i64: > +#endif > + return x << y; > + > + case INDEX_op_shr_i32: > +#if TCG_TARGET_REG_BITS == 64 > + x &= 0xffffffff; > + y &= 0xffffffff; > + case INDEX_op_shr_i64: > +#endif > + /* Assuming TCGArg to be unsigned */ > + return x >> y;
Don't assume when you've got a uint64_t type readily available. > + case INDEX_op_sar_i32: > +#if TCG_TARGET_REG_BITS == 64 > + x &= 0xffffffff; > + y &= 0xffffffff; > +#endif > + return (int32_t)x >> (int32_t)y; Masks are redundant with the casts. > + case INDEX_op_rotr_i32: > +#if TCG_TARGET_REG_BITS == 64 > + x &= 0xffffffff; > + y &= 0xffffffff; > +#endif > + x = (x << (32 - y)) | (x >> y); Have you looked to see if this gets recognized as a rotate by the compiler? I suspect that it will if you use a cast to uint32_t here, but not if it is left as a 64-bit TCGArg. > +#if TCG_TARGET_REG_BITS == 64 > + case INDEX_op_rotl_i64: > + x = (x << y) | (x >> (64 - y)); > + return x; > +#endif Likewise it's probably best to cast to uint64_t here. r~