Line 605... |
Line 605... |
ii->op[3] = prev->op[1]; ii->opt[3] = prev->opt[1];
|
ii->op[3] = prev->op[1]; ii->opt[3] = prev->opt[1];
|
return 1;
|
return 1;
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
|
/* Check if both choices can be pushed through */
|
|
if (ii->opt[1] & OPT_REF && ii->opt[2] & OPT_REF) {
|
|
cuc_insn *a, *b;
|
|
a = &f->INSN(ii->op[1]);
|
|
b = &f->INSN(ii->op[2]);
|
|
if (a->index == b->index && !(a->type & IT_VOLATILE) && !(b->type & IT_VOLATILE)) {
|
|
int diff = -1;
|
|
int i;
|
|
for (i = 0; i < MAX_OPERANDS; i++)
|
|
if (a->opt[i] != b->opt[i] || !(a->op[i] == b->op[i] || a->opt[i] & OPT_REGISTER)) {
|
|
if (diff == -1) diff = i; else diff = -2;
|
|
}
|
|
/* If diff == -1, it will be eliminated by CSE */
|
|
if (diff >= 0) {
|
|
cuc_insn tmp, cmov;
|
|
int ref2 = REF (REF_BB (ref), REF_I (ref) + 1);
|
|
insert_insns (f, ref, 1);
|
|
a = &f->INSN(f->INSN(ref2).op[1]);
|
|
b = &f->INSN(f->INSN(ref2).op[2]);
|
|
cucdebug (4, "ref = %x %x %x\n", ref, f->INSN(ref2).op[1], f->INSN(ref2).op[2]);
|
|
if (cuc_debug >= 7) {
|
|
print_cuc_bb (f, "AAA");
|
|
cuc_check (f);
|
|
}
|
|
tmp = *a;
|
|
cmov = f->INSN(ref2);
|
|
tmp.op[diff] = ref; tmp.opt[diff] = OPT_REF;
|
|
cmov.op[1] = a->op[diff]; cmov.opt[1] = a->opt[diff];
|
|
cmov.op[2] = b->op[diff]; cmov.opt[2] = b->opt[diff];
|
|
change_insn_type (&cmov, II_CMOV);
|
|
cmov.type &= ~IT_COND;
|
|
cucdebug (4, "ref2 = %x %x %x\n", ref2, cmov.op[1], cmov.op[2]);
|
|
if (cmov.opt[1] & OPT_REF && cmov.opt[2] & OPT_REF
|
|
&& f->INSN(cmov.op[1]).type & IT_COND) {
|
|
assert (f->INSN(cmov.op[2]).type & IT_COND);
|
|
cmov.type |= IT_COND;
|
|
}
|
|
f->INSN(ref) = cmov;
|
|
f->INSN(ref2) = tmp;
|
|
if (cuc_debug >= 6) print_cuc_bb (f, "BBB");
|
|
cuc_check (f);
|
|
}
|
|
}
|
|
}
|
return 0;
|
return 0;
|
}
|
}
|
|
|
/* Optimizes dataflow tree */
|
/* Optimizes dataflow tree */
|
int optimize_tree (cuc_func *f)
|
int optimize_tree (cuc_func *f)
|
Line 751... |
Line 796... |
} else /* sub - sfxx joining */
|
} else /* sub - sfxx joining */
|
if (prev->index == II_SUB && (
|
if (prev->index == II_SUB && (
|
ii->index == II_SFEQ || ii->index == II_SFNE
|
ii->index == II_SFEQ || ii->index == II_SFNE
|
|| ii->index == II_SFLT || ii->index == II_SFLE
|
|| ii->index == II_SFLT || ii->index == II_SFLE
|
|| ii->index == II_SFGT || ii->index == II_SFGE)) {
|
|| ii->index == II_SFGT || ii->index == II_SFGE)) {
|
if (ii->opt[2] & OPT_CONST) {
|
if (ii->opt[2] & OPT_CONST && ii->op[2] < 0x80000000) {
|
ii->op[1] = prev->op[1]; ii->opt[1] = prev->opt[1];
|
ii->op[1] = prev->op[1]; ii->opt[1] = prev->opt[1];
|
ii->op[2] += prev->op[2];
|
ii->op[2] += prev->op[2];
|
modified = 1; cucdebug (2, "%8x: sub-sfxx\n", REF(b, i));
|
modified = 1; cucdebug (2, "%8x: sub-sfxx\n", REF(b, i));
|
}
|
}
|
}
|
}
|