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.
*
static ir_tarval *computed_value_Cmp(const ir_node *cmp)
{
/* we can't construct Constb after lowering mode_b nodes */
- if (is_irg_state(get_irn_irg(cmp), IR_GRAPH_STATE_MODEB_LOWERED))
+ if (irg_is_constrained(get_irn_irg(cmp), IR_GRAPH_CONSTRAINT_MODEB_LOWERED))
return tarval_bad;
return compute_cmp(cmp);
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 */
ir_tarval *tv2;
ir_tarval *tv_bitop;
- if (!is_irg_state(irg, IR_GRAPH_STATE_NORMALISATION2))
+ if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_NORMALISATION2))
return n;
assert(is_And(n) || is_Or(n) || is_Eor(n) || is_Or_Eor_Add(n));
ir_graph *irg = get_irn_irg(n);
/* the following code leads to endless recursion when Mul are replaced
* by a simple instruction chain */
- if (!is_irg_state(irg, IR_GRAPH_STATE_ARCH_DEP)
+ if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_ARCH_DEP)
&& a == b && mode_is_int(mode)) {
ir_node *block = get_nodes_block(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) {
}
/* We might generate an endless loop, so keep it alive. */
add_End_keepalive(get_irg_end(irg), blk);
- clear_irg_state(irg, IR_GRAPH_STATE_NO_UNREACHABLE_CODE);
+ clear_irg_properties(irg, IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE);
}
return n;
}
ir_tarval *tv2;
ir_tarval *tv_shift;
- if (is_irg_state(irg, IR_GRAPH_STATE_NORMALISATION2))
+ if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_NORMALISATION2))
return n;
assert(is_Shrs(n) || is_Shr(n) || is_Shl(n) || is_Rotl(n));
/**
* Test whether a block is unreachable
* Note: That this only returns true when
- * IR_GRAPH_STATE_OPTIMIZE_UNREACHABLE_CODE is set.
+ * IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE is set.
* This is important, as you easily end up producing invalid constructs in the
* unreachable code when optimizing away edges into the unreachable code.
* So only set this flag when you iterate localopts to the fixpoint.
static bool is_block_unreachable(const ir_node *block)
{
const ir_graph *irg = get_irn_irg(block);
- if (!is_irg_state(irg, IR_GRAPH_STATE_OPTIMIZE_UNREACHABLE_CODE))
+ if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE))
return false;
return get_Block_dom_depth(block) < 0;
}
ir_node *bad = NULL;
int i;
- if (!is_irg_state(irg, IR_GRAPH_STATE_OPTIMIZE_UNREACHABLE_CODE))
+ if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_OPTIMIZE_UNREACHABLE_CODE))
return block;
for (i = 0; i < arity; ++i) {
/* the following optimisations create new mode_b nodes, so only do them
* before mode_b lowering */
- if (!is_irg_state(irg, IR_GRAPH_STATE_MODEB_LOWERED)) {
+ if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_MODEB_LOWERED)) {
if (is_Mux(t)) {
ir_node* block = get_nodes_block(n);
ir_node* c0 = sel;
/** 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;
}
irn_verify(n);
/* Now we have a legal, useful node. Enter it in hash table for cse.
- * Blocks should be unique anyways. (Except the successor of start:
- * is cse with the start block!)
*
* Note: This is only necessary because some of the optimisations
* operate in-place (set_XXX_bla, turn_into_tuple, ...) which is considered
/* FIXME: Maybe we could also test whether optimizing the node can
change the control graph. */
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
+ clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
return optimize_in_place_2(n);
}
unsigned h;
/* special value for const, as they only differ in their tarval. */
- h = HASH_PTR(node->attr.con.tarval);
+ h = hash_ptr(node->attr.con.tarval);
return h;
}
unsigned h;
/* all others are pointers */
- h = HASH_PTR(node->attr.symc.sym.type_p);
+ h = hash_ptr(node->attr.symc.sym.type_p);
return h;
}