aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cse.c16
-rw-r--r--flow.h3
-rw-r--r--simplify.c14
3 files changed, 17 insertions, 16 deletions
diff --git a/cse.c b/cse.c
index 4de950d..21ae285 100644
--- a/cse.c
+++ b/cse.c
@@ -259,6 +259,20 @@ static int bb_dominates(struct entrypoint *ep, struct basic_block *bb1, struct b
return 1;
}
+static struct basic_block *trivial_common_parent(struct basic_block *bb1, struct basic_block *bb2)
+{
+ struct basic_block *parent;
+
+ if (bb_list_size(bb1->parents) != 1)
+ return 0;
+ parent = first_basic_block(bb1->parents);
+ if (bb_list_size(bb2->parents) != 1)
+ return 0;
+ if (first_basic_block(bb2->parents) != parent)
+ return 0;
+ return parent;
+}
+
static inline void remove_instruction(struct instruction_list **list, struct instruction *insn, int count)
{
delete_ptr_list_entry((struct ptr_list **)list, insn, count);
@@ -305,7 +319,7 @@ static struct instruction * try_to_cse(struct entrypoint *ep, struct instruction
return cse_one_instruction(i1, i2);
/* No direct dominance - but we could try to find a common ancestor.. */
- common = trivial_common_parent(b1, VOID, b2, VOID);
+ common = trivial_common_parent(b1, b2);
if (common) {
i1 = cse_one_instruction(i2, i1);
remove_instruction(&b1->insns, i1, 1);
diff --git a/flow.h b/flow.h
index cd32eba..0c0d1d7 100644
--- a/flow.h
+++ b/flow.h
@@ -30,7 +30,4 @@ extern void track_pseudo_liveness(struct entrypoint *ep);
extern void vrfy_flow(struct entrypoint *ep);
extern int pseudo_in_list(struct pseudo_list *list, pseudo_t pseudo);
-extern struct basic_block *trivial_common_parent(struct basic_block *, pseudo_t,
- struct basic_block *, pseudo_t);
-
#endif
diff --git a/simplify.c b/simplify.c
index 1d6f428..3b1ce0e 100644
--- a/simplify.c
+++ b/simplify.c
@@ -25,16 +25,6 @@ static struct basic_block *phi_parent(struct basic_block *source, pseudo_t pseud
return first_basic_block(source->parents);
}
-struct basic_block *trivial_common_parent(struct basic_block *s1, pseudo_t p1,
- struct basic_block *s2, pseudo_t p2)
-{
- s1 = phi_parent(s1, p1);
- s2 = phi_parent(s2, p2);
- if (s1 != s2)
- s1 = NULL;
- return s1;
-}
-
static void clear_phi(struct instruction *insn)
{
pseudo_t phi;
@@ -71,8 +61,8 @@ static int if_convert_phi(struct instruction *insn)
/*
* See if we can find a common source for this..
*/
- source = trivial_common_parent(bb1, p1, bb2, p2);
- if (!source)
+ source = phi_parent(bb1, p1);
+ if (source != phi_parent(bb2, p2))
return 0;
/*