}
+/*-----------------------------------------------------------------*/
+/* findBackwardDef - scan backwards to find deinition of operand */
+/*-----------------------------------------------------------------*/
+iCode *findBackwardDef(operand *op,iCode *ic)
+{
+ iCode *lic;
+
+ for (lic = ic; lic ; lic = lic->prev) {
+ if (IC_RESULT(lic) && isOperandEqual(op,IC_RESULT(lic)))
+ return lic;
+ }
+ return NULL;
+}
+
/*-----------------------------------------------------------------*/
/* algebraicOpts - does some algebraic optimizations */
/*-----------------------------------------------------------------*/
IC_LEFT (ic) = NULL;
IC_RESULT (ic) = operandFromOperand (IC_RESULT (ic));
IC_RESULT (ic)->isaddr = 0;
+ break;
}
/* if this is a division then check if right */
/* is one then change it to an assignment */
IC_RESULT (ic)->operand.symOperand;
}
+#if 0 /* this needs furthur investigation can save a lot of code */
+ if (ASSIGN_SYM_TO_ITEMP(ic) &&
+ !SPIL_LOC(IC_RESULT(ic))) {
+ if (!OTHERS_PARM (OP_SYMBOL (IC_RIGHT (ic))))
+ SPIL_LOC (IC_RESULT (ic)) =
+ IC_RIGHT (ic)->operand.symOperand;
+ }
+#endif
if (ASSIGN_ITEMP_TO_ITEMP (ic)) {
if (!SPIL_LOC (IC_RIGHT (ic)) &&
/* this check is a hueristic to prevent live ranges
from becoming too long */
if (IS_PTR (operandType (IC_RESULT (ic))))
- return 0;
+ return 0;
/* check if operation with a literal */
if (!IS_OP_LITERAL (IC_RIGHT (ic)))
{
if (IS_ITEMP (pdop) || IS_OP_LITERAL (pdop))
{
+ /* some non dominating block does POINTER_SET with
+ this variable .. unsafe to remove any POINTER_GETs */
+ if (bitVectBitValue(ebb->ndompset,IC_LEFT(ic)->key))
+ ebb->ptrsSet = bitVectSetBit(ebb->ptrsSet,pdop->key);
IC_LEFT (ic) = pdop;
change = 1;
}
/* Alternate code */
if (pdic && IS_ITEMP(IC_RESULT(ic))) {
+ if (POINTER_GET(ic) && bitVectBitValue(ebb->ptrsSet,IC_LEFT(ic)->key)) {
+ /* Mmm, found an equivalent pointer get at a lower level.
+ This could be a loop however with the same pointer set
+ later on */
+ } else {
/* if previous definition found change this to an assignment */
ic->op = '=';
IC_LEFT(ic) = NULL;
IC_RIGHT(ic) = operandFromOperand(IC_RESULT(pdic));
SET_ISADDR(IC_RESULT(ic),0);
SET_ISADDR(IC_RIGHT (ic),0);
+ }
}
if (!(POINTER_SET (ic)) && IC_RESULT (ic)) {