iropt: fix direct calls to compute_cmp
authorMatthias Braun <matthias.braun@kit.edu>
Thu, 1 Mar 2012 14:47:00 +0000 (15:47 +0100)
committerMatthias Braun <matthias.braun@kit.edu>
Thu, 1 Mar 2012 14:48:16 +0000 (15:48 +0100)
- The direct call did not respect the get_opt_constant_folding() flag

ir/ir/iropt.c

index 81083a5..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) {