From: epetrich Date: Thu, 30 Oct 2003 05:42:53 +0000 (+0000) Subject: Fixed a number of problems revealed by bug #827883. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=30244100339d65c90eb0f45a7c3be6fbc9805f30;p=fw%2Fsdcc 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. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2967 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index df792fe5..7ebc3ad7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-10-30 Erik Petrich + + 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 * .version: bumped to 2.3.6 to reflect the big improvements diff --git a/src/SDCCast.c b/src/SDCCast.c index 7db25f4f..c0d2787a 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -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); diff --git a/src/SDCCloop.c b/src/SDCCloop.c index 783fd3d9..1ff5e2cd 100644 --- a/src/SDCCloop.c +++ b/src/SDCCloop.c @@ -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 */