qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 0/7] tcg: movcond (ppc32 version)


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH v2 0/7] tcg: movcond (ppc32 version)
Date: Fri, 21 Sep 2012 15:21:24 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0

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

[Prev in Thread] Current Thread [Next in Thread]