Line 232... |
Line 232... |
f->bb[i].next[0] = j;
|
f->bb[i].next[0] = j;
|
if (++f->bb[j].tmp > 2) eb++;
|
if (++f->bb[j].tmp > 2) eb++;
|
f->bb[i].next[1] = i + 1;
|
f->bb[i].next[1] = i + 1;
|
if (++f->bb[i + 1].tmp > 2) eb++;
|
if (++f->bb[i + 1].tmp > 2) eb++;
|
} else if (f->bb[i].last == num_insn - 1) { /* Last instruction doesn't have to do anything */
|
} else if (f->bb[i].last == num_insn - 1) { /* Last instruction doesn't have to do anything */
|
f->bb[i].type |= BB_END;
|
|
} else {
|
} else {
|
f->bb[i].next[0] = i + 1;
|
f->bb[i].next[0] = i + 1;
|
if (++f->bb[i + 1].tmp > 2) eb++;
|
if (++f->bb[i + 1].tmp > 2) eb++;
|
}
|
}
|
|
|
Line 252... |
Line 251... |
f->bb[--end_bb] = f->bb[i];
|
f->bb[--end_bb] = f->bb[i];
|
reloc[i] = end_bb;
|
reloc[i] = end_bb;
|
while (j-- > 2) {
|
while (j-- > 2) {
|
f->bb[--end_bb].first = f->bb[i].first;
|
f->bb[--end_bb].first = f->bb[i].first;
|
f->bb[end_bb].last = -1;
|
f->bb[end_bb].last = -1;
|
f->bb[end_bb].type &= ~BB_END;
|
|
f->bb[end_bb].next[0] = -1;
|
f->bb[end_bb].next[0] = -1;
|
f->bb[end_bb].next[1] = -1;
|
f->bb[end_bb].next[1] = -1;
|
f->bb[end_bb].tmp = 0;
|
f->bb[end_bb].tmp = 0;
|
f->bb[end_bb].cnt = f->bb[i].cnt;
|
f->bb[end_bb].cnt = f->bb[i].cnt;
|
f->bb[end_bb].ntim = 0;
|
f->bb[end_bb].ntim = 0;
|
Line 333... |
Line 331... |
/* Add START marker */
|
/* Add START marker */
|
assert (f->bb[0].prev[0] < 0);
|
assert (f->bb[0].prev[0] < 0);
|
f->bb[0].prev[0]= BBID_START;
|
f->bb[0].prev[0]= BBID_START;
|
|
|
/* Add END marker */
|
/* Add END marker */
|
for (i = 0; i < f->num_bb; i++)
|
assert (f->bb[f->num_bb - 1].next[0] < 0);
|
if (f->bb[i].type & BB_END) {
|
assert (f->bb[f->num_bb - 1].next[1] < 0);
|
assert (f->bb[i].next[0] < 0);
|
f->bb[f->num_bb - 1].next[0] = BBID_END;
|
f->bb[i].next[0] = BBID_END;
|
|
}
|
|
if (cuc_debug >= 3) print_cuc_bb (f, "AFTER_PREV");
|
if (cuc_debug >= 3) print_cuc_bb (f, "AFTER_PREV");
|
}
|
}
|
|
|
/* We do a quick check if there are some anomalies with references */
|
/* We do a quick check if there are some anomalies with references */
|
void cuc_check (cuc_func *f)
|
void cuc_check (cuc_func *f)
|
Line 358... |
Line 354... |
if ((signed)ii->op[k] >= 0 && ii->op[k] != FLAG_REG && ii->op[k] != LRBB_REG) {
|
if ((signed)ii->op[k] >= 0 && ii->op[k] != FLAG_REG && ii->op[k] != LRBB_REG) {
|
cucdebug (1, "%x %x\n", ii->opt[0], ii->op[0]);
|
cucdebug (1, "%x %x\n", ii->opt[0], ii->op[0]);
|
goto err;
|
goto err;
|
}
|
}
|
}
|
}
|
for (k = 0; k < MAX_OPERANDS; k++)
|
for (k = 0; k < MAX_OPERANDS; k++) {
|
if (ii->opt[k] & OPT_REF) {
|
if (ii->opt[k] & OPT_REF) {
|
int t = ii->op[k];
|
int t = ii->op[k];
|
if (REF_BB(t) >= f->num_bb || REF_I (t) >= f->bb[REF_BB(t)].ninsn
|
if (REF_BB(t) >= f->num_bb || REF_I (t) >= f->bb[REF_BB(t)].ninsn
|
|| (ii->index == II_CMOV || ii->index == II_ADD) && (
|
|| (ii->index == II_CMOV || ii->index == II_ADD) && (
|
(f->INSN(t).type & IT_COND) != (ii->type & IT_COND) && k < 3
|
(f->INSN(t).type & IT_COND) != (ii->type & IT_COND) && k < 3
|
|| !(f->INSN(t).type & IT_COND) && k == 3)) goto err;
|
|| !(f->INSN(t).type & IT_COND) && k == 3)) goto err;
|
}
|
}
|
|
if (k && ii->opt[k] & OPT_DEST) {
|
|
cucdebug (1, "Destination only allowed for op0!\n");
|
|
goto err;
|
|
}
|
|
}
|
}
|
}
|
}
|
}
|
return;
|
return;
|
err:
|
err:
|
cucdebug (1, "Anomaly detected at %x.%x[%i]\n", i, j, k);
|
cucdebug (1, "Anomaly detected at %x.%x[%i]\n", i, j, k);
|
Line 606... |
Line 607... |
sprintf (ii->disasm, "cmov (join BB)");
|
sprintf (ii->disasm, "cmov (join BB)");
|
}
|
}
|
}
|
}
|
|
|
if (cuc_debug) cuc_check (f);
|
if (cuc_debug) cuc_check (f);
|
if (f->bb[succ].type & BB_END) {
|
|
f->bb[pred].type |= BB_END;
|
|
if (ninsn > 0 && insn[ninsn - 1].type & IT_BRANCH && insn[ninsn - 1].op[0] == succ) {
|
|
assert (insn[ninsn - 1].opt[0] & OPT_BB);
|
|
insn[ninsn - 1].op[0] = BBID_END;
|
|
}
|
|
}
|
|
i = 0;
|
i = 0;
|
assert (f->bb[pred].next[0] >= 0 && f->bb[pred].next[0] != BBID_END);
|
|
switch (type) {
|
switch (type) {
|
case 0:
|
case 0:
|
|
assert (f->bb[pred].next[0] >= 0);
|
if (f->bb[pred].next[0] == succ) f->bb[pred].next[0] = f->bb[succ].next[0];
|
if (f->bb[pred].next[0] == succ) f->bb[pred].next[0] = f->bb[succ].next[0];
|
if (f->bb[pred].next[1] == succ) f->bb[pred].next[1] = f->bb[succ].next[0];
|
if (f->bb[pred].next[1] == succ) f->bb[pred].next[1] = f->bb[succ].next[0];
|
assert (f->bb[succ].next[1] < 0);
|
|
break;
|
break;
|
case 1:
|
case 1:
|
|
assert (f->bb[pred].next[0] >= 0 && f->bb[pred].next[0] != BBID_END);
|
f->bb[pred].next[0] = f->bb[succ].next[0];
|
f->bb[pred].next[0] = f->bb[succ].next[0];
|
f->bb[pred].next[1] = f->bb[succ].next[1];
|
f->bb[pred].next[1] = f->bb[succ].next[1];
|
break;
|
break;
|
case 2:
|
case 2:
|
|
assert (f->bb[pred].next[0] >= 0 && f->bb[pred].next[0] != BBID_END);
|
f->bb[pred].next[0] = f->bb[succ].next[0];
|
f->bb[pred].next[0] = f->bb[succ].next[0];
|
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;
|
|
|
|
if (type == 0) assert (f->bb[succ].next[1] < 0);
|
|
|
/* We just did something stupid -- we joined two predecessors into one;
|
/* We just did something stupid -- we joined two predecessors into one;
|
succ may need the information from which block we came. We will repair
|
succ may need the information from which block we came. We will repair
|
this by converting LRBB to CMOV */
|
this by converting LRBB to CMOV */
|
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
int nb = f->bb[pred].next[j];
|
int nb = f->bb[pred].next[j];
|
Line 1071... |
Line 1068... |
for (b = 0; b < f->num_bb; b++)
|
for (b = 0; b < f->num_bb; b++)
|
for (i = 0; i < f->bb[b].ninsn; i++)
|
for (i = 0; i < f->bb[b].ninsn; i++)
|
if (f->bb[b].insn[i].type & IT_UNUSED) change_insn_type (&f->bb[b].insn[i], II_NOP);
|
if (f->bb[b].insn[i].type & IT_UNUSED) change_insn_type (&f->bb[b].insn[i], II_NOP);
|
|
|
/* SSAs with final register value are marked as outputs */
|
/* SSAs with final register value are marked as outputs */
|
assert (f->bb[f->num_bb - 1].type & BB_END);
|
assert (f->bb[f->num_bb - 1].next[0] == BBID_END);
|
for (i = 0; i < MAX_REGS; i++) if (!caller_saved[i]) {
|
for (i = 0; i < MAX_REGS; i++) if (!caller_saved[i]) {
|
int t = f->bb[f->num_bb - 1].last_used_reg[i];
|
int t = f->bb[f->num_bb - 1].last_used_reg[i];
|
/* Mark them volatile, so optimizer does not remove them */
|
/* Mark them volatile, so optimizer does not remove them */
|
if (t >= 0) f->bb[REF_BB(t)].insn[REF_I(t)].type |= IT_OUTPUT;
|
if (t >= 0) f->bb[REF_BB(t)].insn[REF_I(t)].type |= IT_OUTPUT;
|
}
|
}
|
Line 1286... |
Line 1283... |
if (t < i) bb->insn[i].op[j] = REF (back, t);
|
if (t < i) bb->insn[i].op[j] = REF (back, t);
|
else bb->insn[i].op[j] = REF (fwd, t);
|
else bb->insn[i].op[j] = REF (fwd, t);
|
}
|
}
|
}
|
}
|
|
|
/* Unroll loop b unroll times and return new function. Original
|
/* Preroll if type == 1 or unroll if type == 0 loop in BB b `ntimes' times and return
|
function is unmodified. */
|
new function. Original function is unmodified. */
|
static cuc_func *unroll_loop (cuc_func *f, int b, int unroll)
|
static cuc_func *roll_loop (cuc_func *f, int b, int ntimes, int type)
|
{
|
{
|
int b1, t, i, j, prevb, prevart_b;
|
int b1, t, i, j, prevb, prevart_b;
|
cuc_func *n = dup_func (f);
|
cuc_func *n = dup_func (f);
|
cuc_bb *ob = &f->bb[b];
|
cuc_bb *ob = &f->bb[b];
|
cuc_insn *ii;
|
cuc_insn *ii;
|
|
|
assert (unroll > 1);
|
assert (ntimes > 1);
|
//PRINTF ("unroll BB%i x %i (num_bb %i)\n", b, unroll, n->num_bb);
|
cucdebug (3, "roll type = %i, BB%i x %i (num_bb %i)\n", type, b, ntimes, n->num_bb);
|
unroll--;
|
ntimes--;
|
assert (n->num_bb + unroll * 2 < MAX_BB);
|
assert (n->num_bb + ntimes * 2 < MAX_BB);
|
|
|
prevb = b;
|
prevb = b;
|
prevart_b = b;
|
prevart_b = b;
|
/* Duplicate the BB */
|
|
for (t = 0; t < unroll; t++) {
|
|
cuc_bb *pb = &n->bb[prevart_b];
|
|
/* Add new block and set links */
|
|
b1 = n->num_bb++;
|
|
cpy_bb (&n->bb[b1], ob);
|
|
/* Only one should be in loop, so we remove any INLOOP flags from duplicates */
|
|
n->bb[b1].type &= ~(BB_END | BB_INLOOP);
|
|
|
|
/* Set predecessor's successor */
|
|
if (n->bb[prevb].next[0] == b) {
|
|
n->bb[prevb].next[0] = b1;
|
|
if (pb->next[0] < 0) pb->next[0] = b1 + 1;
|
|
else pb->next[1] = b1 + 1;
|
|
n->bb[b1].next[1] = b1 + 1;
|
|
} else if (n->bb[prevb].next[1] == b) {
|
|
if (pb->next[0] < 0) pb->next[0] = b1 + 1;
|
|
else pb->next[1] = b1 + 1;
|
|
n->bb[b1].next[0] = b1 + 1;
|
|
n->bb[prevb].next[1] = b1;
|
|
} else assert (0);
|
|
|
|
/* Set predecessor */
|
|
n->bb[b1].prev[0] = prevb;
|
|
n->bb[b1].prev[1] = -1;
|
|
|
|
/* Relocate backward references to current instance and forward references
|
|
to previous one */
|
|
relocate_bb (&n->bb[b1], b, b1, prevb);
|
|
|
|
/* add artificial block, just to join accesses */
|
|
b1 = n->num_bb++;
|
|
cpy_bb (&n->bb[b1], ob);
|
|
n->bb[b1].cnt = 0;
|
|
|
|
for (i = 0; i < ob->ninsn - 1; i++) {
|
|
ii = &n->bb[b1].insn[i];
|
|
if (ob->insn[i].opt[0] & OPT_DEST) {
|
|
change_insn_type (ii, II_CMOV);
|
|
ii->op[0] = -1; ii->opt[0] = OPT_REGISTER | OPT_DEST;
|
|
ii->op[1] = REF (prevart_b, i); ii->opt[1] = OPT_REF;
|
|
ii->op[2] = REF (b1 - 1, i); ii->opt[2] = OPT_REF;
|
|
|
|
/* Take left one, if we should have finished the first iteration*/
|
|
if (pb->insn[pb->ninsn - 1].type & IT_BRANCH) {
|
|
ii->op[3] = pb->insn[pb->ninsn - 1].op[1]; ii->opt[3] = pb->insn[pb->ninsn - 1].opt[1];
|
|
} else {
|
|
assert (pb->insn[pb->ninsn - 1].type & IT_COND);
|
|
ii->op[3] = REF (prevart_b, pb->ninsn - 1); ii->opt[3] = OPT_REF;
|
|
}
|
|
ii->dep = NULL;
|
|
ii->type = ob->insn[i].type & IT_COND;
|
|
} else {
|
|
change_insn_type (ii, II_NOP);
|
|
}
|
|
}
|
|
|
|
/* Add conditional or instruction at the end, prioritizing flags */
|
|
ii = &n->bb[b1].insn[ob->ninsn - 1];
|
|
change_insn_type (ii, II_CMOV);
|
|
ii->op[0] = FLAG_REG; ii->opt[0] = OPT_REGISTER | OPT_DEST;
|
|
if (pb->insn[pb->ninsn - 1].type & IT_BRANCH) {
|
|
ii->op[1] = pb->insn[pb->ninsn - 1].op[1];
|
|
ii->opt[1] = pb->insn[pb->ninsn - 1].opt[1];
|
|
} else {
|
|
ii->op[1] = REF (prevart_b, pb->ninsn - 1);
|
|
ii->opt[1] = OPT_REF;
|
|
}
|
|
if (n->bb[b1 - 1].insn[pb->ninsn - 1].type & IT_BRANCH) {
|
|
ii->op[2] = n->bb[b1 - 1].insn[pb->ninsn - 1].op[1];
|
|
ii->opt[2] = n->bb[b1 - 1].insn[pb->ninsn - 1].opt[1];
|
|
} else {
|
|
ii->op[2] = REF (b1 - 1, pb->ninsn - 1);
|
|
ii->opt[2] = OPT_REF;
|
|
}
|
|
/* {z = x || y;} is same as {z = x ? x : y;} */
|
|
ii->op[3] = ii->op[1]; ii->opt[3] = ii->opt[1];
|
|
ii->type = IT_COND;
|
|
|
|
/* 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].prev[0] = prevart_b;
|
|
n->bb[b1].prev[1] = b1 - 1;
|
|
n->bb[b1].next[0] = -1;
|
|
n->bb[b1].next[1] = -1;
|
|
|
|
prevb = b1 - 1;
|
|
prevart_b = b1;
|
|
}
|
|
if (ob->type & BB_END) {
|
|
n->bb[prevart_b].type |= BB_END;
|
|
n->bb[b].type &= ~BB_END;
|
|
}
|
|
|
|
n->bb[prevart_b].next[0] = ob->next[0] == b ? ob->next[1] : ob->next[0];
|
/* point to first artificial block */
|
//print_cuc_bb (n, "unroll1");
|
if (n->bb[b].next[0] != b) {
|
/* repair BB after loop, to point back to latest artificial BB */
|
n->bb[b].next[0] = n->num_bb + 1;
|
b1 = n->bb[prevart_b].next[0];
|
} else if (n->bb[b].next[1] != b) {
|
if (b1 >= 0 && b1 != BBID_END) {
|
n->bb[b].next[1] = n->num_bb + 1;
|
if (n->bb[b1].prev[0] == b) n->bb[b1].prev[0] = prevart_b;
|
|
else if (n->bb[b1].prev[1] == b) n->bb[b1].prev[1] = prevart_b;
|
|
else assert (0);
|
|
}
|
}
|
|
|
/* Relink back to start of the loop */
|
|
/* Set predecessor's successor */
|
|
if (n->bb[prevb].next[0] == b) n->bb[prevb].next[0] = b;
|
|
else if (n->bb[prevb].next[1] == b) n->bb[prevb].next[1] = b;
|
|
else assert (0);
|
|
|
|
/* Set predecessor */
|
|
if (n->bb[b].prev[0] == b) n->bb[b].prev[0] = prevb;
|
|
else if (n->bb[b].prev[1] == b) n->bb[b].prev[1] = prevb;
|
|
else assert (0);
|
|
|
|
//print_cuc_bb (n, "unroll2");
|
|
|
|
/* Relocate backward references to current instance and forward references
|
|
to previous one */
|
|
relocate_bb (&n->bb[b], b, b, prevb);
|
|
|
|
/* Relocate all other blocks to point to latest prevart_b */
|
|
for (i = 0; i < f->num_bb; i++)
|
|
if (i != b) relocate_bb (&n->bb[i], b, prevart_b, prevart_b);
|
|
|
|
return n;
|
|
}
|
|
|
|
/* Preroll loop b preroll times and return new function. Original
|
|
function is unmodified. */
|
|
static cuc_func *preroll_loop (cuc_func *f, int b, int preroll)
|
|
{
|
|
int b1, t, i, j, prevb, prevart_b;
|
|
cuc_func *n = dup_func (f);
|
|
cuc_bb *ob = &f->bb[b];
|
|
cuc_insn *ii;
|
|
|
|
assert (preroll > 1);
|
|
//PRINTF ("preroll BB%i x %i (num_bb %i)\n", b, preroll, n->num_bb);
|
|
preroll--;
|
|
assert (n->num_bb + preroll * 2 < MAX_BB);
|
|
|
|
prevb = b;
|
|
prevart_b = b;
|
|
/* Duplicate the BB */
|
/* Duplicate the BB */
|
for (t = 0; t < preroll; t++) {
|
for (t = 0; t < ntimes; t++) {
|
cuc_bb *pb = &n->bb[prevart_b];
|
cuc_bb *pb = &n->bb[prevart_b];
|
/* Add new block and set links */
|
/* Add new block and set links */
|
b1 = n->num_bb++;
|
b1 = n->num_bb++;
|
cpy_bb (&n->bb[b1], ob);
|
cpy_bb (&n->bb[b1], ob);
|
/* 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_INLOOP;
|
|
print_cuc_bb (n, "prerollA");
|
|
|
|
printf ("prevb %i b1 %i prevart %i\n", prevb, b1, prevart_b);
|
/* Set predecessor's successor */
|
/* Set predecessor's successor */
|
if (n->bb[prevb].next[0] == b) {
|
if (n->bb[prevb].next[0] == b) {
|
n->bb[prevb].next[0] = b1;
|
n->bb[prevb].next[0] = b1;
|
if (pb->next[0] < 0) pb->next[0] = b1 + 1;
|
if (pb->next[0] < 0) pb->next[0] = b1 + 1;
|
else pb->next[1] = b1 + 1;
|
else pb->next[1] = b1 + 1;
|
Line 1526... |
Line 1389... |
/* {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_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;
|
n->bb[b1].next[0] = -1;
|
n->bb[b1].next[0] = -1;
|
n->bb[b1].next[1] = -1;
|
n->bb[b1].next[1] = -1;
|
|
|
prevb = b1 - 1;
|
prevb = b1 - 1;
|
prevart_b = b1;
|
prevart_b = b1;
|
|
print_cuc_bb (n, "prerollB");
|
}
|
}
|
if (ob->type & BB_END) {
|
|
n->bb[prevart_b].type |= BB_END;
|
print_cuc_bb (n, "preroll0");
|
n->bb[b].type &= ~BB_END;
|
|
}
|
|
n->bb[prevart_b].next[0] = ob->next[0] == b ? ob->next[1] : ob->next[0];
|
n->bb[prevart_b].next[0] = ob->next[0] == b ? ob->next[1] : ob->next[0];
|
|
|
//print_cuc_bb (n, "preroll1");
|
print_cuc_bb (n, "preroll1");
|
/* repair BB after loop, to point back to latest artificial BB */
|
/* repair BB after loop, to point back to latest artificial BB */
|
b1 = n->bb[prevart_b].next[0];
|
b1 = n->bb[prevart_b].next[0];
|
if (b1 >= 0 && b1 != BBID_END) {
|
if (b1 >= 0 && b1 != BBID_END) {
|
if (n->bb[b1].prev[0] == b) n->bb[b1].prev[0] = prevart_b;
|
if (n->bb[b1].prev[0] == b) n->bb[b1].prev[0] = prevart_b;
|
else if (n->bb[b1].prev[1] == b) n->bb[b1].prev[1] = prevart_b;
|
else if (n->bb[b1].prev[1] == b) n->bb[b1].prev[1] = prevart_b;
|
else assert (0);
|
else assert (0);
|
}
|
}
|
|
|
|
if (type) {
|
/* Relink to itself */
|
/* Relink to itself */
|
/* Set predecessor's successor */
|
/* Set predecessor's successor */
|
if (n->bb[prevb].next[0] == b) n->bb[prevb].next[0] = prevb;
|
if (n->bb[prevb].next[0] == b) n->bb[prevb].next[0] = prevb;
|
else if (n->bb[prevb].next[1] == b) n->bb[prevb].next[1] = prevb;
|
else if (n->bb[prevb].next[1] == b) n->bb[prevb].next[1] = prevb;
|
else assert (0);
|
else assert (0);
|
n->bb[prevb].prev[1] = prevb;
|
n->bb[prevb].prev[1] = prevb;
|
|
|
|
/* Set predecessor */
|
if (n->bb[b].prev[0] == b) {
|
if (n->bb[b].prev[0] == b) {
|
n->bb[b].prev[0] = n->bb[b].prev[1];
|
n->bb[b].prev[0] = n->bb[b].prev[1];
|
n->bb[b].prev[1] = -1;
|
n->bb[b].prev[1] = -1;
|
} else if (n->bb[b].prev[1] == b) {
|
} else if (n->bb[b].prev[1] == b) n->bb[b].prev[1] = -1;
|
n->bb[b].prev[1] = -1;
|
else assert (0);
|
|
} else {
|
|
/* Relink back to start of the loop */
|
|
/* Set predecessor's successor */
|
|
if (n->bb[prevb].next[0] == b) n->bb[prevb].next[0] = b;
|
|
else if (n->bb[prevb].next[1] == b) n->bb[prevb].next[1] = b;
|
|
else assert (0);
|
|
|
|
/* Set predecessor */
|
|
if (n->bb[b].prev[0] == b) n->bb[b].prev[0] = prevb;
|
|
else if (n->bb[b].prev[1] == b) n->bb[b].prev[1] = prevb;
|
|
else assert (0);
|
}
|
}
|
|
|
//print_cuc_bb (n, "preroll2");
|
print_cuc_bb (n, "preroll2");
|
|
|
/* Relocate backward references to current instance and forward references
|
/* Relocate backward references to current instance and forward references
|
to previous one */
|
to previous one */
|
relocate_bb (&n->bb[b], b, b, prevb);
|
relocate_bb (&n->bb[b], b, b, prevb);
|
|
|
Line 1587... |
Line 1462... |
cuc_func *n, *t;
|
cuc_func *n, *t;
|
int *counts;
|
int *counts;
|
int *bb_reloc;
|
int *bb_reloc;
|
|
|
if (preroll > 1) {
|
if (preroll > 1) {
|
t = preroll_loop (f, b, preroll);
|
t = roll_loop (f, b, preroll, 1);
|
b1 = t->num_bb - 2;
|
b1 = t->num_bb - 2;
|
if (unroll > 1) {
|
if (unroll > 1) {
|
//print_cuc_bb (t, "preunroll1");
|
//print_cuc_bb (t, "preunroll1");
|
n = unroll_loop (t, b1, unroll);
|
n = roll_loop (t, b1, unroll, 0);
|
free_func (t);
|
free_func (t);
|
} else n = t;
|
} else n = t;
|
} else {
|
} else {
|
b1 = b;
|
b1 = b;
|
if (unroll > 1) n = unroll_loop (f, b1, unroll);
|
if (unroll > 1) n = roll_loop (f, b1, unroll, 0);
|
else return dup_func (f);
|
else return dup_func (f);
|
}
|
}
|
|
|
/* Assign new counts to functions */
|
/* Assign new counts to functions */
|
assert (counts = (int *)malloc (sizeof (int) * (preroll - 1 + unroll)));
|
assert (counts = (int *)malloc (sizeof (int) * (preroll - 1 + unroll)));
|