aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/flow.c
diff options
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-11-16 16:47:05 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:04:33 -0700
commita25eb46654bcc274b81af4f6aee2ea640c067e8a (patch)
tree7faa35d0492c87877b66a541c60437e2e9efbb2a /flow.c
parentc040f2e0eedcea68618679bd97e3587fb904f602 (diff)
downloadsparse-dev-a25eb46654bcc274b81af4f6aee2ea640c067e8a.tar.gz
If we find an exclusive dominating load, see if we can follow it further.
In particular, we could check if the loaded value then gets used in a test, so that the test ends up dominating the instruction.. This just adds the hooks. We don't actually try to find any test instructions.
Diffstat (limited to 'flow.c')
-rw-r--r--flow.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/flow.c b/flow.c
index bc0f0d61..3cb34925 100644
--- a/flow.c
+++ b/flow.c
@@ -206,6 +206,15 @@ static int dominates(pseudo_t pseudo, struct instruction *insn,
return 1;
}
+static pseudo_t load_dominator(struct instruction *insn, struct instruction *dom)
+{
+ /*
+ * We should eventually see if we can determine a more precise
+ * value by seeing if the load value gets tested..
+ */
+ return dom->target;
+}
+
static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn,
struct basic_block *bb, unsigned long generation, struct phi_list **dominators,
int local, int loads)
@@ -216,6 +225,7 @@ static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn,
loads = 0;
FOR_EACH_PTR(bb->parents, parent) {
struct instruction *one;
+ pseudo_t target;
struct phi *phi;
FOR_EACH_PTR_REVERSE(parent->insns, one) {
@@ -230,8 +240,12 @@ static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn,
}
if (!dominance)
continue;
- if (one->opcode == OP_LOAD && !loads)
- continue;
+ target = one->target;
+ if (one->opcode == OP_LOAD) {
+ if (!loads)
+ continue;
+ target = load_dominator(insn, one);
+ }
goto found_dominator;
} END_FOR_EACH_PTR_REVERSE(one);
no_dominance:
@@ -244,7 +258,7 @@ no_dominance:
continue;
found_dominator:
- phi = alloc_phi(parent, one->target);
+ phi = alloc_phi(parent, target);
add_phi(dominators, phi);
} END_FOR_EACH_PTR(parent);
return 1;
@@ -338,7 +352,10 @@ found:
return 0;
if (dom) {
- convert_load_insn(insn, dom->target);
+ pseudo_t target = dom->target;
+ if (dom->opcode == OP_LOAD)
+ target = load_dominator(insn, dom);
+ convert_load_insn(insn, target);
return 1;
}