1
0
mirror of https://github.com/KarolS/millfork.git synced 2025-01-11 12:29:46 +00:00

6502: another optimization for comparisons

This commit is contained in:
Karol Stasiak 2018-12-19 18:14:40 +01:00
parent 1e9be50ccb
commit 30d18fba01

View File

@ -2646,6 +2646,18 @@ object AlwaysGoodOptimizations {
code(1).copy(opcode = LDA),
code(0).copy(opcode = CMP),
code(2).copy(opcode = BCS))
}
},
(Elidable & HasOpcode(LDA)) ~
(Elidable & HasOpcode(CMP) & DoesntMatterWhatItDoesWith(State.A, State.N)) ~
(Elidable & HasOpcode(BEQ) & MatchParameter(2)) ~
(Elidable & HasOpcode(BCS) & DoesntMatterWhatItDoesWith(State.C) & MatchParameter(1)) ~
(Elidable & HasCallerCount(1) & MatchParameter(2)) ~~> { code =>
List(
code(1).copy(opcode = LDA),
code(0).copy(opcode = CMP),
code(3).copy(opcode = BCC))
},
)
}