From 3a3107b244c8872e3d7848a0da5689fa39d31a62 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Tue, 14 May 2019 22:47:18 -0400 Subject: [PATCH] Disabling too-aggressive optimization in OptCmp8 Generates incorrect code for some 16-bit cases. See: #895 --- src/cc65/coptcmp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cc65/coptcmp.c b/src/cc65/coptcmp.c index 9e9c20502..a82f08d88 100644 --- a/src/cc65/coptcmp.c +++ b/src/cc65/coptcmp.c @@ -885,11 +885,16 @@ unsigned OptCmp8 (CodeSeg* S) ++Changes; } - /* If we have made changes above, we may also remove the compare */ - if (JumpsChanged) { - CS_DelEntry (S, I); - } - + /* "If we have made changes above, we may also remove the compare." + ** + ** Removing the compare was too aggressive. E.g. for 16-bit compares the compiler + ** may generate a branch to a second shared branch that still requires the flag + ** result of the first compare instruction. + ** + **if (JumpsChanged) { + ** CS_DelEntry (S, I); + **} + */ } NextEntry: