Line 443... |
Line 443... |
change_insn_type (&insn[n1 + n2 - 1], II_NOP);
|
change_insn_type (&insn[n1 + n2 - 1], II_NOP);
|
} else change_insn_type (&insn[ninsn - 1], II_NOP); /* do not use branch slot */
|
} else change_insn_type (&insn[ninsn - 1], II_NOP); /* do not use branch slot */
|
}
|
}
|
|
|
#if 1
|
#if 1
|
/* LRBB at start of succ BB is not valid, it should be set when */
|
/* LRBB at start of succ BB is not valid anymore */
|
if (insn[n1].index == II_LRBB) {
|
if (insn[n1].index == II_LRBB) {
|
if (type == 1) {
|
if (type == 1) {
|
/* We have two possibilities, how this could have happened:
|
/* We have two possibilities, how this could have happened:
|
1. we just moved second predecessor of succ to pred,
|
1. we just moved second predecessor of succ to pred,
|
pred now having two predecessors => everything is ok
|
pred now having two predecessors => everything is ok
|
Line 546... |
Line 546... |
f->bb[pred].next[1] = f->bb[succ].next[1];
|
f->bb[pred].next[1] = f->bb[succ].next[1];
|
break;
|
break;
|
}
|
}
|
if (f->bb[pred].next[0] < 0) f->bb[pred].next[0] = f->bb[pred].next[1];
|
if (f->bb[pred].next[0] < 0) f->bb[pred].next[0] = f->bb[pred].next[1];
|
if (f->bb[pred].next[0] == f->bb[pred].next[1]) f->bb[pred].next[1] = -1;
|
if (f->bb[pred].next[0] == f->bb[pred].next[1]) f->bb[pred].next[1] = -1;
|
|
|
|
/* We just did something stupid -- we joined two predecessors into one;
|
|
succ may need the information from which block we came. We will repair
|
|
this by converting LRBB to CMOV */
|
|
for (i = 0; i < 2; i++) {
|
|
int nb = f->bb[pred].next[i];
|
|
int t;
|
|
|
|
/* check just valid connections */
|
|
if (nb < 0 || nb == BBID_END) continue;
|
|
|
|
/* check type */
|
|
if (f->bb[nb].prev[0] == pred && f->bb[nb].prev[1] == succ) t = 1;
|
|
else if (f->bb[nb].prev[1] == pred && f->bb[nb].prev[0] == succ) t = 0;
|
|
else continue;
|
|
|
|
/* LRBB can only be first instruction. */
|
|
if (f->bb[nb].insn[0].index == II_LRBB) {
|
|
cuc_insn *lrbb =&f->bb[nb].insn[0];
|
|
change_insn_type (lrbb, II_CMOV);
|
|
lrbb->op[1] = t; lrbb->opt[1] = OPT_CONST;
|
|
lrbb->op[2] = 1 - t; lrbb->opt[2] = OPT_CONST;
|
|
lrbb->op[3] = cond_op; lrbb->opt[3] = cond_opt;
|
|
lrbb->type |= IT_COND;
|
|
}
|
|
}
|
|
|
f->bb[succ].type = BB_DEAD;
|
f->bb[succ].type = BB_DEAD;
|
//printf (" %x %x %x %x %x\n", f->bb[pred].next[0], f->bb[pred].next[1], f->bb[succ].next[0], f->bb[succ].next[1], insn[ninsn - 1].type);
|
//printf (" %x %x %x %x %x\n", f->bb[pred].next[0], f->bb[pred].next[1], f->bb[succ].next[0], f->bb[succ].next[1], insn[ninsn - 1].type);
|
/* remove branch instruction, if there is only one successor */
|
/* remove branch instruction, if there is only one successor */
|
if (f->bb[pred].next[1] < 0 && insn[ninsn - 1].type & IT_BRANCH) {
|
if (f->bb[pred].next[1] < 0 && insn[ninsn - 1].type & IT_BRANCH) {
|
assert (f->bb[pred].next[0] != pred); /* end BB, loop should not be possible */
|
assert (f->bb[pred].next[0] != pred); /* end BB, loop should not be possible */
|
Line 622... |
Line 649... |
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
/* Type 0 joining
|
/* Ordering of joining types is cruical -- we should concat all directly connected BBs
|
1. link between pred & succ
|
together first, so when we do a type != 1 joining, we can remove LRBB, directly by
|
2. no memory accesses in succ
|
looking at number of its predeccessors */
|
3. optional pred's second successors
|
|
4. max. one succ's successors */
|
|
for (i = 0; i < f->num_bb; i++) if (!(f->bb[i].type & BB_DEAD))
|
|
if (f->bb[i].prev[0] >= 0 && f->bb[i].prev[1] < 0 /* one predecessor */
|
|
&& f->bb[i].next[1] < 0 /* max. one successor */
|
|
&& f->bb[i].nmemory == 0) { /* and no memory acceses */
|
|
join_bb (f, f->bb[i].prev[0], i, 0);
|
|
goto remove_lrbb;
|
|
}
|
|
|
|
/* Type 1 joining
|
/* Type 1 joining
|
1. link between pred & succ
|
1. link between pred & succ
|
2. no other pred's successors
|
2. no other pred's successors
|
3. no other succ's predecessors, except if pred has max one */
|
3. no other succ's predecessors, except if pred has max one */
|
Line 664... |
Line 682... |
assert (f->bb[i].prev[0] >= 0 && f->bb[i].prev[1] < 0); /* one predecessor */
|
assert (f->bb[i].prev[0] >= 0 && f->bb[i].prev[1] < 0); /* one predecessor */
|
join_bb (f, f->bb[i].prev[0], i, 1);
|
join_bb (f, f->bb[i].prev[0], i, 1);
|
goto remove_lrbb;
|
goto remove_lrbb;
|
}
|
}
|
|
|
|
/* Type 0 joining
|
|
1. link between pred & succ
|
|
2. no memory accesses in succ
|
|
3. optional pred's second successors
|
|
4. max. one succ's successors */
|
|
for (i = 0; i < f->num_bb; i++) if (!(f->bb[i].type & BB_DEAD))
|
|
if (f->bb[i].prev[0] >= 0 && f->bb[i].prev[1] < 0 /* one predecessor */
|
|
&& f->bb[i].next[1] < 0 /* max. one successor */
|
|
&& f->bb[i].nmemory == 0) { /* and no memory acceses */
|
|
join_bb (f, f->bb[i].prev[0], i, 0);
|
|
goto remove_lrbb;
|
|
}
|
|
|
#if 1
|
#if 1
|
/* Type 2 joining
|
/* Type 2 joining
|
1. link between pred & succ
|
1. link between pred & succ
|
2. succ has exactly one predeccessor
|
2. succ has exactly one predeccessor
|
3. pred & succ share common successor
|
3. pred & succ share common successor
|