- }
- }
- }
- }
- return n;
-} /* equivalent_node_Mux */
-
-/**
- * Returns a equivalent node of a Psi: if a condition is true
- * and all previous conditions are false we know its value.
- * If all conditions are false its value is the default one.
- */
-static ir_node *equivalent_node_Psi(ir_node *n) {
- if (is_Mux(n))
- return equivalent_node_Mux(n);
- return n;
-} /* equivalent_node_Psi */
-
-/**
- * Optimize -a CMP -b into b CMP a.
- * This works only for for modes where unary Minus
- * cannot Overflow.
- * Note that two-complement integers can Overflow
- * so it will NOT work.
- *
- * For == and != can be handled in Proj(Cmp)
- */
-static ir_node *equivalent_node_Cmp(ir_node *n) {
- ir_node *left = get_Cmp_left(n);
- ir_node *right = get_Cmp_right(n);
-
- if (is_Minus(left) && is_Minus(right) &&
- !mode_overflow_on_unary_Minus(get_irn_mode(left))) {
- left = get_Minus_op(left);
- right = get_Minus_op(right);
- set_Cmp_left(n, right);
- set_Cmp_right(n, left);
- }
- return n;
-} /* equivalent_node_Cmp */
-
-/**
- * Remove Confirm nodes if setting is on.
- * Replace Confirms(x, '=', Constlike) by Constlike.
- */
-static ir_node *equivalent_node_Confirm(ir_node *n) {
- ir_node *pred = get_Confirm_value(n);
- pn_Cmp pnc = get_Confirm_cmp(n);
-
- if (is_Confirm(pred) && pnc == get_Confirm_cmp(pred)) {
- /*
- * rare case: two identical Confirms one after another,
- * replace the second one with the first.
- */
- n = pred;
- }
- if (pnc == pn_Cmp_Eq) {
- ir_node *bound = get_Confirm_bound(n);
-
- /*
- * Optimize a rare case:
- * Confirm(x, '=', Constlike) ==> Constlike
- */
- if (is_irn_constlike(bound)) {
- DBG_OPT_CONFIRM(n, bound);
- return bound;
- }
- }
- return get_opt_remove_confirm() ? get_Confirm_value(n) : n;
-}
-
-/**
- * Optimize CopyB(mem, x, x) into a Nop.
- */
-static ir_node *equivalent_node_CopyB(ir_node *n) {
- ir_node *a = get_CopyB_dst(n);
- ir_node *b = get_CopyB_src(n);
-
- if (a == b) {
- /* Turn CopyB into a tuple (mem, jmp, bad, bad) */
- ir_node *mem = get_CopyB_mem(n);
- ir_node *blk = get_nodes_block(n);
- turn_into_tuple(n, pn_CopyB_max);
- set_Tuple_pred(n, pn_CopyB_M, mem);
- set_Tuple_pred(n, pn_CopyB_X_regular, new_r_Jmp(current_ir_graph, blk));
- set_Tuple_pred(n, pn_CopyB_X_except, new_Bad()); /* no exception */
- set_Tuple_pred(n, pn_CopyB_M_except, new_Bad());
- }
- return n;
-} /* equivalent_node_CopyB */
-
-/**
- * Optimize Bounds(idx, idx, upper) into idx.
- */
-static ir_node *equivalent_node_Bound(ir_node *n) {
- ir_node *idx = get_Bound_index(n);
- ir_node *lower = get_Bound_lower(n);
- int ret_tuple = 0;
-
- /* By definition lower < upper, so if idx == lower -->
- lower <= idx && idx < upper */
- if (idx == lower) {
- /* Turn Bound into a tuple (mem, jmp, bad, idx) */
- ret_tuple = 1;
- } else {
- ir_node *pred = skip_Proj(idx);