Further optimize inc/decsp

The optimizer can now merge incsp+decsp together, and merge
jsr incsp/decsp + jmp incsp/decsp together. Drop the code
altogether if both instructions cancel each other out.

Fixes #2748
This commit is contained in:
Colin Leroy-Mira
2025-07-06 13:28:53 +02:00
parent 7ed1f0c7ea
commit fe86149203
2 changed files with 51 additions and 30 deletions

View File

@@ -907,6 +907,11 @@ static unsigned RunOptGroup7 (CodeSeg* S)
between branches */
C += RunOptFunc (S, &DOptBranchDist, 3);
/* Re-optimize inc/decsp that may now be grouped */
C += RunOptFunc (S, &DOptStackPtrOps, 5);
/* Re-optimize JSR/RTS that may now be grouped */
C += RunOptFunc (S, &DOptRTS, 1);
Changes += C;
/* If we had changes, we must run dead code elimination again,
** since the changes may have introduced dead code.