Use be_emit_irprintf("%T", x) instead of be_emit_tarval().
[libfirm] / ir / ir / iropt.c
index d9be5c1..bd60eb8 100644 (file)
@@ -614,6 +614,17 @@ static ir_tarval *compute_cmp(const ir_node *cmp)
        return computed_value_Cmp_Confirm(cmp, left, right, relation);
 }
 
+/**
+ * some people want to call compute_cmp directly, in this case we have to
+ * test the constant folding flag again
+ */
+static ir_tarval *compute_cmp_ext(const ir_node *cmp)
+{
+       if (!get_opt_constant_folding())
+               return tarval_bad;
+       return compute_cmp(cmp);
+}
+
 /**
  * Return the value of a Cmp.
  *
@@ -1471,7 +1482,7 @@ static ir_node *equivalent_node_Mux(ir_node *n)
        if (ts == tarval_bad && is_Cmp(sel)) {
                /* try again with a direct call to compute_cmp, as we don't care
                 * about the MODEB_LOWERED flag here */
-               ts = compute_cmp(sel);
+               ts = compute_cmp_ext(sel);
        }
 
        /* Mux(true, f, t) == t */
@@ -3539,7 +3550,7 @@ static ir_node *transform_node_Cond(ir_node *n)
        if (ta == tarval_bad && is_Cmp(a)) {
                /* try again with a direct call to compute_cmp, as we don't care
                 * about the MODEB_LOWERED flag here */
-               ta = compute_cmp(a);
+               ta = compute_cmp_ext(a);
        }
 
        if (ta != tarval_bad && get_irn_mode(a) == mode_b) {
@@ -6516,11 +6527,11 @@ static int node_cmp_attr_Sel(const ir_node *a, const ir_node *b)
 /** Compares the attributes of two Phi nodes. */
 static int node_cmp_attr_Phi(const ir_node *a, const ir_node *b)
 {
-       /* we can only enter this function if both nodes have the same number of inputs,
-          hence it is enough to check if one of them is a Phi0 */
-       if (is_Phi0(a)) {
-               /* check the Phi0 pos attribute */
-               return a->attr.phi.u.pos != b->attr.phi.u.pos;
+       (void) b;
+       /* do not CSE Phi-nodes without any inputs when building new graphs */
+       if (get_irn_arity(a) == 0 &&
+           get_irg_phase_state(get_irn_irg(a)) == phase_building) {
+           return 1;
        }
        return 0;
 }