aboutsummaryrefslogtreecommitdiffstats
path: root/cse.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-11-24 09:44:37 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:04:41 -0700
commit76b1ba754f31ef878d2db1e5d14fc45a9d02fd7a (patch)
treeadc5f07b8523226457d3e56efde3c5917e610f04 /cse.c
parenta90d8406a0803a3ef2a5326c87b98d667a58a60c (diff)
downloadsparse-76b1ba754f31ef878d2db1e5d14fc45a9d02fd7a.tar.gz
sparse-76b1ba754f31ef878d2db1e5d14fc45a9d02fd7a.tar.xz
sparse-76b1ba754f31ef878d2db1e5d14fc45a9d02fd7a.zip
Make phi-node normalization (part of CSE) do trivial simplification.
Diffstat (limited to 'cse.c')
-rw-r--r--cse.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/cse.c b/cse.c
index 6e4875f..a0ce997 100644
--- a/cse.c
+++ b/cse.c
@@ -42,14 +42,21 @@ static unsigned long clean_up_phi(struct instruction *insn)
{
struct phi *phi, *last;
unsigned long hash = 0;
+ int same;
sort_phi_list(&insn->phi_list);
last = NULL;
+ same = 1;
FOR_EACH_PTR(insn->phi_list, phi) {
+ if (phi->pseudo == VOID) {
+ DELETE_CURRENT_PTR(phi);
+ continue;
+ }
if (last) {
- if (last->pseudo == phi->pseudo &&
- last->source == phi->source) {
+ if (last->pseudo != phi->pseudo) {
+ same = 0;
+ } else if (last->source == phi->source) {
DELETE_CURRENT_PTR(phi);
continue;
}
@@ -59,6 +66,14 @@ static unsigned long clean_up_phi(struct instruction *insn)
hash += hashval(phi->source);
} END_FOR_EACH_PTR(phi);
+ if (same) {
+ pseudo_t pseudo = last ? last->pseudo : VOID;
+ convert_instruction_target(insn, pseudo);
+ insn->bb = NULL;
+ /* This one is bogus, but no worse than anything else */
+ return hash;
+ }
+
/* Whenever we delete pointers, we may have to pack the end result */
PACK_PTR_LIST(&insn->phi_list);
return hash;