mirror of
https://github.com/irmen/prog8.git
synced 2025-02-16 07:31:48 +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 {
|
private fun replaceConcatZeroMsbWithExt(chunk: IRCodeChunk, indexedInstructions: List<IndexedValue<IRInstruction>>): Boolean {
|
||||||
var changed = false
|
var changed = false
|
||||||
indexedInstructions.reversed().forEach { (idx, ins) ->
|
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
|
// if the previous instruction loads a zero in the msb, this can be turned into EXT.B instead
|
||||||
val prev = indexedInstructions[idx-1].value
|
val prev = indexedInstructions[idx-1].value
|
||||||
if(prev.opcode==Opcode.LOAD && prev.immediate==0 && prev.reg1==ins.reg2) {
|
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 {
|
private fun removeDoubleLoadsAndStores(chunk: IRCodeChunk, indexedInstructions: List<IndexedValue<IRInstruction>>): Boolean {
|
||||||
var changed = false
|
var changed = false
|
||||||
indexedInstructions.forEach { (idx, ins) ->
|
indexedInstructions.forEach { (idx, ins) ->
|
||||||
if(ins.opcode==Opcode.STOREM) {
|
if(ins.opcode==Opcode.STOREM && idx>0) {
|
||||||
val prev = indexedInstructions[idx-1].value
|
val prev = indexedInstructions[idx-1].value
|
||||||
if(prev.opcode==Opcode.LOADM) {
|
if(prev.opcode==Opcode.LOADM) {
|
||||||
// loadm.X rX,something | storem.X rX,something ?? -> get rid of the store.
|
// loadm.X rX,something | storem.X rX,something ?? -> get rid of the store.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user