summaryrefslogtreecommitdiffhomepage
path: root/ir/be/belive.c
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2014-07-16 17:13:13 +0200
committerMatthias Braun <matze@braunis.de>2014-07-18 10:04:11 +0200
commit3cd5b2153fa672ade8c30a82a2cd0d96655d003a (patch)
tree9e82a2a80fa3da6269827d93f37ba1fb224d89ed /ir/be/belive.c
parent2ef7259cb0cb2e12a25a16892cdfaa17a63de3e8 (diff)
extract be_value_live_after() from be_values_interfere()
Value live_after() is a special case of the checks performed in values_interfere(). This commit extracts this code and use the new function where possible.
Diffstat (limited to 'ir/be/belive.c')
-rw-r--r--ir/be/belive.c64
1 files changed, 38 insertions, 26 deletions
diff --git a/ir/be/belive.c b/ir/be/belive.c
index c6c32fe..8e33bb6 100644
--- a/ir/be/belive.c
+++ b/ir/be/belive.c
@@ -445,45 +445,57 @@ void be_liveness_nodes_live_before(be_lv_t const *const lv, arch_register_class_
}
}
-bool be_values_interfere(const ir_node *a, const ir_node *b)
+/**
+ * Check if value @p value is live at definition of @p after.
+ * @note assumes value dominates after
+ */
+static bool value_live_after(const ir_node *const value,
+ const ir_node *const after)
{
- assert(a != b);
- if (value_strictly_dominates(b, a)) {
- /* Adjust a and b so, that a dominates b if
- * a dominates b or vice versa. */
- const ir_node *const t = a;
- a = b;
- b = t;
- } else if (!value_strictly_dominates(a, b)) {
- /* If there is no dominance relation, they do not interfere. */
- return false;
- }
-
- /* If a is live end in b's block it is
- * live at b's definition (a dominates b) */
- const ir_node *const bb = get_nodes_block(b);
+ /* If value is live end in after's block it is
+ * live at after's definition (value dominates after) */
+ const ir_node *const bb = get_nodes_block(after);
const ir_graph *const irg = get_Block_irg(bb);
const be_lv_t *const lv = be_get_irg_liveness(irg);
- if (be_is_live_end(lv, bb, a))
+ if (be_is_live_end(lv, bb, value))
return true;
- /* Look at all usages of a.
- * If there's one usage of a in the block of b, then we check, if this use
- * is dominated by b, if that's true a and b interfere. Note that b must
- * strictly dominate the user, since if b is the last user of in the block,
- * b and a do not interfere.
- * Uses of a not in b's block can be disobeyed, because the check for a
- * being live at the end of b's block is already performed. */
- foreach_out_edge(a, edge) {
+ /* Look at all usages of value.
+ * If there's one usage of value in the block of after, then we check, if
+ * this use is dominated by after, if that's true value and after interfere.
+ * Note that after must strictly dominate the user, since if after is the
+ * last user of in the block, after and value do not interfere.
+ * Uses of value not in after's block can be disobeyed, because the check
+ * for value being live at the end of after's block is already performed. */
+ foreach_out_edge(value, edge) {
const ir_node *const user = get_edge_src_irn(edge);
if (get_nodes_block(user) == bb && !is_Phi(user)
- && sched_comes_before(b, user))
+ && sched_comes_before(after, user))
return true;
}
return false;
}
+bool be_value_live_after(const ir_node *value, const ir_node *after)
+{
+ assert(value != after);
+ if (!value_strictly_dominates(value, after))
+ return false;
+ return value_live_after(value, after);
+}
+
+bool be_values_interfere(const ir_node *a, const ir_node *b)
+{
+ assert(a != b);
+ if (value_strictly_dominates(b, a)) {
+ return value_live_after(b, a);
+ } else if (value_strictly_dominates(a, b)) {
+ return value_live_after(a, b);
+ }
+ return false;
+}
+
static bool live_at_user(const ir_node *const users_of,
const ir_node *const node, const ir_node *const bb)
{