Fixed a number of problems revealed by bug #827883.
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 30 Oct 2003 05:42:53 +0000 (05:42 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 30 Oct 2003 05:42:53 +0000 (05:42 +0000)
* src/SDCCloop.c (loopInvariants): Spill location of the
result operand should be recomputed if extracted from
a loop. Also, don't extract assignments of an iTemp
from a literal.
* src/SDCCast.c (isConformingBody): loop reversal should
not occur if the control variable is involved with a
relational operator.

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2967 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCast.c
src/SDCCloop.c

index df792fe5778aead67d3d2a870f6f9990d8532b15..7ebc3ad7e791a2fe4ac4c75ca2ae471a153c2b00 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2003-10-30 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+       Fixed a number of problems revealed by bug #827883.
+       * src/SDCCloop.c (loopInvariants): Spill location of the
+       result operand should be recomputed if extracted from
+       a loop. Also, don't extract assignments of an iTemp
+       from a literal.
+       * src/SDCCast.c (isConformingBody): loop reversal should
+       not occur if the control variable is involved with a
+       relational operator.
+
 2003-10-28 Bernhard Held <bernhard@bernhardheld.de>
 
        * .version: bumped to 2.3.6 to reflect the big improvements
index 7db25f4f605307e2121778c99db5acee13d8b065..c0d2787a56b4fddc5edff1bd24aa4e4c36f64f41 100644 (file)
@@ -1682,6 +1682,14 @@ isConformingBody (ast * pbody, symbol * sym, ast * body)
     case '?':
     case ':':
     case SIZEOF:               /* evaluate wihout code generation */
+      
+      if (IS_AST_SYM_VALUE (pbody->left) &&
+         isSymbolEqual (AST_SYMBOL (pbody->left), sym))
+       return FALSE;
+
+      if (IS_AST_SYM_VALUE (pbody->right) &&
+         isSymbolEqual (AST_SYMBOL (pbody->right), sym))
+       return FALSE;
 
       return isConformingBody (pbody->left, sym, body) &&
        isConformingBody (pbody->right, sym, body);
index 783fd3d9287a7560c61ab1f061404d2ebb3a369c..1ff5e2cdb59c8b24988aafdd4247dd2f8a8c61b1 100644 (file)
@@ -464,6 +464,13 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
 
          if (SKIP_IC (ic) || POINTER_SET (ic) || ic->op == IFX)
            continue;
+         
+         /* iTemp assignment from a literal may be invariant, but it
+            will needlessly increase register pressure if the
+            iCode(s) that use this iTemp are not also invariant */
+         if (ic->op=='=' && IS_ITEMP (IC_RESULT (ic))
+             && IS_OP_LITERAL (IC_RIGHT (ic)))
+           continue;
 
          /* if result is volatile then skip */
          if (IC_RESULT (ic) &&
@@ -507,7 +514,8 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
              applyToSet (theLoop->regBlocks, hasNonPtrUse, IC_LEFT (ic)))
            continue;
 
-         /* if both the left & right are invariants : then check that */
+
+          /* if both the left & right are invariants : then check that */
          /* this definition exists in the out definition of all the  */
          /* blocks, this will ensure that this is not assigned any   */
          /* other value in the loop , and not used in this block     */
@@ -518,7 +526,7 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
              eBBlock *sBlock;
              set *lSet = setFromSet (theLoop->regBlocks);
 
-             /* if this block does not dominate all exists */
+             /* if this block does not dominate all exits */
              /* make sure this defintion is not used anywhere else */
              if (!domsAllExits)
                {
@@ -567,7 +575,9 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
              /* now we know it is a true invariant */
              /* remove it from the insts chain & put */
              /* in the invariant set                */
-             OP_SYMBOL (IC_RESULT (ic))->isinvariant = 1;
+             
+              OP_SYMBOL (IC_RESULT (ic))->isinvariant = 1;
+              SPIL_LOC (IC_RESULT (ic)) = NULL;
              remiCodeFromeBBlock (lBlock, ic);
 
              /* maintain the data flow */