1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-10 23:29:05 +00:00

More optimizations

git-svn-id: svn://svn.cc65.org/cc65/trunk@824 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-07-26 06:40:06 +00:00
parent 58592116ac
commit bbebbe3a1b

View File

@ -923,6 +923,50 @@ static unsigned OptCmp5 (CodeSeg* S)
static unsigned OptCmp6 (CodeSeg* S)
/* Search for a sequence ldx/txa/branch and remove the txa if A is not
* used later.
*/
{
unsigned Changes = 0;
/* Walk over the entries */
unsigned I = 0;
while (I < CS_GetEntryCount (S)) {
CodeEntry* L[2];
/* Get next entry */
CodeEntry* E = CS_GetEntry (S, I);
/* Check for the sequence */
if ((E->OPC == OP65_LDX || E->OPC == OP65_TAX) &&
CS_GetEntries (S, L, I+1, 2) &&
L[0]->OPC == OP65_TXA &&
!CE_HasLabel (L[0]) &&
(L[1]->Info & OF_FBRA) != 0 &&
!CE_HasLabel (L[1]) &&
!RegAUsed (S, I+3)) {
/* Remove the txa */
CS_DelEntry (S, I+1);
/* Remember, we had changes */
++Changes;
}
/* Next entry */
++I;
}
/* Return the number of changes made */
return Changes;
}
/*****************************************************************************/
/* Optimize tests */
/*****************************************************************************/
@ -1428,6 +1472,7 @@ static OptFunc OptFuncs [] = {
{ OptCmp3, "OptCmp3", 0 },
{ OptCmp4, "OptCmp4", 0 },
{ OptCmp5, "OptCmp5", 0 },
{ OptCmp6, "OptCmp6", 0 },
/* Optimize tests */
{ OptTest1, "OptTest1", 0 },
/* Remove unused loads */