From 07cc6a3d208b28ba6bcb42f9a02b8cb765c61bd8 Mon Sep 17 00:00:00 2001 From: acqn Date: Fri, 18 Sep 2020 20:23:02 +0800 Subject: [PATCH] Made optimization steps aware of long branches better. --- src/cc65/coptcmp.c | 4 +++- src/cc65/coptptrload.c | 2 +- src/cc65/coptshift.c | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cc65/coptcmp.c b/src/cc65/coptcmp.c index a4a8c6a9b..fda23ae0a 100644 --- a/src/cc65/coptcmp.c +++ b/src/cc65/coptcmp.c @@ -944,7 +944,9 @@ unsigned OptCmp9 (CodeSeg* S) if (L[0]->OPC == OP65_SBC && CS_GetEntries (S, L+1, I+1, 4) && (L[1]->OPC == OP65_BVC || - L[1]->OPC == OP65_BVS) && + L[1]->OPC == OP65_BVS || + L[1]->OPC == OP65_JVC || + L[1]->OPC == OP65_JVS) && L[1]->JumpTo != 0 && L[1]->JumpTo->Owner == L[3] && L[2]->OPC == OP65_EOR && diff --git a/src/cc65/coptptrload.c b/src/cc65/coptptrload.c index 0534a1fa2..046e65d79 100644 --- a/src/cc65/coptptrload.c +++ b/src/cc65/coptptrload.c @@ -988,7 +988,7 @@ unsigned OptPtrLoad12 (CodeSeg* S) L[4]->OPC == OP65_CLC && L[5]->OPC == OP65_ADC && CE_IsKnownImm (L[5], 1) && - L[6]->OPC == OP65_BCC && + (L[6]->OPC == OP65_BCC || L[6]->OPC == OP65_JCC) && L[6]->JumpTo != 0 && L[6]->JumpTo->Owner == L[8] && L[7]->OPC == OP65_INX && diff --git a/src/cc65/coptshift.c b/src/cc65/coptshift.c index 92210ebb5..aef3f64bc 100644 --- a/src/cc65/coptshift.c +++ b/src/cc65/coptshift.c @@ -341,7 +341,10 @@ unsigned OptShift2 (CodeSeg* S) L[0] = CS_GetEntry (S, I); /* Check for the sequence */ - if ((L[0]->OPC == OP65_BPL || L[0]->OPC == OP65_BCC) && + if ((L[0]->OPC == OP65_BPL || + L[0]->OPC == OP65_BCC || + L[0]->OPC == OP65_JPL || + L[0]->OPC == OP65_JCC) && L[0]->JumpTo != 0 && CS_GetEntries (S, L+1, I+1, 3) && L[1]->OPC == OP65_DEX &&