Quick fix for Issue #1071.
This commit is contained in:
@@ -145,6 +145,9 @@ struct StackOpData {
|
|||||||
/* Freedom of registers inside the sequence */
|
/* Freedom of registers inside the sequence */
|
||||||
unsigned UsedRegs; /* Registers used */
|
unsigned UsedRegs; /* Registers used */
|
||||||
|
|
||||||
|
/* Whether the rhs is changed multiple times */
|
||||||
|
int RhsMultiChg;
|
||||||
|
|
||||||
/* Register load information for lhs and rhs */
|
/* Register load information for lhs and rhs */
|
||||||
LoadInfo Lhs;
|
LoadInfo Lhs;
|
||||||
LoadInfo Rhs;
|
LoadInfo Rhs;
|
||||||
@@ -1972,6 +1975,7 @@ static void ResetStackOpData (StackOpData* Data)
|
|||||||
Data->ZPUsage = REG_NONE;
|
Data->ZPUsage = REG_NONE;
|
||||||
Data->ZPChanged = REG_NONE;
|
Data->ZPChanged = REG_NONE;
|
||||||
Data->UsedRegs = REG_NONE;
|
Data->UsedRegs = REG_NONE;
|
||||||
|
Data->RhsMultiChg = 0;
|
||||||
|
|
||||||
ClearLoadInfo (&Data->Lhs);
|
ClearLoadInfo (&Data->Lhs);
|
||||||
ClearLoadInfo (&Data->Rhs);
|
ClearLoadInfo (&Data->Rhs);
|
||||||
@@ -2092,6 +2096,10 @@ static int PreCondOk (StackOpData* D)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (D->RhsMultiChg && (D->OptFunc->Flags & OP_RHS_REMOVE_DIRECT) != 0) {
|
||||||
|
/* Cannot optimize */
|
||||||
|
break;
|
||||||
|
}
|
||||||
Passed = 1;
|
Passed = 1;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
@@ -2188,6 +2196,8 @@ unsigned OptStackOps (CodeSeg* S)
|
|||||||
int OldEntryCount; /* Old number of entries */
|
int OldEntryCount; /* Old number of entries */
|
||||||
unsigned Used; /* What registers would be used */
|
unsigned Used; /* What registers would be used */
|
||||||
unsigned PushedRegs; /* Track if the same regs are used after the push */
|
unsigned PushedRegs; /* Track if the same regs are used after the push */
|
||||||
|
int RhsALoadIndex; /* Track if rhs is changed more than once */
|
||||||
|
int RhsXLoadIndex; /* Track if rhs is changed more than once */
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
Initialize,
|
Initialize,
|
||||||
@@ -2335,6 +2345,10 @@ unsigned OptStackOps (CodeSeg* S)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Memorize the old rhs load indices before refreshing them */
|
||||||
|
RhsALoadIndex = Data.Rhs.A.LoadIndex;
|
||||||
|
RhsXLoadIndex = Data.Rhs.X.LoadIndex;
|
||||||
|
|
||||||
/* Track register usage */
|
/* Track register usage */
|
||||||
Used = TrackLoads (&Data.Rhs, &Data.Lhs, Data.Code, I);
|
Used = TrackLoads (&Data.Rhs, &Data.Lhs, Data.Code, I);
|
||||||
Data.ZPUsage |= (E->Use | E->Chg);
|
Data.ZPUsage |= (E->Use | E->Chg);
|
||||||
@@ -2358,6 +2372,16 @@ unsigned OptStackOps (CodeSeg* S)
|
|||||||
}
|
}
|
||||||
PushedRegs &= ~E->Chg;
|
PushedRegs &= ~E->Chg;
|
||||||
}
|
}
|
||||||
|
/* Check if rhs is changed again after the push */
|
||||||
|
if ((RhsALoadIndex != Data.Lhs.A.LoadIndex &&
|
||||||
|
RhsALoadIndex != Data.Rhs.A.LoadIndex) ||
|
||||||
|
(RhsXLoadIndex != Data.Lhs.X.LoadIndex &&
|
||||||
|
RhsXLoadIndex != Data.Rhs.X.LoadIndex)) {
|
||||||
|
/* This will disable those sub-opts that require removing
|
||||||
|
** the rhs as they can't handle such cases correctly.
|
||||||
|
*/
|
||||||
|
Data.RhsMultiChg = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FoundOp:
|
case FoundOp:
|
||||||
|
|||||||
Reference in New Issue
Block a user