1
0
mirror of https://github.com/cc65/cc65.git synced 2025-08-08 22:25:28 +00:00

Small but significant shift optimization

git-svn-id: svn://svn.cc65.org/cc65/trunk@1559 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2002-11-21 01:08:14 +00:00
parent 263b17605c
commit 0ba44bb2d4

View File

@@ -138,13 +138,18 @@ static unsigned OptShift1 (CodeSeg* S)
static unsigned OptShift2 (CodeSeg* S)
/* A call to the shraxN routine may get replaced by one or more lsr insns
* if the value of X is not used later.
* if the value of X is not used later, or if the value of X is known and
* zero.
*/
{
unsigned Changes = 0;
unsigned I;
/* Generate register info */
CS_GenRegInfo (S);
/* Walk over the entries */
unsigned I = 0;
I = 0;
while (I < CS_GetEntryCount (S)) {
/* Get next entry */
@@ -155,7 +160,7 @@ static unsigned OptShift2 (CodeSeg* S)
strncmp (E->Arg, "shrax", 5) == 0 &&
strlen (E->Arg) == 6 &&
IsDigit (E->Arg[5]) &&
!RegXUsed (S, I+1)) {
(E->RI->In.RegX == 0 || !RegXUsed (S, I+1))) {
/* Insert shift insns */
unsigned Count = E->Arg[5] - '0';
@@ -177,6 +182,9 @@ static unsigned OptShift2 (CodeSeg* S)
}
/* Free the register info */
CS_FreeRegInfo (S);
/* Return the number of changes made */
return Changes;
}