[Mono-devel-list] [PATCH] Constant folding signed div
Massimiliano Mantione
massi at ximian.com
Mon Nov 29 07:36:42 EST 2004
On Fri, 2004-11-26 at 16:19, Paolo Molaro wrote:
> > +MINI_OP(OP_DIV_CFOLD, "op_div_cfold")
> I don't like the OP_DIV_CFOLD name. Maybe OP_DIV_POWER2_IMM?
> Any better suggestions?
No (concise) better suggestion, but I totally second this, in
fact I could not understand what the opcode did from the name
alone.
> > +reg: OP_DIV_CFOLD (reg, OP_ICONST) {
> > + MonoInst *not_signed;
> > + int imm = state->right->tree->inst_c0;
> > +
> > + MONO_NEW_LABEL (s, not_signed);
> > +
> > + MONO_EMIT_NEW_BIALU_IMM (s, OP_COMPARE_IMM, state->left->reg1, state->left->reg1, 0);
> > + MONO_EMIT_NEW_BRANCH_LABEL (s, CEE_BGE, not_signed);
> > + if (imm == 1)
> > + MONO_EMIT_NEW_BIALU_IMM (s, OP_ADC_IMM, state->left->reg1, state->left->reg1, 1);
> > + else
> > + MONO_EMIT_NEW_BIALU_IMM (s, OP_ADD_IMM, state->left->reg1, state->left->reg1, (1 << imm) - 1);
> > +
> > + mono_bblock_add_inst (s->cbb, not_signed);
> > +
> > + MONO_EMIT_NEW_BIALU_IMM (s, OP_SHR_IMM, state->left->reg1, state->left->reg1, imm);
> > + MONO_EMIT_NEW_UNALU (s, OP_MOVE, state->reg1, state->left->reg1);
> > +}
>
> This needs to be forced in its own tree, but there is no good way to do it
> when the code in cfold.c runs:-(
> Maybe it's better to just introduce the OP_DIV_POWER2_IMM opcode
> and let the backend code optionally implement it.
Sorry but, why "This needs to be forced in its own tree"?
Not that I don't agree, I just don't understand :-(
Ciao,
Massi
More information about the Mono-devel-list
mailing list