added function findbackward def (to be used in upcoming optimization)
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 30 Jan 2002 04:12:38 +0000 (04:12 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 30 Jan 2002 04:12:38 +0000 (04:12 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1862 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCcse.c
src/SDCCcse.h

index 23dece6272c69be3f1935b191d15d702d80e8058..7f439dc7eba174f70f03c277cd66e9f0a3c01141 100644 (file)
@@ -571,6 +571,20 @@ DEFSETFUNC (ifDiCodeIsX)
 
 }
 
+/*-----------------------------------------------------------------*/
+/* 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               */
 /*-----------------------------------------------------------------*/
@@ -896,6 +910,14 @@ updateSpillLocation (iCode * ic, int induction)
                                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)) &&
@@ -1109,7 +1131,7 @@ constFold (iCode * ic, set * cseSet)
   /* 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)))
index 5eaf9cf284a6e13d926f41475630b77a6dfe72c8..023afd1adc105b425efb8e2c14060298cbdf4c79 100644 (file)
@@ -57,4 +57,5 @@ void unsetDefsAndUses (iCode *);
 void updateSpillLocation (iCode * ic,int);
 void setUsesDefs (operand *, bitVect *, bitVect *, bitVect **);
 void replaceAllSymBySym (iCode *, operand *, operand *, bitVect **);
+iCode *findBackwardDef(operand *,iCode *);
 #endif