On 09/21/2012 01:10 PM, malc wrote:
> +        if (dest == v2) {
> +            label_ptr = s->code_ptr;
> +            tcg_out32 (s, tcg_to_bc[tcg_invert_cond (cond)]);
> +            tcg_out_mov (s, TCG_TYPE_I32, dest, v1);
> +            reloc_pc14 (label_ptr, (tcg_target_long) s->code_ptr);
> +        }
> +        else {
> +            tcg_out_mov (s, TCG_TYPE_I32, dest, v1);
> +            label_ptr = s->code_ptr;
> +            tcg_out32 (s, tcg_to_bc[cond]);
> +            tcg_out_mov (s, TCG_TYPE_I32, dest, v2);
> +            reloc_pc14 (label_ptr, (tcg_target_long) s->code_ptr);
> +        }

How about

    if (dest == v2) {
        cond = tcg_invert_cond(cond);
        v2 = v1;
    } else if (dest != v1) {
        tcg_out_mov(s, TCG_TYPE_I32, dest, v1);
    }
    /* Branch forward over one insn.  */
    tcg_out32 (s, tcg_to_bc[cond] | 4);
    tcg_out_mov(s, TCG_TYPE_I32, dest, v2);

which avoids an extra mov if dest == v1, and also minimizes the code.


r~

Reply via email to