Correct a subtle bug in the ia32 backend: Sub(x, x) triggered that the Neg+Add trick...
authorChristoph Mallon <christoph.mallon@gmx.de>
Sat, 6 Mar 2010 10:49:03 +0000 (10:49 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 6 Mar 2010 10:49:03 +0000 (10:49 +0000)
[r27256]

ir/be/ia32/ia32_finish.c

index 09858aa..3a47783 100644 (file)
@@ -51,7 +51,7 @@
 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 
 /**
- * Transforms a Sub or xSub into Neg--Add iff OUT_REG == SRC2_REG.
+ * Transforms a Sub or xSub into Neg--Add iff OUT_REG != SRC1_REG && OUT_REG == SRC2_REG.
  * THIS FUNCTIONS MUST BE CALLED AFTER REGISTER ALLOCATION.
  */
 static void ia32_transform_sub_to_neg_add(ir_node *irn, ia32_code_gen_t *cg)
@@ -78,6 +78,9 @@ static void ia32_transform_sub_to_neg_add(ir_node *irn, ia32_code_gen_t *cg)
        irg     = cg->irg;
        block   = get_nodes_block(irn);
 
+       if (out_reg == in1_reg)
+               return;
+
        /* in case of sub and OUT == SRC2 we can transform the sequence into neg src2 -- add */
        if (out_reg != in2_reg)
                return;