1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 07:29:33 +00:00

OptDupLoads shouldn't silently do optimizations.

This commit is contained in:
acqn 2020-08-31 01:57:01 +08:00 committed by Oliver Schmidt
parent f45d2515eb
commit ae340703f2
2 changed files with 17 additions and 5 deletions

View File

@ -1147,8 +1147,9 @@ unsigned OptDupLoads (CodeSeg* S)
/* Get next entry */
CodeEntry* E = CS_GetEntry (S, I);
/* Assume we won't delete the entry */
/* Assume we won't delete or replace the entry */
int Delete = 0;
opc_t NewOPC = OP65_INVALID;
/* Get a pointer to the input registers of the insn */
const RegContents* In = &E->RI->In;
@ -1218,7 +1219,7 @@ unsigned OptDupLoads (CodeSeg* S)
E->AM != AM65_ABSY &&
E->AM != AM65_ZPY) {
/* Use the A register instead */
CE_ReplaceOPC (E, OP65_STA);
NewOPC = OP65_STA;
}
break;
@ -1242,11 +1243,11 @@ unsigned OptDupLoads (CodeSeg* S)
*/
} else if (RegValIsKnown (In->RegY)) {
if (In->RegY == In->RegA) {
CE_ReplaceOPC (E, OP65_STA);
NewOPC = OP65_STA;
} else if (In->RegY == In->RegX &&
E->AM != AM65_ABSX &&
E->AM != AM65_ZPX) {
CE_ReplaceOPC (E, OP65_STX);
NewOPC = OP65_STX;
}
}
break;
@ -1319,6 +1320,14 @@ unsigned OptDupLoads (CodeSeg* S)
} else {
if (NewOPC != OP65_INVALID) {
/* Replace the opcode */
CE_ReplaceOPC (E, NewOPC);
/* Remember, we had changes */
++Changes;
}
/* Next entry */
++I;

View File

@ -128,7 +128,10 @@ typedef enum {
OP65_TYA,
/* Number of opcodes available */
OP65_COUNT
OP65_COUNT,
/* Invalid opcode */
OP65_INVALID = OP65_COUNT,
} opc_t;
/* 65XX addressing modes */