diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmOptimizer.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmOptimizer.kt index 427beecf1..9ab425abd 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmOptimizer.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmOptimizer.kt @@ -58,7 +58,7 @@ internal fun optimizeAssembly(lines: MutableList, machine: IMachineDefin numberOfOptimizations++ } - mods = optimizeSamePointerIndexing(linesByFourteen) + mods = optimizeSamePointerIndexingAndUselessBeq(linesByFourteen) if(mods.isNotEmpty()) { apply(mods, lines) linesByFourteen = getLinesBy(lines, 14) @@ -306,7 +306,7 @@ private fun optimizeSameAssignments( return mods } -private fun optimizeSamePointerIndexing(linesByFourteen: Sequence>>): List { +private fun optimizeSamePointerIndexingAndUselessBeq(linesByFourteen: Sequence>>): List { // Optimize same pointer indexing where for instance we load and store to the same ptr index in Y // if Y isn't modified in between we can omit the second LDY: @@ -343,6 +343,35 @@ private fun optimizeSamePointerIndexing(linesByFourteen: Sequence