+} /* compute_Phi */
+
+/**
+ * (Re-)compute the type for an Add. Special case: one nodes is a Zero Const.
+ *
+ * @param node the node
+ */
+static void compute_Add(node_t *node) {
+ ir_node *sub = node->node;
+ node_t *l = get_irn_node(get_Add_left(sub));
+ node_t *r = get_irn_node(get_Add_right(sub));
+ lattice_elem_t a = l->type;
+ lattice_elem_t b = r->type;
+ ir_mode *mode;
+
+ if (a.tv == tarval_top || b.tv == tarval_top) {
+ node->type.tv = tarval_top;
+ } else if (a.tv == tarval_bottom || b.tv == tarval_bottom) {
+ node->type.tv = tarval_bottom;
+ } else {
+ /* x + 0 = 0 + x = x, but beware of floating point +0 + -0, so we
+ must call tarval_add() first to handle this case! */
+ if (is_tarval(a.tv)) {
+ if (is_tarval(b.tv)) {
+ node->type.tv = tarval_add(a.tv, b.tv);
+ return;
+ }
+ mode = get_tarval_mode(a.tv);
+ if (a.tv == get_mode_null(mode)) {
+ node->type = b;
+ return;
+ }
+ } else if (is_tarval(b.tv)) {
+ mode = get_tarval_mode(b.tv);
+ if (b.tv == get_mode_null(mode)) {
+ node->type = a;
+ return;
+ }
+ }
+ node->type.tv = tarval_bottom;
+ }
+} /* compute_Add */
+
+/**
+ * (Re-)compute the type for a Sub. Special case: both nodes are congruent.
+ *
+ * @param node the node
+ */
+static void compute_Sub(node_t *node) {
+ ir_node *sub = node->node;
+ node_t *l = get_irn_node(get_Sub_left(sub));
+ node_t *r = get_irn_node(get_Sub_right(sub));
+ lattice_elem_t a = l->type;
+ lattice_elem_t b = r->type;
+ tarval *tv;
+
+ if (a.tv == tarval_top || b.tv == tarval_top) {
+ node->type.tv = tarval_top;
+ } else if (is_con(a) && is_con(b)) {
+ if (is_tarval(a.tv) && is_tarval(b.tv)) {
+ node->type.tv = tarval_sub(a.tv, b.tv, get_irn_mode(sub));
+ } else if (is_tarval(a.tv) && tarval_is_null(a.tv)) {
+ node->type = b;
+ } else if (is_tarval(b.tv) && tarval_is_null(b.tv)) {
+ node->type = a;
+ } else {
+ node->type.tv = tarval_bottom;
+ }
+ node->by_all_const = 1;
+ } else if (r->part == l->part &&
+ (!mode_is_float(get_irn_mode(l->node)))) {
+ /*
+ * BEWARE: a - a is NOT always 0 for floating Point values, as
+ * NaN op NaN = NaN, so we must check this here.
+ */
+ ir_mode *mode = get_irn_mode(sub);
+ tv = get_mode_null(mode);
+
+ /* if the node was ONCE evaluated by all constants, but now
+ this breakes AND we cat by partition a different result, switch to bottom.
+ This happens because initially all nodes are in the same partition ... */
+ if (node->by_all_const && node->type.tv != tv)
+ tv = tarval_bottom;
+ node->type.tv = tv;
+ } else {
+ node->type.tv = tarval_bottom;
+ }
+} /* compute_Sub */
+
+/**
+ * (Re-)compute the type for an Eor. Special case: both nodes are congruent.
+ *
+ * @param node the node
+ */
+static void compute_Eor(node_t *node) {
+ ir_node *eor = node->node;
+ node_t *l = get_irn_node(get_Eor_left(eor));
+ node_t *r = get_irn_node(get_Eor_right(eor));
+ lattice_elem_t a = l->type;
+ lattice_elem_t b = r->type;
+ tarval *tv;
+
+ if (a.tv == tarval_top || b.tv == tarval_top) {
+ node->type.tv = tarval_top;
+ } else if (is_con(a) && is_con(b)) {
+ if (is_tarval(a.tv) && is_tarval(b.tv)) {
+ node->type.tv = tarval_eor(a.tv, b.tv);
+ } else if (is_tarval(a.tv) && tarval_is_null(a.tv)) {
+ node->type = b;
+ } else if (is_tarval(b.tv) && tarval_is_null(b.tv)) {
+ node->type = a;
+ } else {
+ node->type.tv = tarval_bottom;
+ }
+ node->by_all_const = 1;
+ } else if (r->part == l->part) {
+ ir_mode *mode = get_irn_mode(eor);
+ tv = get_mode_null(mode);
+
+ /* if the node was ONCE evaluated by all constants, but now
+ this breakes AND we cat by partition a different result, switch to bottom.
+ This happens because initially all nodes are in the same partition ... */
+ if (node->by_all_const && node->type.tv != tv)
+ tv = tarval_bottom;
+ node->type.tv = tv;
+ } else {
+ node->type.tv = tarval_bottom;
+ }
+} /* compute_Eor */
+
+/**
+ * (Re-)compute the type for Cmp.
+ *
+ * @param node the node
+ */
+static void compute_Cmp(node_t *node) {
+ ir_node *cmp = node->node;
+ node_t *l = get_irn_node(get_Cmp_left(cmp));
+ node_t *r = get_irn_node(get_Cmp_right(cmp));
+ lattice_elem_t a = l->type;
+ lattice_elem_t b = r->type;
+
+ if (a.tv == tarval_top || b.tv == tarval_top) {
+#ifdef WITH_UNKNOWN
+ /*
+ * Top is congruent to any other value, we can
+ * calculate the compare result.
+ */
+ node->type.tv = tarval_b_true;
+#else
+ node->type.tv = tarval_top;
+#endif
+ } else if (is_con(a) && is_con(b)) {
+ /* both nodes are constants, we can probably do something */
+ node->type.tv = tarval_b_true;
+ } else if (r->part == l->part) {
+ /* both nodes congruent, we can probably do something */
+ node->type.tv = tarval_b_true;
+ } else {
+ node->type.tv = tarval_bottom;
+ }
+} /* compute_Proj_Cmp */
+
+/**
+ * (Re-)compute the type for a Proj(Cmp).
+ *
+ * @param node the node
+ * @param cond the predecessor Cmp node
+ */
+static void compute_Proj_Cmp(node_t *node, ir_node *cmp) {
+ ir_node *proj = node->node;
+ node_t *l = get_irn_node(get_Cmp_left(cmp));
+ node_t *r = get_irn_node(get_Cmp_right(cmp));
+ lattice_elem_t a = l->type;
+ lattice_elem_t b = r->type;
+ pn_Cmp pnc = get_Proj_proj(proj);
+ tarval *tv;
+
+ if (a.tv == tarval_top || b.tv == tarval_top) {
+#ifdef WITH_UNKNOWN
+ /* see above */
+ tv = new_tarval_from_long((pnc & pn_Cmp_Eq) ^ pn_Cmp_Eq, mode_b);
+ goto not_equal;
+#else
+ node->type.tv = tarval_top;
+#endif
+ } else if (is_con(a) && is_con(b)) {
+ default_compute(node);
+ node->by_all_const = 1;
+ } else if (r->part == l->part &&
+ (!mode_is_float(get_irn_mode(l->node)) || pnc == pn_Cmp_Lt || pnc == pn_Cmp_Gt)) {
+ /*
+ * BEWARE: a == a is NOT always True for floating Point values, as
+ * NaN != NaN is defined, so we must check this here.
+ */
+ tv = new_tarval_from_long(pnc & pn_Cmp_Eq, mode_b);
+#ifdef WITH_UNKNOWN
+not_equal:
+#endif
+
+ /* if the node was ONCE evaluated by all constants, but now
+ this breakes AND we cat by partition a different result, switch to bottom.
+ This happens because initially all nodes are in the same partition ... */
+ if (node->by_all_const && node->type.tv != tv)
+ tv = tarval_bottom;
+ node->type.tv = tv;
+ } else {
+ node->type.tv = tarval_bottom;
+ }
+} /* compute_Proj_Cmp */
+
+/**
+ * (Re-)compute the type for a Proj(Cond).
+ *
+ * @param node the node
+ * @param cond the predecessor Cond node
+ */
+static void compute_Proj_Cond(node_t *node, ir_node *cond) {
+ ir_node *proj = node->node;
+ long pnc = get_Proj_proj(proj);
+ ir_node *sel = get_Cond_selector(cond);
+ node_t *selector = get_irn_node(sel);
+
+ if (get_irn_mode(sel) == mode_b) {
+ /* an IF */
+ if (pnc == pn_Cond_true) {
+ if (selector->type.tv == tarval_b_false) {
+ node->type.tv = tarval_unreachable;
+ } else if (selector->type.tv == tarval_b_true) {
+ node->type.tv = tarval_reachable;
+ } else if (selector->type.tv == tarval_bottom) {
+ node->type.tv = tarval_reachable;
+ } else {
+ assert(selector->type.tv == tarval_top);
+ node->type.tv = tarval_unreachable;
+ }
+ } else {
+ assert(pnc == pn_Cond_false);
+
+ if (selector->type.tv == tarval_b_false) {
+ node->type.tv = tarval_reachable;
+ } else if (selector->type.tv == tarval_b_true) {
+ node->type.tv = tarval_unreachable;
+ } else if (selector->type.tv == tarval_bottom) {
+ node->type.tv = tarval_reachable;
+ } else {
+ assert(selector->type.tv == tarval_top);
+ node->type.tv = tarval_unreachable;
+ }
+ }
+ } else {
+ /* an SWITCH */
+ if (selector->type.tv == tarval_bottom) {
+ node->type.tv = tarval_reachable;
+ } else if (selector->type.tv == tarval_top) {
+ node->type.tv = tarval_unreachable;
+ } else {
+ long value = get_tarval_long(selector->type.tv);
+ if (pnc == get_Cond_defaultProj(cond)) {
+ /* default switch, have to check ALL other cases */
+ int i;
+
+ for (i = get_irn_n_outs(cond) - 1; i >= 0; --i) {
+ ir_node *succ = get_irn_out(cond, i);
+
+ if (succ == proj)
+ continue;
+ if (value == get_Proj_proj(succ)) {
+ /* we found a match, will NOT take the default case */
+ node->type.tv = tarval_unreachable;
+ return;
+ }
+ }
+ /* all cases checked, no match, will take default case */
+ node->type.tv = tarval_reachable;
+ } else {
+ /* normal case */
+ node->type.tv = value == pnc ? tarval_reachable : tarval_unreachable;
+ }
+ }
+ }
+} /* compute_Proj_Cond */