Fixed a problem with the optimizations for shifts.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5783 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -840,13 +840,6 @@ static unsigned Opt_tosshift (StackOpData* D, const char* Name)
|
|||||||
/* Store the value into the zeropage instead of pushing it */
|
/* Store the value into the zeropage instead of pushing it */
|
||||||
ReplacePushByStore (D);
|
ReplacePushByStore (D);
|
||||||
|
|
||||||
/* Inline the shift */
|
|
||||||
D->IP = D->OpIndex+1;
|
|
||||||
|
|
||||||
/* tay */
|
|
||||||
X = NewCodeEntry (OP65_TAY, AM65_IMP, 0, 0, D->OpEntry->LI);
|
|
||||||
InsertEntry (D, X, D->IP++);
|
|
||||||
|
|
||||||
/* If the lhs is direct (but not stack relative), we can just reload the
|
/* If the lhs is direct (but not stack relative), we can just reload the
|
||||||
* data later.
|
* data later.
|
||||||
*/
|
*/
|
||||||
@@ -856,6 +849,13 @@ static unsigned Opt_tosshift (StackOpData* D, const char* Name)
|
|||||||
CodeEntry* LoadX = D->Lhs.X.LoadEntry;
|
CodeEntry* LoadX = D->Lhs.X.LoadEntry;
|
||||||
CodeEntry* LoadA = D->Lhs.A.LoadEntry;
|
CodeEntry* LoadA = D->Lhs.A.LoadEntry;
|
||||||
|
|
||||||
|
/* Inline the shift */
|
||||||
|
D->IP = D->OpIndex+1;
|
||||||
|
|
||||||
|
/* tay */
|
||||||
|
X = NewCodeEntry (OP65_TAY, AM65_IMP, 0, 0, D->OpEntry->LI);
|
||||||
|
InsertEntry (D, X, D->IP++);
|
||||||
|
|
||||||
/* lda */
|
/* lda */
|
||||||
X = NewCodeEntry (OP65_LDA, LoadA->AM, LoadA->Arg, 0, D->OpEntry->LI);
|
X = NewCodeEntry (OP65_LDA, LoadA->AM, LoadA->Arg, 0, D->OpEntry->LI);
|
||||||
InsertEntry (D, X, D->IP++);
|
InsertEntry (D, X, D->IP++);
|
||||||
@@ -874,6 +874,15 @@ static unsigned Opt_tosshift (StackOpData* D, const char* Name)
|
|||||||
AddStoreX (D);
|
AddStoreX (D);
|
||||||
AddStoreA (D);
|
AddStoreA (D);
|
||||||
|
|
||||||
|
/* Be sure to setup IP after adding the stores, otherwise it will get
|
||||||
|
* messed up.
|
||||||
|
*/
|
||||||
|
D->IP = D->OpIndex+1;
|
||||||
|
|
||||||
|
/* tay */
|
||||||
|
X = NewCodeEntry (OP65_TAY, AM65_IMP, 0, 0, D->OpEntry->LI);
|
||||||
|
InsertEntry (D, X, D->IP++);
|
||||||
|
|
||||||
/* lda zp */
|
/* lda zp */
|
||||||
X = NewCodeEntry (OP65_LDA, AM65_ZP, D->ZPLo, 0, D->OpEntry->LI);
|
X = NewCodeEntry (OP65_LDA, AM65_ZP, D->ZPLo, 0, D->OpEntry->LI);
|
||||||
InsertEntry (D, X, D->IP++);
|
InsertEntry (D, X, D->IP++);
|
||||||
@@ -888,7 +897,7 @@ static unsigned Opt_tosshift (StackOpData* D, const char* Name)
|
|||||||
X = NewCodeEntry (OP65_JSR, AM65_ABS, Name, 0, D->OpEntry->LI);
|
X = NewCodeEntry (OP65_JSR, AM65_ABS, Name, 0, D->OpEntry->LI);
|
||||||
InsertEntry (D, X, D->IP++);
|
InsertEntry (D, X, D->IP++);
|
||||||
|
|
||||||
/* Remove the push and the call to the tossubax function */
|
/* Remove the push and the call to the shift function */
|
||||||
RemoveRemainders (D);
|
RemoveRemainders (D);
|
||||||
|
|
||||||
/* We changed the sequence */
|
/* We changed the sequence */
|
||||||
|
|||||||
Reference in New Issue
Block a user