mirror of
https://github.com/KarolS/millfork.git
synced 2024-11-19 13:31:23 +00:00
Optimize pulling a known constant from the stack in more cases
This commit is contained in:
parent
38efdcc979
commit
656dbef184
@ -260,6 +260,24 @@ object AlwaysGoodOptimizations {
|
||||
|
||||
val PointlessStackStashing = new RuleBasedAssemblyOptimization("Pointless stack stashing",
|
||||
needsFlowInfo = FlowInfoRequirement.NoRequirement,
|
||||
(Elidable & HasOpcode(LDA) & HasAddrMode(Immediate)) ~
|
||||
(Elidable & HasOpcode(PHA)) ~
|
||||
(Linear & Not(ConcernsStack) | HasOpcodeIn(Set(JSR, BSR))).* ~
|
||||
(Elidable & HasOpcode(PLA)) ~~> { code =>
|
||||
code.head :: (code.drop(2).init :+ code.head)
|
||||
},
|
||||
(Elidable & HasOpcode(LDX) & HasAddrMode(Immediate)) ~
|
||||
(Elidable & HasOpcode(PHX)) ~
|
||||
(Linear & Not(ConcernsStack) | HasOpcodeIn(Set(JSR, BSR))).* ~
|
||||
(Elidable & HasOpcode(PLX)) ~~> { code =>
|
||||
code.head :: (code.drop(2).init :+ code.head)
|
||||
},
|
||||
(Elidable & HasOpcode(LDY) & HasAddrMode(Immediate)) ~
|
||||
(Elidable & HasOpcode(PHY)) ~
|
||||
(Linear & Not(ConcernsStack) | HasOpcodeIn(Set(JSR, BSR))).* ~
|
||||
(Elidable & HasOpcode(PLY)) ~~> { code =>
|
||||
code.head :: (code.drop(2).init :+ code.head)
|
||||
},
|
||||
(Elidable & HasOpcode(LDA) & MatchAddrMode(0) & MatchParameter(1)) ~
|
||||
(Elidable & HasOpcode(PHA)) ~
|
||||
(Linear & Not(ConcernsStack) & DoesntChangeIndexingInAddrMode(0) & DoesntChangeMemoryAt(0, 1)).* ~
|
||||
|
Loading…
Reference in New Issue
Block a user