# include "irvrfy.h"
# include "tv.h"
# include "tune.h"
-
+# include "debinfo.h"
/* Make types visible to allow most efficient access */
# include "entity_t.h"
themselves.
*/
int i, n_preds;
+
+
ir_node *block = NULL; /* to shutup gcc */
ir_node *first_val = NULL; /* to shutup gcc */
ir_node *scnd_val = NULL; /* to shutup gcc */
}
}
#endif
+
/* Find first non-self-referencing input */
for (i = 0; i < n_preds; ++i) {
first_val = follow_Id(get_Phi_pred(n, i));
}
/* A totally Bad or self-referencing Phi (we didn't break the above loop) */
- if (i > n_preds) { n = new_Bad(); break; }
+ if (i >= n_preds) { n = new_Bad(); break; }
scnd_val = NULL;
}
/* Fold, if no multiple distinct non-self-referencing inputs */
- if (i > n_preds) {
- n = a;
+ if (i >= n_preds) {
+ n = first_val;
} else {
/* skip the remaining Ids. */
while (++i < n_preds) {
if ( op != op_Block && op != op_Phi && op != op_Tuple) {
for (i = -1; i < get_irn_arity(node); i++) {
if (is_Bad(get_irn_n(node, i))) {
- node = new_Bad();
- break;
+ return new_Bad();
}
}
}
+#if 0
+ /* If Block has only Bads as predecessors it's garbage. */
+ /* If Phi has only Bads as predecessors it's garbage. */
+ if (op == op_Block || op == op_Phi) {
+ for (i = 0; i < get_irn_arity(node); i++) {
+ if (!is_Bad(get_irn_n(node, i))) break;
+ }
+ if (i = get_irn_arity(node)) node = new_Bad();
+ }
+#endif
return node;
}
tarval *tv;
ir_node *old_n = n;
+ if (!get_optimize()) return n;
+
/* if not optimize return n */
if (n == NULL) {
/* Here this is possible. Why? */
tv = computed_value (n);
if (tv != NULL) {
/* evaluation was succesful -- replace the node. */
- return new_Const (get_tv_mode (tv), tv);
+ n = new_Const (get_tv_mode (tv), tv);
+ deb_info_copy(n, old_n, id_from_str("const_eval", 10));
+ return n;
/* xprintf("* optimize: computed node %I\n", n->op->name);*/
}
}
}
/* remove unnecessary nodes */
- if (get_opt_constant_folding())
- // if (get_opt_constant_folding() || get_irn_op(n) == op_Phi)
+ //if (get_opt_constant_folding())
+ if (get_opt_constant_folding() || get_irn_op(n) == op_Phi)
n = equivalent_node (n);
/** common subexpression elimination **/