]> git.gag.com Git - fw/sdcc/commitdiff
Fixed loopreversal bug.
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 9 Sep 2001 17:33:26 +0000 (17:33 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 9 Sep 2001 17:33:26 +0000 (17:33 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1250 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c

index 6c0d58da83d24b92f7d7bd8b421fefe3eda28e9a..c497d19bc41f979dbb99c32fbffde1b78da12a29 100644 (file)
@@ -1422,11 +1422,25 @@ astHasSymbol (ast * tree, symbol * sym)
       else
        return FALSE;
     }
-
+  
   return astHasSymbol (tree->left, sym) ||
     astHasSymbol (tree->right, sym);
 }
 
+/*-----------------------------------------------------------------*/
+/* astHasDeref - return true if the ast has an indirect access     */
+/*-----------------------------------------------------------------*/
+static bool 
+astHasDeref (ast * tree)
+{
+  if (!tree || IS_AST_LINK (tree) || IS_AST_VALUE(tree))
+    return FALSE;
+
+  if (tree->opval.op == '*' && tree->right == NULL) return TRUE;
+  
+  return astHasDeref (tree->left) || astHasDeref (tree->right);
+}
+
 /*-----------------------------------------------------------------*/
 /* isConformingBody - the loop body has to conform to a set of rules */
 /* for the loop to be considered reversible read on for rules      */
@@ -1577,6 +1591,8 @@ isConformingBody (ast * pbody, symbol * sym, ast * body)
 
       if (astHasVolatile (pbody->left))
        return FALSE;
+      
+      if (astHasDeref(pbody->right)) return FALSE;
 
       return isConformingBody (pbody->left, sym, body) &&
        isConformingBody (pbody->right, sym, body);