+/**
+ * find a definition for a value in the given block or above.
+ *
+ * @param block the block
+ * @param op the memop: the definition must dominate it
+ * @param value the value
+ *
+ * @return the definition or NULL if modes are different
+ */
+static ir_node *find_definition(ir_node *block, const memop_t *op, const value_t *value) {
+ ir_node *def_block = get_nodes_block(value->value);
+
+ if (def_block == block) {
+ /* the value is in our block: check, if it is above in the memory list */
+ const memop_t *p;
+
+ for (p = op->prev; p != NULL; p = p->prev) {
+ if (!(p->flags & FLAG_KILLED_NODE) &&
+ p->value.address == value->address) {
+ /* found */
+ assert(p->value.value == value->value);
+ return p->value.value;
+ }
+ }
+ } else if (block_dominates(def_block, block)) {
+ /* strictly dominates */
+ return value->value;
+ }
+
+ return build_phi_definition(block, value);
+}
+