aboutsummaryrefslogtreecommitdiffstats
path: root/cse.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-12-07 20:05:09 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:05:35 -0700
commit8c08c764f0a0e5de5be15fa7b5a1fa49392e7546 (patch)
treef6a166e4fd726b7ab37609fbd15b376c22ddddf1 /cse.c
parent2d8d9bda591831a9d0acc478f7d3b8fa35032b6e (diff)
downloadsparse-8c08c764f0a0e5de5be15fa7b5a1fa49392e7546.tar.gz
sparse-8c08c764f0a0e5de5be15fa7b5a1fa49392e7546.tar.xz
sparse-8c08c764f0a0e5de5be15fa7b5a1fa49392e7546.zip
Be more aggressive on PHI-node CSE.
We don't care _where_ a PHI-node is, since the real location is at the phi sources. So unlike other instructions, we do not bother with any dominance analysis - we can just combine them blindly across basic block borders. It might make sense to totally disconnect the PHI nodes from the flow graph to make this lack of positional information even more explicit. That might also allow us to combine more basic blocks.
Diffstat (limited to 'cse.c')
-rw-r--r--cse.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/cse.c b/cse.c
index 6835aac..866bff2 100644
--- a/cse.c
+++ b/cse.c
@@ -84,7 +84,7 @@ static void clean_up_one_instruction(struct basic_block *bb, struct instruction
pseudo_t phi;
FOR_EACH_PTR(insn->phi_list, phi) {
struct instruction *def;
- if (phi == VOID)
+ if (phi == VOID || !phi->def)
continue;
def = phi->def;
hash += hashval(def->src1);
@@ -134,9 +134,9 @@ static int phi_list_compare(struct pseudo_list *l1, struct pseudo_list *l2)
for (;;) {
int cmp;
- while (phi1 == VOID)
+ while (phi1 && (phi1 == VOID || !phi1->def))
NEXT_PTR_LIST(phi1);
- while (phi2 == VOID)
+ while (phi2 && (phi2 == VOID || !phi2->def))
NEXT_PTR_LIST(phi2);
if (!phi1)
@@ -300,6 +300,13 @@ static struct instruction * try_to_cse(struct entrypoint *ep, struct instruction
b2 = i2->bb;
/*
+ * PHI-nodes do not care where they are - the only thing that matters
+ * are the PHI _sources_.
+ */
+ if (i1->opcode == OP_PHI)
+ return cse_one_instruction(i1, i2);
+
+ /*
* Currently we only handle the uninteresting degenerate case where
* the CSE is inside one basic-block.
*/