1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-20 14:29:03 +00:00

Repeat opts until there are no more changes

git-svn-id: svn://svn.cc65.org/cc65/trunk@684 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-04-04 20:20:29 +00:00
parent cf61bd0b40
commit b8e26d3612

View File

@ -1550,9 +1550,13 @@ static void OptDeadJumps (void)
static void OptLoads (void)
/* Remove unnecessary loads of values */
{
Line* L2 [10];
unsigned Changes;
do {
Line* L2 [10];
Line* L = FirstCode;
Changes = 0;
while (L) {
/* Check for
@ -1598,6 +1602,9 @@ static void OptLoads (void)
/* Delete the remaining lines */
FreeLines (L2 [0], L2 [3]);
/* We have changes */
++Changes;
/* Check for
*
* ldy #$xx
@ -1645,6 +1652,9 @@ static void OptLoads (void)
/* Delete the remaining lines */
FreeLines (L2 [0], L2 [3]);
/* We have changes */
++Changes;
/* Search for:
*
* lda (sp),y
@ -1662,6 +1672,9 @@ static void OptLoads (void)
L = ReplaceLine (L, "\tjsr\tpushaysp");
FreeLine (L2 [0]);
/* We have changes */
++Changes;
/* Search for:
*
* ldx xx
@ -1691,6 +1704,9 @@ static void OptLoads (void)
FreeLine (L2[2]);
L = L2[1];
/* We have changes */
++Changes;
/* Search for:
*
* ldx xx
@ -1728,6 +1744,9 @@ static void OptLoads (void)
/* Remove the remaining lines */
FreeLines (L2[1], L2[2]);
/* We have changes */
++Changes;
/* Search for:
*
* ldx xx
@ -1763,6 +1782,9 @@ static void OptLoads (void)
/* Remove the remaining line */
FreeLine (L2[1]);
/* We have changes */
++Changes;
/* Search for
*
* adc xx
@ -1783,6 +1805,9 @@ static void OptLoads (void)
/* Delete the lines */
FreeLines (L2[0], L2[1]->Next);
/* We have changes */
++Changes;
/* Search for
*
* sbc xx
@ -1802,8 +1827,34 @@ static void OptLoads (void)
/* Delete the lines */
FreeLines (L2[0], L2[1]->Next);
}
/* We have changes */
++Changes;
/* Search for
*
* lda xx
* bpl *+3
* dex
*
* Remove the handling of the high byte if the X register
* is not used any more
*/
} else if (LineMatch (L, "\tlda\t") &&
GetNextCodeLines (L, L2, 3) &&
LineFullMatch (L2[0], "\tbpl\t*+3") &&
LineFullMatch (L2[1], "\tdex") &&
L2[1]->Next &&
IsHint (L2[1]->Next, "x:!") &&
!RegXUsed (L2[1])) {
/* Delete the lines */
FreeLines (L2[0], L2[1]->Next);
/* We have changes */
++Changes;
}
/* All other patterns start with this one: */
if (!LineFullMatch (L, "\tldx\t#$00")) {
@ -1829,6 +1880,9 @@ static void OptLoads (void)
/* Remove the unnecessary line */
FreeLine (L2[0]);
/* We have changes */
++Changes;
}
/* Search for:
@ -1858,6 +1912,9 @@ static void OptLoads (void)
/* L must be valid */
L = L2 [0];
/* We have changes */
++Changes;
}
}
@ -1885,6 +1942,9 @@ static void OptLoads (void)
/* L must be valid */
L = L2 [0];
/* We have changes */
++Changes;
}
}
@ -1911,6 +1971,9 @@ static void OptLoads (void)
/* L must be valid */
L = L2 [0];
/* We have changes */
++Changes;
}
}
@ -1918,6 +1981,8 @@ NextLine:
/* Go to the next line */
L = NextCodeLine (L);
}
} while (Changes);
}