Line 460... |
Line 460... |
} 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 anymore */
|
/* LRBB at start of succ BB is not valid anymore */
|
if (insn[n1].index == II_LRBB) {
|
if (n1 > 0 && 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
|
2. we just moved second predecessor of succ to pred,
|
2. we just moved second predecessor of succ to pred,
|
Line 536... |
Line 536... |
}
|
}
|
|
|
if (cuc_debug) cuc_check (f);
|
if (cuc_debug) cuc_check (f);
|
if (f->bb[succ].type & BB_END) {
|
if (f->bb[succ].type & BB_END) {
|
f->bb[pred].type |= BB_END;
|
f->bb[pred].type |= BB_END;
|
if (insn[ninsn - 1].type & IT_BRANCH && insn[ninsn - 1].op[0] == succ) {
|
if (ninsn > 0 && insn[ninsn - 1].type & IT_BRANCH && insn[ninsn - 1].op[0] == succ) {
|
assert (insn[ninsn - 1].opt[0] & OPT_BB);
|
assert (insn[ninsn - 1].opt[0] & OPT_BB);
|
insn[ninsn - 1].op[0] = BBID_END;
|
insn[ninsn - 1].op[0] = BBID_END;
|
}
|
}
|
}
|
}
|
i = 0;
|
i = 0;
|
Line 591... |
Line 591... |
}
|
}
|
|
|
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 && ninsn > 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 */
|
change_insn_type (&insn[ninsn - 1], II_NOP);
|
change_insn_type (&insn[ninsn - 1], II_NOP);
|
}
|
}
|
|
|
/* Set max count */
|
/* Set max count */
|
Line 1266... |
Line 1266... |
ii->op[2] = REF (b1 - 1, pb->ninsn - 1);
|
ii->op[2] = REF (b1 - 1, pb->ninsn - 1);
|
ii->opt[2] = OPT_REF;
|
ii->opt[2] = OPT_REF;
|
}
|
}
|
/* {z = x || y;} is same as {z = x ? x : y;} */
|
/* {z = x || y;} is same as {z = x ? x : y;} */
|
ii->op[3] = ii->op[1]; ii->opt[3] = ii->opt[1];
|
ii->op[3] = ii->op[1]; ii->opt[3] = ii->opt[1];
|
ii->type |= IT_COND;
|
ii->type = IT_COND;
|
|
|
/* Only one should be in loop, so we remove any INLOOP flags from duplicates */
|
/* Only one should be in loop, so we remove any INLOOP flags from duplicates */
|
n->bb[b1].type &= ~(BB_END | BB_INLOOP);
|
n->bb[b1].type &= ~(BB_END | BB_INLOOP);
|
n->bb[b1].prev[0] = prevart_b;
|
n->bb[b1].prev[0] = prevart_b;
|
n->bb[b1].prev[1] = b1 - 1;
|
n->bb[b1].prev[1] = b1 - 1;
|
Line 1410... |
Line 1410... |
ii->op[2] = REF (b1 - 1, pb->ninsn - 1);
|
ii->op[2] = REF (b1 - 1, pb->ninsn - 1);
|
ii->opt[2] = OPT_REF;
|
ii->opt[2] = OPT_REF;
|
}
|
}
|
/* {z = x || y;} is same as {z = x ? x : y;} */
|
/* {z = x || y;} is same as {z = x ? x : y;} */
|
ii->op[3] = ii->op[1]; ii->opt[3] = ii->opt[1];
|
ii->op[3] = ii->op[1]; ii->opt[3] = ii->opt[1];
|
ii->type |= IT_COND;
|
ii->type = IT_COND;
|
|
|
/* Only one should be in loop, so we remove any INLOOP flags from duplicates */
|
/* Only one should be in loop, so we remove any INLOOP flags from duplicates */
|
n->bb[b1].type &= ~(BB_END | BB_INLOOP);
|
n->bb[b1].type &= ~(BB_END | BB_INLOOP);
|
n->bb[b1].prev[0] = prevart_b;
|
n->bb[b1].prev[0] = prevart_b;
|
n->bb[b1].prev[1] = b1 - 1;
|
n->bb[b1].prev[1] = b1 - 1;
|
Line 1501... |
Line 1501... |
//print_cuc_bb (n, "preunroll");
|
//print_cuc_bb (n, "preunroll");
|
free (counts);
|
free (counts);
|
return n;
|
return n;
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|
|
/* Calculates facts, that are determined by conditionals */
|
|
void insert_conditional_facts (cuc_func *f)
|
|
{
|
|
int b, i, j;
|
|
cuc_insn n[2];
|
|
for (b = 0; b < f->num_bb; b++) {
|
|
cuc_insn *ii = &f->bb[b].insn[f->bb[b].ninsn - 1];
|
|
if (ii->type & IT_BRANCH
|
|
&& ii->opt[1] & OPT_REF && f->INSN(ii->op[1]).opt[2] & OPT_CONST) {
|
|
int ok = 1;
|
|
unsigned long c = f->INSN(ii->op[1]).op[2];
|
|
change_insn_type (&n[0], II_NOP);
|
|
change_insn_type (&n[1], II_NOP);
|
|
|
|
/* First get the conditional and two instruction to place after the current BB */
|
|
switch (f->INSN(ii->op[1]).index) {
|
|
case II_SFEQ:
|
|
change_insn_type (&n[0], II_ADD);
|
|
n[0].type = 0;
|
|
n[0].dep = NULL;
|
|
n[0].op[0] = -1; n[0].opt[0] = OPT_REGISTER | OPT_DEST;
|
|
n[0].op[1] = 0; n[0].opt[1] = OPT_CONST;
|
|
n[0].op[2] = c; n[0].opt[2] = OPT_CONST;
|
|
break;
|
|
case II_SFNE:
|
|
change_insn_type (&n[1], II_ADD);
|
|
n[1].type = 0;
|
|
n[1].dep = NULL;
|
|
n[1].op[0] = -1; n[1].opt[0] = OPT_REGISTER | OPT_DEST;
|
|
n[1].op[1] = 0; n[1].opt[1] = OPT_CONST;
|
|
n[1].op[2] = c; n[1].opt[2] = OPT_CONST;
|
|
break;
|
|
case II_SFLT:
|
|
change_insn_type (&n[0], II_AND);
|
|
n[0].type = 0;
|
|
n[0].dep = NULL;
|
|
n[0].op[0] = -1; n[0].opt[0] = OPT_REGISTER | OPT_DEST;
|
|
n[0].op[1] = 0; n[0].opt[1] = OPT_CONST;
|
|
n[0].op[2] = (1 << (log2 (c) + 1)) - 1; n[0].opt[2] = OPT_CONST;
|
|
break;
|
|
case II_SFGT:
|
|
change_insn_type (&n[1], II_ADD);
|
|
n[1].type = 0;
|
|
n[1].dep = NULL;
|
|
n[1].op[0] = -1; n[1].opt[0] = OPT_REGISTER | OPT_DEST;
|
|
n[1].op[1] = 0; n[1].opt[1] = OPT_CONST;
|
|
n[1].op[2] = (1 << (log2 (c + 1) + 1)) - 1; n[1].opt[2] = OPT_CONST;
|
|
break;
|
|
case II_SFLE:
|
|
change_insn_type (&n[0], II_AND);
|
|
n[0].type = 0;
|
|
n[0].dep = NULL;
|
|
n[0].op[0] = -1; n[0].opt[0] = OPT_REGISTER | OPT_DEST;
|
|
n[0].op[1] = 0; n[0].opt[1] = OPT_CONST;
|
|
n[0].op[2] = (1 << (log2 (c + 1) + 1)) - 1; n[0].opt[2] = OPT_CONST;
|
|
break;
|
|
case II_SFGE:
|
|
change_insn_type (&n[1], II_ADD);
|
|
n[1].type = 0;
|
|
n[1].dep = NULL;
|
|
n[1].op[0] = -1; n[1].opt[0] = OPT_REGISTER | OPT_DEST;
|
|
n[1].op[1] = 0; n[1].opt[1] = OPT_CONST;
|
|
n[1].op[2] = (1 << (log2 (c) + 1)) - 1; n[1].opt[2] = OPT_CONST;
|
|
break;
|
|
default:
|
|
ok = 0;
|
|
break;
|
|
}
|
|
/* Now add two BBs at the end and relink */
|
|
if (ok) {
|
|
for (j = 0; j < 2; j++) {
|
|
int nb = f->num_bb++;
|
|
int sb;
|
|
assert (nb < MAX_BB);
|
|
f->bb[nb].type = 0;
|
|
f->bb[nb].first = -1; f->bb[nb].last = -1;
|
|
f->bb[nb].prev[0] = b; f->bb[nb].prev[1] = -1;
|
|
sb = f->bb[nb].next[0] = f->bb[b].next[j]; f->bb[nb].next[1] = -1;
|
|
printf ("%x %x %x\n", b, sb, nb);
|
|
assert (sb >= 0);
|
|
f->bb[b].next[j] = nb;
|
|
if (sb != BBID_END) {
|
|
if (f->bb[sb].prev[0] == b) f->bb[sb].prev[0] = nb;
|
|
else if (f->bb[sb].prev[1] == b) f->bb[sb].prev[1] = nb;
|
|
else assert (0);
|
|
}
|
|
f->bb[nb].insn = (cuc_insn *) malloc (sizeof (cuc_insn));
|
|
f->bb[nb].insn[0] = n[j];
|
|
f->bb[nb].ninsn = 1;
|
|
f->bb[nb].mdep = NULL;
|
|
f->bb[nb].nmemory = 0;
|
|
f->bb[nb].cnt = 0;
|
|
f->bb[nb].unrolled = 0;
|
|
f->bb[nb].ntim = 0;
|
|
f->bb[nb].selected_tim = -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|