mirror of
https://github.com/irmen/prog8.git
synced 2026-04-19 20:16:51 +00:00
IR: fix LOADI.f peephole optimization
This commit is contained in:
@@ -605,11 +605,18 @@ jump p8_label_gen_2
|
||||
if((load.opcode==Opcode.LOAD) && load.labelSymbol!=null) {
|
||||
val lastInstruction = indexedInstructions[idx+1].value
|
||||
if(lastInstruction.opcode==Opcode.LOADI) {
|
||||
val targetRegister = lastInstruction.reg1!!
|
||||
if(lastInstruction.type== IRDataType.FLOAT) {
|
||||
TODO("peephole opt LOADI.float")
|
||||
if(ins.reg1==lastInstruction.reg1!! && load.reg1==lastInstruction.reg1!!) {
|
||||
val targetFpRegister = lastInstruction.fpReg1!!
|
||||
val loadm = IRInstruction(Opcode.LOADM, lastInstruction.type, fpReg1 = targetFpRegister, labelSymbol = load.labelSymbol, symbolOffset = ins.immediate)
|
||||
chunk.instructions[idx-1] = loadm
|
||||
chunk.instructions.removeAt(idx+1)
|
||||
chunk.instructions.removeAt(idx)
|
||||
changed = true
|
||||
}
|
||||
} else {
|
||||
if(ins.reg1==lastInstruction.reg2!! && load.reg1==lastInstruction.reg2!!) {
|
||||
val targetRegister = lastInstruction.reg1!!
|
||||
val loadm = IRInstruction(Opcode.LOADM, lastInstruction.type, reg1=targetRegister, labelSymbol = load.labelSymbol, symbolOffset = ins.immediate)
|
||||
chunk.instructions[idx-1] = loadm
|
||||
chunk.instructions.removeAt(idx+1)
|
||||
@@ -618,12 +625,14 @@ jump p8_label_gen_2
|
||||
}
|
||||
}
|
||||
} else if(lastInstruction.opcode==Opcode.STOREI) {
|
||||
val valueLoad = indexedInstructions[idx-2].value
|
||||
val targetRegister = lastInstruction.reg1!!
|
||||
if(lastInstruction.type==IRDataType.FLOAT) {
|
||||
TODO("peephole opt STOREI.float")
|
||||
if(ins.reg1==lastInstruction.reg1!! && load.reg1==lastInstruction.reg1!!) {
|
||||
TODO("peephole opt STOREI.float ${chunk.sourceLinesPositions}")
|
||||
}
|
||||
} else {
|
||||
if(ins.reg1==lastInstruction.reg2!! && load.reg1==lastInstruction.reg2!!) {
|
||||
val valueLoad = indexedInstructions[idx-2].value
|
||||
if(valueLoad.opcode==Opcode.LOAD && valueLoad.reg1==targetRegister) {
|
||||
val storem = IRInstruction(Opcode.STOREM, lastInstruction.type, reg1=valueLoad.reg1, labelSymbol = load.labelSymbol, symbolOffset = ins.immediate)
|
||||
chunk.instructions[idx-1] = storem
|
||||
|
||||
Reference in New Issue
Block a user