mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 00:31:56 +00:00
fix instruction index error in optimizer
This commit is contained in:
parent
a40d120f2a
commit
d5fc69d3e4
@ -64,7 +64,7 @@ class IRPeepholeOptimizer(private val irprog: IRProgram) {
|
||||
private fun replaceConcatZeroMsbWithExt(chunk: IRCodeChunk, indexedInstructions: List<IndexedValue<IRInstruction>>): Boolean {
|
||||
var changed = false
|
||||
indexedInstructions.reversed().forEach { (idx, ins) ->
|
||||
if (ins.opcode == Opcode.CONCAT) {
|
||||
if (ins.opcode == Opcode.CONCAT && idx>0) {
|
||||
// if the previous instruction loads a zero in the msb, this can be turned into EXT.B instead
|
||||
val prev = indexedInstructions[idx-1].value
|
||||
if(prev.opcode==Opcode.LOAD && prev.immediate==0 && prev.reg1==ins.reg2) {
|
||||
@ -449,7 +449,7 @@ class IRPeepholeOptimizer(private val irprog: IRProgram) {
|
||||
private fun removeDoubleLoadsAndStores(chunk: IRCodeChunk, indexedInstructions: List<IndexedValue<IRInstruction>>): Boolean {
|
||||
var changed = false
|
||||
indexedInstructions.forEach { (idx, ins) ->
|
||||
if(ins.opcode==Opcode.STOREM) {
|
||||
if(ins.opcode==Opcode.STOREM && idx>0) {
|
||||
val prev = indexedInstructions[idx-1].value
|
||||
if(prev.opcode==Opcode.LOADM) {
|
||||
// loadm.X rX,something | storem.X rX,something ?? -> get rid of the store.
|
||||
|
Loading…
Reference in New Issue
Block a user