On 29 October 2012 13:36, Jia Liu <pro...@gmail.com> wrote: > case OPC_REPL_PH: > check_dsp(ctx); > { > imm = (ctx->opcode >> 16) & 0x03FF; > imm = (int16_t)(imm << 6) >> 6; > tcg_gen_movi_tl(cpu_gpr[ret], \ > (target_long)(int32_t)((int32_t)imm << 16 | \ > (uint32_t)(uint16_t)imm)); > } > break;
This code is using rather more casts than it needs to. Also, if you kept the scope of 'imm' to the local blocks where it is used then it would be easy to see at a glance what type it is (in this case int16_t) and thus which of these casts are needed. (It would also mean you could use the sensible type for the job -- for instance in the OPC_REPL_QB case a 32 bit type would let you avoid a lot of the casts your current code has.) -- PMM