From: sandeep Date: Sun, 9 Sep 2001 17:33:26 +0000 (+0000) Subject: Fixed loopreversal bug. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=a4578248eab1e359e4cc86eafd6fb48166e53f1d;p=fw%2Fsdcc Fixed loopreversal bug. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1250 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCast.c b/src/SDCCast.c index 6c0d58da..c497d19b 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -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);