+ DB((dbg, LEVEL_2, "optimize %+F\n", current_node));
+ peephole_node(current_node);
+ assert(!is_Bad(current_node));
+ }
+}
+
+/**
+ * Check whether the node has only one user. Explicitly ignore the anchor.
+ */
+bool be_has_only_one_user(ir_node *node)
+{
+ int n = get_irn_n_edges(node);
+ int n_users;
+ const ir_edge_t *edge;
+
+ if (n <= 1)
+ return 1;
+
+ n_users = 0;
+ foreach_out_edge(node, edge) {
+ ir_node *src = get_edge_src_irn(edge);
+ /* ignore anchor and keep-alive edges */
+ if (is_Anchor(src) || is_End(src))
+ continue;
+ n_users++;
+ }
+
+ return n_users == 1;
+}
+
+bool be_can_move_before(ir_heights_t *heights, const ir_node *node,
+ const ir_node *before)
+{
+ int node_arity = get_irn_arity(node);
+ ir_node *schedpoint = sched_next(node);
+
+ while (schedpoint != before) {
+ int i;
+ unsigned n_outs = arch_get_irn_n_outs(schedpoint);
+
+ /* the node must not use our computed values */
+ if (heights_reachable_in_block(heights, schedpoint, node))
+ return false;
+
+ /* the node must not overwrite registers of our inputs */
+ for (i = 0; i < node_arity; ++i) {
+ ir_node *in = get_irn_n(node, i);
+ const arch_register_t *reg = arch_get_irn_register(in);
+ const arch_register_req_t *in_req
+ = arch_get_irn_register_req_in(node, i);
+ unsigned o;
+ if (reg == NULL)
+ continue;
+ for (o = 0; o < n_outs; ++o) {
+ const arch_register_t *outreg
+ = arch_get_irn_register_out(schedpoint, o);
+ const arch_register_req_t *outreq
+ = arch_get_irn_register_req_out(schedpoint, o);
+ if (outreg == NULL)
+ continue;
+ if (outreg->global_index >= reg->global_index
+ && outreg->global_index
+ < (unsigned)reg->global_index + in_req->width)
+ return false;
+ if (reg->global_index >= outreg->global_index
+ && reg->global_index
+ < (unsigned)outreg->global_index + outreq->width)
+ return false;
+ }