+2009-05-20 Rodrigo Kumpera <rkumpera@novell.com>
+
+ * local-propagation.c (mono_local_cprop): Avoid local propagation
+ across paired add/sub if the first instruction dest reg is it's
+ source reg. For example:
+
+ int_add_imm R12 <- R12 [1] clobbers: 1
+ int_sub_imm R42 <- R12 [1] clobbers: 1
+
+ The cprop pass would wrongly const prop + 1 to int_sub_imm which doesn't
+ maintain the math identify.
+
+ Fixes #505375.
+
2009-05-20 Andreia Gaita <avidigal@novell.com>
* Makefile.am: avoid going on the network just to get the revision,
return 2;
return 0;
}
+
+ //repro for #505375
+ public static int test_2_cprop_bug () {
+ int idx = 0;
+ int a = 1;
+ var cmp = System.Collections.Generic.Comparer<int>.Default ;
+ if (cmp.Compare (a, 0) > 0)
+ a = 0;
+ do { idx++; } while (cmp.Compare (idx - 1, a) == 0);
+ return idx;
+ }
+
+
}
if ((def->opcode == OP_MOVE) && (!defs [def->sreg1] || (def_index [def->sreg1] < def_index [sreg])) && !vreg_is_volatile (cfg, def->sreg1)) {
int vreg = def->sreg1;
- //printf ("CCOPY: R%d -> R%d\n", sreg, vreg);
+ if (cfg->verbose_level > 2) printf ("CCOPY: R%d -> R%d\n", sreg, vreg);
ins->dreg = vreg;
}
}
(def->opcode != OP_FMOVE)) {
int vreg = def->sreg1;
- //printf ("CCOPY: R%d -> R%d\n", sreg, vreg);
+ if (cfg->verbose_level > 2) printf ("CCOPY/2: R%d -> R%d\n", sreg, vreg);
sregs [srcindex] = vreg;
mono_inst_set_src_registers (ins, sregs);
ins->inst_basereg = def->sreg1;
ins->inst_offset += def->inst_imm;
}
- } else if ((ins->opcode == OP_ISUB_IMM) && (def->opcode == OP_IADD_IMM) && (def->next == ins)) {
+ } else if ((ins->opcode == OP_ISUB_IMM) && (def->opcode == OP_IADD_IMM) && (def->next == ins) && (def->dreg != def->sreg1)) {
ins->sreg1 = def->sreg1;
ins->inst_imm -= def->inst_imm;
- } else if ((ins->opcode == OP_IADD_IMM) && (def->opcode == OP_ISUB_IMM) && (def->next == ins)) {
+ } else if ((ins->opcode == OP_IADD_IMM) && (def->opcode == OP_ISUB_IMM) && (def->next == ins) && (def->dreg != def->sreg1)) {
ins->sreg1 = def->sreg1;
ins->inst_imm -= def->inst_imm;
} else if (ins->opcode == OP_STOREI1_MEMBASE_REG &&