X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fcfold.c;h=940c07ac8d825b9d0bb3886ec37d35b71319ef41;hb=081280659abccd2ff89056572bd6cd192d7747fe;hp=ab343a50b174f68b3dba1c6b640ddbb665928bdc;hpb=db4550cb380f75bd9c4985966272320f25653ba8;p=mono.git diff --git a/mono/mini/cfold.c b/mono/mini/cfold.c index ab343a50b17..940c07ac8d8 100644 --- a/mono/mini/cfold.c +++ b/mono/mini/cfold.c @@ -1,5 +1,6 @@ -/* - * cfold.c: Constant folding support +/** + * \file + * Constant folding support * * Author: * Paolo Molaro (lupus@ximian.com) @@ -7,9 +8,12 @@ * * (C) 2003 Ximian, Inc. http://www.ximian.com */ +#include + #include "mini.h" #include "ir-emit.h" +/* WTF is this doing here?!?!? */ int mono_is_power_of_two (guint32 val) { @@ -66,6 +70,8 @@ mono_is_power_of_two (guint32 val) } \ } while (0) +#ifndef DISABLE_JIT + /** * mono_constant_fold_ins: * @@ -137,7 +143,7 @@ mono_constant_fold_ins (MonoCompile *cfg, MonoInst *ins, MonoInst *arg1, MonoIns FOLD_BINOPC2_IMM (OP_ISHL_IMM, <<, gint32); FOLD_BINOPC2_IMM (OP_ISHR_IMM, >>, gint32); FOLD_BINOPC2_IMM (OP_ISHR_UN_IMM, >>, guint32); - FOLD_BINOPC2_IMM (OP_SHL_IMM, <<, gint32); + FOLD_BINOP2_IMM (OP_SHL_IMM, <<); } dest->opcode = OP_ICONST; MONO_INST_NULLIFY_SREGS (dest); @@ -202,8 +208,10 @@ mono_constant_fold_ins (MonoCompile *cfg, MonoInst *ins, MonoInst *arg1, MonoIns case OP_INEG: if (arg1->opcode == OP_ICONST) { /* INEG sets cflags on x86, and the LNEG decomposition depends on that */ - if ((ins->opcode == OP_INEG) && ins->next && (ins->next->opcode == OP_ADC_IMM)) +#if SIZEOF_REGISTER == 4 + if (ins->opcode == OP_INEG) return NULL; +#endif ALLOC_DEST (cfg, dest, ins); switch (ins->opcode) { FOLD_UNOP (OP_INEG,-); @@ -328,6 +336,19 @@ mono_constant_fold_ins (MonoCompile *cfg, MonoInst *ins, MonoInst *arg1, MonoIns dest->inst_c0 = res; } break; + case OP_COND_EXC_EQ: + res = arg1->inst_c0 == arg2->inst_c0; + if (!res) { + if (overwrite) { + NULLIFY_INS (ins); + NULLIFY_INS (next); + } else { + ALLOC_DEST (cfg, dest, ins); + dest->opcode = OP_ICONST; + dest->inst_c0 = res; + } + } + break; case OP_NOP: case OP_BR: /* This happens when a conditional branch is eliminated */ @@ -341,6 +362,24 @@ mono_constant_fold_ins (MonoCompile *cfg, MonoInst *ins, MonoInst *arg1, MonoIns return NULL; } } + if ((arg1->opcode == OP_PCONST) && (arg2->opcode == OP_PCONST) && ins->next) { + MonoInst *next = ins->next; + + if (next->opcode == OP_LCEQ) { + gboolean res = arg1->inst_p0 == arg2->inst_p0; + if (overwrite) { + NULLIFY_INS (ins); + next->opcode = OP_ICONST; + next->inst_c0 = res; + MONO_INST_NULLIFY_SREGS (next); + } else { + ALLOC_DEST (cfg, dest, ins); + dest->opcode = OP_ICONST; + dest->inst_c0 = res; + } + break; + } + } break; } case OP_FMOVE: @@ -364,3 +403,6 @@ mono_constant_fold_ins (MonoCompile *cfg, MonoInst *ins, MonoInst *arg1, MonoIns return dest; } + + +#endif /* DISABLE_JIT */