From 4f8e4838e890519b68681e502145ca9170a1adc8 Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Sat, 15 Dec 2018 00:01:12 +0100 Subject: [PATCH] 6502: Fix comparison optimization --- .../mos/opt/ReverseFlowAnalyzerPerOpcode.scala | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/scala/millfork/assembly/mos/opt/ReverseFlowAnalyzerPerOpcode.scala b/src/main/scala/millfork/assembly/mos/opt/ReverseFlowAnalyzerPerOpcode.scala index f5b5c8a8..7e997a2d 100644 --- a/src/main/scala/millfork/assembly/mos/opt/ReverseFlowAnalyzerPerOpcode.scala +++ b/src/main/scala/millfork/assembly/mos/opt/ReverseFlowAnalyzerPerOpcode.scala @@ -114,27 +114,34 @@ object ReverseFlowAnalyzerPerOpcode { CMP -> (currentImportance => { val ignoreOutput = allCompareOutputsAreUnimportant(currentImportance) currentImportance.copy( - a = if (ignoreOutput) Unimportant else Important, + a = if (ignoreOutput) currentImportance.a else Important, n = Unimportant, z = Unimportant, c = Unimportant, m = Important) }), DCP -> (currentImportance => { val ignoreOutput = allCompareOutputsAreUnimportant(currentImportance) currentImportance.copy( - a = if (ignoreOutput) Unimportant else Important, + a = if (ignoreOutput) currentImportance.a else Important, n = Unimportant, z = Unimportant, c = Unimportant) }), CPX -> (currentImportance => { val ignoreOutput = allCompareOutputsAreUnimportant(currentImportance) currentImportance.copy( - x = if (ignoreOutput) Unimportant else Important, + x = if (ignoreOutput) currentImportance.x else Important, n = Unimportant, z = Unimportant, c = Unimportant, w = Important) }), CPY -> (currentImportance => { val ignoreOutput = allCompareOutputsAreUnimportant(currentImportance) currentImportance.copy( - y = if (ignoreOutput) Unimportant else Important, + y = if (ignoreOutput) currentImportance.y else Important, + n = Unimportant, z = Unimportant, c = Unimportant, + w = Important) + }), + CPZ -> (currentImportance => { + val ignoreOutput = allCompareOutputsAreUnimportant(currentImportance) + currentImportance.copy( + iz = if (ignoreOutput) currentImportance.iz else Important, n = Unimportant, z = Unimportant, c = Unimportant, w = Important) }),