On 10/09/2012 12:56 PM, Aurelien Jarno wrote:
> Now that the liveness analysis provides more information, rewrite
> tcg_reg_alloc_mov(). This changes the behaviour about propagating
> constants and memory accesses. We now take the assumption that once
> a value is loaded into a register (from memory or from a constant),
> it's better to keep it there than to reload it later. This assumption
> is now always almost correct given that we are now sure the
> corresponding temp is going to be used later (otherwise it would have
> been synchronized and marked as dead already). The assumption is wrong
> if one of the op after clobbers some registers including the one
> of the holding the temp (this can be avoided by allocating clobbered
> registers last, which is what most TCG target do), or in case of lack
> of available register.
> 
> Signed-off-by: Aurelien Jarno <aurel...@aurel32.net>

Reviewed-by: Richard Henderson <r...@twiddle.net>

> +        /* The code in the first if block should have moved the
> +           temp to a register. */
> +        assert(ts->val_type == TEMP_VAL_REG);
> +        if (IS_DEAD_ARG(1) && !ts->fixed_reg && !ots->fixed_reg) {
> +                /* the mov can be suppressed */
> +                if (ots->val_type == TEMP_VAL_REG) {
> +                    s->reg_to_temp[ots->reg] = -1;
> +                }
> +                ots->reg = ts->reg;
> +                temp_dead(s, args[1]);

Incorrect indentation?

>          } else {
> +            if (ots->val_type != TEMP_VAL_REG) {
> +                /* When allocating a new register, make sure to not spill the
> +                   input one. */
> +                tcg_regset_set_reg(allocated_regs, ts->reg);
> +                ots->reg = tcg_reg_alloc(s, oarg_ct->u.regs, allocated_regs);
>              }
> +            tcg_out_mov(s, ots->type, ots->reg, ts->reg);
> +        }


Reply via email to