mirror of
https://github.com/cc65/cc65.git
synced 2025-02-05 20:31:53 +00:00
Optimize local immidiate stores
git-svn-id: svn://svn.cc65.org/cc65/trunk@556 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
3b18880fb1
commit
eed3723502
@ -1719,8 +1719,42 @@ static void OptLoads (void)
|
||||
|
||||
/* Remove the remaining lines */
|
||||
FreeLines (L2[1], L2[2]);
|
||||
}
|
||||
|
||||
/* Search for:
|
||||
*
|
||||
* ldx xx
|
||||
* lda yy
|
||||
* jsr stax0sp
|
||||
*
|
||||
* and replace it by:
|
||||
*
|
||||
* lda xx
|
||||
* ldy #$01
|
||||
* sta (sp),y
|
||||
* dey
|
||||
* lda yy
|
||||
* sta (sp),y
|
||||
*
|
||||
* provided that that the X register is not used later. This code
|
||||
* sequence is four bytes longer, but a lot faster and it does not
|
||||
* use the X register, so other loads may get removed later.
|
||||
*/
|
||||
} else if (LineMatch (L, "\tldx\t") &&
|
||||
GetNextCodeLines (L, L2, 2) &&
|
||||
LineMatch (L2 [0], "\tlda\t") &&
|
||||
LineFullMatch (L2 [1], "\tjsr\tstax0sp") &&
|
||||
!RegXUsed (L2[1])) {
|
||||
|
||||
/* Found - replace it */
|
||||
L->Line[3] = 'a';
|
||||
L = NewLineAfter (L, "\tldy\t#$01");
|
||||
L = NewLineAfter (L, "\tsta\t(sp),y");
|
||||
L = NewLineAfter (L, "\tdey");
|
||||
L = NewLineAfter (L2[0], "\tsta\t(sp),y");
|
||||
|
||||
/* Remove the remaining line */
|
||||
FreeLine (L2[1]);
|
||||
}
|
||||
|
||||
/* All other patterns start with this one: */
|
||||
if (!LineFullMatch (L, "\tldx\t#$00")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user