|
From: | Richard Henderson |
Subject: | Re: [Qemu-devel] [PATCH v2 5/6] Do constant folding for shift operations. |
Date: | Fri, 10 Jun 2011 11:02:52 -0700 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc15 Thunderbird/3.1.10 |
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~
[Prev in Thread] | Current Thread | [Next in Thread] |