aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-09-21 01:53:36 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-07-01 00:18:44 +0200
commitf0abb143f3e3d776ee4e227a8cbb30620a799be8 (patch)
tree6d08bcd80950f7cc585a82ac49b09772a9b45c0c
parent4786ecebf608a8e86df43e396b037990a5710206 (diff)
downloadsparse-dev-f0abb143f3e3d776ee4e227a8cbb30620a799be8.tar.gz
dom: use domtree for bb_dominates()
The function bb_dominates() do a dominance query on two BB but do this by walking the CFG tree. Now that we have the dominance tree, we don't need anymore to do this walk, we can use the dom tree itself. This patch just replace the calls bb_dominates() by domtree_dominates() since they have a slightly different interface. Note: in the next version, it'll be better/simpler to rename domtree_dominates() by bb_dominates(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--cse.c27
1 files changed, 3 insertions, 24 deletions
diff --git a/cse.c b/cse.c
index 848ac512..006abc78 100644
--- a/cse.c
+++ b/cse.c
@@ -14,6 +14,7 @@
#include "parse.h"
#include "expression.h"
+#include "flowgraph.h"
#include "linearize.h"
#include "flow.h"
#include "cse.h"
@@ -272,28 +273,6 @@ static struct instruction * cse_one_instruction(struct instruction *insn, struct
return def;
}
-/*
- * Does "bb1" dominate "bb2"?
- */
-static int bb_dominates(struct entrypoint *ep, struct basic_block *bb1, struct basic_block *bb2, unsigned long generation)
-{
- struct basic_block *parent;
-
- /* Nothing dominates the entrypoint.. */
- if (bb2 == ep->entry->bb)
- return 0;
- FOR_EACH_PTR(bb2->parents, parent) {
- if (parent == bb1)
- continue;
- if (parent->generation == generation)
- continue;
- parent->generation = generation;
- if (!bb_dominates(ep, bb1, parent, generation))
- return 0;
- } END_FOR_EACH_PTR(parent);
- return 1;
-}
-
static struct basic_block *trivial_common_parent(struct basic_block *bb1, struct basic_block *bb2)
{
struct basic_block *parent;
@@ -347,10 +326,10 @@ static struct instruction * try_to_cse(struct entrypoint *ep, struct instruction
warning(b1->pos, "Whaa? unable to find CSE instructions");
return i1;
}
- if (bb_dominates(ep, b1, b2, ++bb_generation))
+ if (domtree_dominates(b1, b2))
return cse_one_instruction(i2, i1);
- if (bb_dominates(ep, b2, b1, ++bb_generation))
+ if (domtree_dominates(b2, b1))
return cse_one_instruction(i1, i2);
/* No direct dominance - but we could try to find a common ancestor.. */