On 10/06/2012 05:30 AM, Paolo Bonzini wrote:
> +    case CC_OP_SUBB:
> +    case CC_OP_SUBW:
> +    case CC_OP_SUBL:
> +    case CC_OP_SUBQ:
> +        /* (DATA_TYPE)(CC_DST + CC_SRC) < (DATA_TYPE)CC_SRC */
> +        size = (s->cc_op - CC_OP_ADDB) & 3;

I guess the & 3 makes the result "just so happen" to be right,
but I think the code would be more readable with "- SUBB" there.
And the other cases of the same pattern below.

> +    case CC_OP_SBBB:
> +    case CC_OP_SBBW:
> +    case CC_OP_SBBL:
> +    case CC_OP_SBBQ:
> +        /* (DATA_TYPE)(CC_DST + CC_SRC + 1) <= (DATA_TYPE)CC_SRC */
> +        size = (s->cc_op - CC_OP_ADDB) & 3;
> +        t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
> +        if (t1 == reg && reg == cpu_cc_src) {
> +            tcg_gen_mov_tl(cpu_tmp0, cpu_cc_src);
> +            t1 = cpu_tmp0;
> +        }
> +
> +        tcg_gen_add_tl(reg, cpu_cc_dst, cpu_cc_src);
> +        tcg_gen_addi_tl(reg, reg, 1);
> +        gen_extu(size, reg);
> +        t0 = reg;
> +        goto adc_sbb;
> +
> +    case CC_OP_ADCB:
> +    case CC_OP_ADCW:
> +    case CC_OP_ADCL:
> +    case CC_OP_ADCQ:
> +        /* (DATA_TYPE)CC_DST <= (DATA_TYPE)CC_SRC */
> +        size = (s->cc_op - CC_OP_ADDB) & 3;
> +        t1 = gen_ext_tl(cpu_tmp0, cpu_cc_src, size, false);
> +        t0 = gen_ext_tl(reg, cpu_cc_dst, size, false);
> +    adc_sbb:
> +        tcg_gen_setcond_tl(inv ? TCG_COND_GTU : TCG_COND_LEU, reg, t0, t1);
> +        return;

There's no point in handling these, because you can never see them
assigned to s->cc_op.  The ADC/SBB translators always set CC_OP_DYNAMIC
after dynamically selecting CC_OP_ADD or CC_OP_ADC based on the carry-in.

> +    default:
> +        abort();

Better to just treat unlisted codes as dynamic?  I.e.

    default: /* Including CC_OP_DYNAMIC */
        gen_compute_eflags(s);
        /* FALLTHRU */

    case CC_OP_EFLAGS:
        ...

All that said, the patch as written is correct.

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


r~

Reply via email to