mirror of
https://github.com/cc65/cc65.git
synced 2024-07-16 17:29:43 +00:00
Extend OPtShift3 to shift counts larger than 1.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5713 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
22078ba924
commit
c66185259b
@ -261,7 +261,11 @@ static unsigned OptShift3 (CodeSeg* S)
|
|||||||
*
|
*
|
||||||
* ror a
|
* ror a
|
||||||
*
|
*
|
||||||
* if X is zero on entry and unused later.
|
* if X is zero on entry and unused later. For shift counts > 1, more
|
||||||
|
*
|
||||||
|
* shr a
|
||||||
|
*
|
||||||
|
* must be added.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
unsigned Changes = 0;
|
unsigned Changes = 0;
|
||||||
@ -287,12 +291,21 @@ static unsigned OptShift3 (CodeSeg* S)
|
|||||||
L[1]->OPC == OP65_INX &&
|
L[1]->OPC == OP65_INX &&
|
||||||
L[0]->JumpTo->Owner == L[2] &&
|
L[0]->JumpTo->Owner == L[2] &&
|
||||||
!CS_RangeHasLabel (S, I, 2) &&
|
!CS_RangeHasLabel (S, I, 2) &&
|
||||||
CE_IsCallTo (L[2], "shrax1") &&
|
L[2]->OPC == OP65_JSR &&
|
||||||
|
strlen (L[2]->Arg) == 6 &&
|
||||||
|
memcmp (L[2]->Arg, "shrax", 5) == 0 &&
|
||||||
|
IsDigit (L[2]->Arg[5]) &&
|
||||||
!RegXUsed (S, I+3)) {
|
!RegXUsed (S, I+3)) {
|
||||||
|
|
||||||
|
unsigned ShiftCount = (L[2]->Arg[5] - '0');
|
||||||
|
|
||||||
/* Add the replacement insn instead */
|
/* Add the replacement insn instead */
|
||||||
CodeEntry* X = NewCodeEntry (OP65_ROR, AM65_ACC, "a", 0, L[2]->LI);
|
CodeEntry* X = NewCodeEntry (OP65_ROR, AM65_ACC, "a", 0, L[2]->LI);
|
||||||
CS_InsertEntry (S, X, I+3);
|
CS_InsertEntry (S, X, I+3);
|
||||||
|
while (--ShiftCount) {
|
||||||
|
X = NewCodeEntry (OP65_LSR, AM65_ACC, "a", 0, L[2]->LI);
|
||||||
|
CS_InsertEntry (S, X, I+4);
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove the bcs/dex/jsr */
|
/* Remove the bcs/dex/jsr */
|
||||||
CS_DelEntries (S, I, 3);
|
CS_DelEntries (S, I, 3);
|
||||||
|
Loading…
Reference in New Issue
Block a user