diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index 74e36ab48..a967ce5f9 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -398,6 +398,7 @@ public class Compiler { }); constantOptimizations.add(new Pass2NopCastInlining(program)); constantOptimizations.add(new Pass2MultiplyToShiftRewriting(program)); + constantOptimizations.add(new Pass2ModuloToAndRewriting(program)); constantOptimizations.add(new Pass2ConstantInlining(program)); constantOptimizations.add(new Pass2ConstantAdditionElimination(program)); constantOptimizations.add(new Pass2ConstantSimplification(program)); @@ -553,10 +554,10 @@ public class Compiler { // Initial Code generation new Pass4CodeGeneration(program, false, program.isWarnFragmentMissing()).generate(); - new Pass4AssertNoCpuClobber(program).check(); getLog().append("\nINITIAL ASM"); getLog().append("Target platform is " + program.getTargetPlatform().getName() + " / " + program.getTargetCpu().getName().toUpperCase(Locale.ENGLISH)); getLog().append(program.getAsm().toString(new AsmProgram.AsmPrintState(true), program)); + new Pass4AssertNoCpuClobber(program).check(); if(disableUplift) { getLog().append("REGISTER UPLIFT DISABLED!"); diff --git a/src/main/java/dk/camelot64/kickc/model/iterator/ProgramExpressionBinary.java b/src/main/java/dk/camelot64/kickc/model/iterator/ProgramExpressionBinary.java index fcaeae638..7a2627970 100644 --- a/src/main/java/dk/camelot64/kickc/model/iterator/ProgramExpressionBinary.java +++ b/src/main/java/dk/camelot64/kickc/model/iterator/ProgramExpressionBinary.java @@ -71,6 +71,12 @@ public interface ProgramExpressionBinary extends ProgramExpression { */ ProgramValue getRightValue(); + /** + * Set the binary operator + * @param operator new binary operator + */ + void setOperator(OperatorBinary operator); + /** Binary expression assignment rvalue. */ class ProgramExpressionBinaryAssignmentRValue implements ProgramExpressionBinary { @@ -90,6 +96,11 @@ public interface ProgramExpressionBinary extends ProgramExpression { return (OperatorBinary) assignment.getOperator(); } + @Override + public void setOperator(OperatorBinary operator) { + assignment.setOperator(operator); + } + @Override public RValue getRight() { return assignment.getrValue2(); @@ -165,6 +176,11 @@ public interface ProgramExpressionBinary extends ProgramExpression { return Operators.ASSIGNMENT; } + @Override + public void setOperator(OperatorBinary operator) { + throw new InternalError("Not supported!"); + } + @Override public RValue getRight() { return (RValue) parameterValue.get(); @@ -234,6 +250,11 @@ public interface ProgramExpressionBinary extends ProgramExpression { throw new InternalError("Not supported!"); } + @Override + public void setOperator(OperatorBinary operator) { + throw new InternalError("Not supported!"); + } + @Override public ProgramValue getLeftValue() { return new ProgramValue.ProgramValueLValue(assignment); @@ -302,6 +323,11 @@ public interface ProgramExpressionBinary extends ProgramExpression { return (OperatorBinary) conditionalJump.getOperator(); } + @Override + public void setOperator(OperatorBinary operator) { + conditionalJump.setOperator(operator); + } + @Override public RValue getRight() { return conditionalJump.getrValue2(); @@ -368,6 +394,11 @@ public interface ProgramExpressionBinary extends ProgramExpression { return getConstantBinary().getOperator(); } + @Override + public void setOperator(OperatorBinary operator) { + getConstantBinary().setOperator(operator); + } + @Override public RValue getRight() { return getConstantBinary().getRight(); @@ -422,6 +453,11 @@ public interface ProgramExpressionBinary extends ProgramExpression { return Operators.PLUS; } + @Override + public void setOperator(OperatorBinary operator) { + throw new InternalError("Not supported!"); + } + @Override public RValue getRight() { return getPointerDereferenceIndexed().getIndex(); @@ -492,6 +528,11 @@ public interface ProgramExpressionBinary extends ProgramExpression { return Operators.ASSIGNMENT; } + @Override + public void setOperator(OperatorBinary operator) { + throw new InternalError("Not supported!"); + } + @Override public RValue getRight() { return (RValue) phiValue.get(); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass2ModuloToAndRewriting.java b/src/main/java/dk/camelot64/kickc/passes/Pass2ModuloToAndRewriting.java new file mode 100644 index 000000000..3034a17bf --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/passes/Pass2ModuloToAndRewriting.java @@ -0,0 +1,62 @@ +package dk.camelot64.kickc.passes; + +import dk.camelot64.kickc.model.ConstantNotLiteral; +import dk.camelot64.kickc.model.Program; +import dk.camelot64.kickc.model.iterator.ProgramExpressionBinary; +import dk.camelot64.kickc.model.iterator.ProgramExpressionIterator; +import dk.camelot64.kickc.model.operators.Operators; +import dk.camelot64.kickc.model.types.SymbolType; +import dk.camelot64.kickc.model.values.ConstantBinary; +import dk.camelot64.kickc.model.values.ConstantInteger; +import dk.camelot64.kickc.model.values.ConstantLiteral; +import dk.camelot64.kickc.model.values.ConstantValue; + +import java.util.concurrent.atomic.AtomicBoolean; + +/** Pass that replaces modulo with factors of 2 with binary and */ +public class Pass2ModuloToAndRewriting extends Pass2SsaOptimization { + + public Pass2ModuloToAndRewriting(Program program) { + super(program); + } + + @Override + public boolean step() { + AtomicBoolean optimized = new AtomicBoolean(false); + + ProgramExpressionIterator.execute(getProgram(), (programExpression, currentStmt, stmtIt, currentBlock) -> { + if(programExpression instanceof ProgramExpressionBinary) { + ProgramExpressionBinary binary = (ProgramExpressionBinary) programExpression; + if(binary.getOperator().equals(Operators.MODULO) && binary.getRight() instanceof ConstantValue) { + final ConstantLiteral constantLiteral = getConstantLiteral((ConstantValue) binary.getRight()); + if(constantLiteral instanceof ConstantInteger) { + Long constantInt = ((ConstantInteger) constantLiteral).getInteger(); + double power2 = Math.log(constantInt) / Math.log(2); + if(power2 >= 0.0 && Math.round(power2) == power2) { + // Modulo whole power of 2 + binary.setOperator(Operators.BOOL_AND); + binary.getRightValue().set(new ConstantBinary((ConstantValue) binary.getRight(), Operators.MINUS, new ConstantInteger(1l, SymbolType.BYTE))); + getLog().append("Rewriting power 2 modulo to use AND " + binary.getLeft().toString()+" "+binary.getOperator().toString()+" "+binary.getRight().toString()); + optimized.set(true); + } + } + } + } + }); + return optimized.get(); + } + + /** + * Get the constant literal value for a constant value - or null if not possible + * + * @param constantValue The constant value + * @return The constant literal value for RValue2 (or null) + */ + private ConstantLiteral getConstantLiteral(ConstantValue constantValue) { + try { + return constantValue.calculateLiteral(getScope()); + } catch(ConstantNotLiteral e) { + return null; + } + } +} diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4InterruptClobberFix.java b/src/main/java/dk/camelot64/kickc/passes/Pass4InterruptClobberFix.java index c721750f0..fe5f437bb 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4InterruptClobberFix.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4InterruptClobberFix.java @@ -115,9 +115,10 @@ public class Pass4InterruptClobberFix extends Pass2Base { while(entryLines.hasNext()) { AsmLine line = entryLines.next(); for(String notClobberedReg : notClobberedRegisters) { - if(line.getAsm().contains(notClobberedReg)) { + final String lineAsm = line.getAsm(); + if(lineAsm.contains("ld"+notClobberedReg) || lineAsm.contains("st"+notClobberedReg) || lineAsm.contains("reg"+notClobberedReg)) { // Found an A/X/Y in the asm where A/X/Y is not clobbered - remove the line - getLog().append("Removing interrupt register storage "+line.toString()+" in CHU"+interruptEntryExit.getIndex()+" "+interruptEntryExit.getSource()); + getLog().append("Removing interrupt register storage "+line.toString()+" in "+interruptEntryExit.getIndex()+" "+interruptEntryExit.getSource()); entryLines.remove(); } } diff --git a/src/main/java/dk/camelot64/kickc/passes/calcs/PassNCalcVariableRegisterWeight.java b/src/main/java/dk/camelot64/kickc/passes/calcs/PassNCalcVariableRegisterWeight.java index 7602bdb4c..cb2a5c8ef 100644 --- a/src/main/java/dk/camelot64/kickc/passes/calcs/PassNCalcVariableRegisterWeight.java +++ b/src/main/java/dk/camelot64/kickc/passes/calcs/PassNCalcVariableRegisterWeight.java @@ -80,7 +80,7 @@ public class PassNCalcVariableRegisterWeight extends PassNCalcBase>1 + lda #((3+1-1)*6/2&2-1)<<2>>1 sta.z test.a jsr test ldx #8 - lda #mod((3+1-1)*6/2,2)<<2>>1^6 + lda #((3+1-1)*6/2&2-1)<<2>>1^6 sta.z test.a jsr test ldx #9 - lda #mod((3+1-1)*6/2,2)<<2>>1^6|1 + lda #((3+1-1)*6/2&2-1)<<2>>1^6|1 sta.z test.a jsr test ldx #$a - lda #(mod((3+1-1)*6/2,2)<<2>>1^6|1)&1 + lda #(((3+1-1)*6/2&2-1)<<2>>1^6|1)&1 sta.z test.a jsr test rts diff --git a/src/test/ref/assignment-compound.cfg b/src/test/ref/assignment-compound.cfg index 857bb2975..2ff233022 100644 --- a/src/test/ref/assignment-compound.cfg +++ b/src/test/ref/assignment-compound.cfg @@ -60,7 +60,7 @@ main::@return: scope:[main] from main::@10 (void()) test((byte) test::i , (byte) test::a) test: scope:[test] from main main::@1 main::@10 main::@2 main::@3 main::@4 main::@5 main::@6 main::@7 main::@8 main::@9 [27] (byte) test::i#11 ← phi( main/(byte) 0 main::@1/(byte) 1 main::@10/(byte) $a main::@2/(byte) 2 main::@3/(byte) 3 main::@4/(byte) 4 main::@5/(byte) 5 main::@6/(byte) 6 main::@7/(byte) 7 main::@8/(byte) 8 main::@9/(byte) 9 ) - [27] (byte) test::a#11 ← phi( main/(byte) 3 main::@1/(byte) 3+(byte) 1 main::@10/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 main::@2/(byte) 3+(byte) 1-(byte) 1 main::@3/(byte) 3+(byte) 1-(byte) 1*(byte) 6 main::@4/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2 main::@5/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2 main::@6/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2 main::@7/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1 main::@8/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6 main::@9/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 ) + [27] (byte) test::a#11 ← phi( main/(byte) 3 main::@1/(byte) 3+(byte) 1 main::@10/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 main::@2/(byte) 3+(byte) 1-(byte) 1 main::@3/(byte) 3+(byte) 1-(byte) 1*(byte) 6 main::@4/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2 main::@5/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1 main::@6/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2 main::@7/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1 main::@8/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6 main::@9/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 ) [28] *((const byte*) screen1 + (byte) test::i#11) ← (byte) test::a#11 [29] *((const byte*) screen2#0 + (byte) test::i#11) ← *((const byte*) ref + (byte) test::i#11) [30] if(*((const byte*) ref + (byte) test::i#11)==(byte) test::a#11) goto test::@1 diff --git a/src/test/ref/assignment-compound.log b/src/test/ref/assignment-compound.log index e7f1eda01..b8b17b170 100644 --- a/src/test/ref/assignment-compound.log +++ b/src/test/ref/assignment-compound.log @@ -446,6 +446,8 @@ Successful SSA optimization Pass2ConstantIdentification Constant (const byte) test::i#10 = main::i#10 Constant (const byte) test::a#10 = main::a#10 Successful SSA optimization Pass2ConstantIdentification +Rewriting power 2 modulo to use AND main::a#15 & 2-1 +Successful SSA optimization Pass2ModuloToAndRewriting Inlining constant with different constant siblings (const byte) main::i#0 Inlining constant with different constant siblings (const byte) main::a#0 Inlining constant with different constant siblings (const byte) main::i#1 @@ -491,38 +493,38 @@ Inlining constant with var siblings (const byte) test::a#9 Inlining constant with var siblings (const byte) test::i#10 Inlining constant with var siblings (const byte) test::a#10 Constant inlined test::i#1 = ++(byte) 0 -Constant inlined test::a#8 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6 +Constant inlined test::a#8 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6 Constant inlined test::i#0 = (byte) 0 -Constant inlined test::a#9 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 +Constant inlined test::a#9 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 Constant inlined test::i#3 = ++++++(byte) 0 Constant inlined test::i#2 = ++++(byte) 0 Constant inlined test::a#4 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2 Constant inlined main::i#21 = ++++++++++++++++++(byte) 0 -Constant inlined test::a#5 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2 -Constant inlined test::a#6 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2 -Constant inlined test::a#7 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1 +Constant inlined test::a#5 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1 +Constant inlined test::a#6 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2 +Constant inlined test::a#7 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1 Constant inlined main::i#20 = ++++++++++++++++(byte) 0 Constant inlined test::i#9 = ++++++++++++++++++(byte) 0 Constant inlined test::i#8 = ++++++++++++++++(byte) 0 -Constant inlined main::a#20 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 -Constant inlined test::a#10 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 +Constant inlined main::a#20 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 +Constant inlined test::a#10 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 Constant inlined test::i#5 = ++++++++++(byte) 0 Constant inlined test::i#4 = ++++++++(byte) 0 Constant inlined test::i#7 = ++++++++++++++(byte) 0 Constant inlined test::i#6 = ++++++++++++(byte) 0 Constant inlined test::i#10 = ++++++++++++++++++++(byte) 0 Constant inlined main::a#0 = (byte) 3 -Constant inlined main::a#19 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6 -Constant inlined main::a#18 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1 -Constant inlined main::a#17 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2 +Constant inlined main::a#19 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6 +Constant inlined main::a#18 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1 +Constant inlined main::a#17 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2 Constant inlined main::a#1 = (byte) 3+(byte) 1 -Constant inlined main::a#16 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2 +Constant inlined main::a#16 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1 Constant inlined main::i#0 = (byte) 0 Constant inlined main::i#1 = ++(byte) 0 Constant inlined main::i#14 = ++++(byte) 0 Constant inlined main::i#15 = ++++++(byte) 0 Constant inlined main::i#10 = ++++++++++++++++++++(byte) 0 -Constant inlined main::a#10 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 +Constant inlined main::a#10 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 Constant inlined main::a#15 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2 Constant inlined main::i#18 = ++++++++++++(byte) 0 Constant inlined main::a#14 = (byte) 3+(byte) 1-(byte) 1*(byte) 6 @@ -661,7 +663,7 @@ main::@return: scope:[main] from main::@10 (void()) test((byte) test::i , (byte) test::a) test: scope:[test] from main main::@1 main::@10 main::@2 main::@3 main::@4 main::@5 main::@6 main::@7 main::@8 main::@9 [27] (byte) test::i#11 ← phi( main/(byte) 0 main::@1/(byte) 1 main::@10/(byte) $a main::@2/(byte) 2 main::@3/(byte) 3 main::@4/(byte) 4 main::@5/(byte) 5 main::@6/(byte) 6 main::@7/(byte) 7 main::@8/(byte) 8 main::@9/(byte) 9 ) - [27] (byte) test::a#11 ← phi( main/(byte) 3 main::@1/(byte) 3+(byte) 1 main::@10/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 main::@2/(byte) 3+(byte) 1-(byte) 1 main::@3/(byte) 3+(byte) 1-(byte) 1*(byte) 6 main::@4/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2 main::@5/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2 main::@6/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2 main::@7/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1 main::@8/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6 main::@9/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 ) + [27] (byte) test::a#11 ← phi( main/(byte) 3 main::@1/(byte) 3+(byte) 1 main::@10/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 main::@2/(byte) 3+(byte) 1-(byte) 1 main::@3/(byte) 3+(byte) 1-(byte) 1*(byte) 6 main::@4/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2 main::@5/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1 main::@6/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2 main::@7/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1 main::@8/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6 main::@9/(byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 ) [28] *((const byte*) screen1 + (byte) test::i#11) ← (byte) test::a#11 [29] *((const byte*) screen2#0 + (byte) test::i#11) ← *((const byte*) ref + (byte) test::i#11) [30] if(*((const byte*) ref + (byte) test::i#11)==(byte) test::a#11) goto test::@1 @@ -810,8 +812,8 @@ main: { // [27] phi (byte) test::i#11 = (byte) 5 [phi:main::@5->test#0] -- vbuz1=vbuc1 lda #5 sta.z test.i - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2 [phi:main::@5->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2) + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1 [phi:main::@5->test#1] -- vbuz1=vbuc1 + lda #(3+1-1)*6/2&2-1 sta.z test.a jsr test // [16] phi from main::@5 to main::@6 [phi:main::@5->main::@6] @@ -825,8 +827,8 @@ main: { // [27] phi (byte) test::i#11 = (byte) 6 [phi:main::@6->test#0] -- vbuz1=vbuc1 lda #6 sta.z test.i - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2 [phi:main::@6->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2 [phi:main::@6->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2 sta.z test.a jsr test // [18] phi from main::@6 to main::@7 [phi:main::@6->main::@7] @@ -840,8 +842,8 @@ main: { // [27] phi (byte) test::i#11 = (byte) 7 [phi:main::@7->test#0] -- vbuz1=vbuc1 lda #7 sta.z test.i - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1 [phi:main::@7->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2>>1 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1 [phi:main::@7->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2>>1 sta.z test.a jsr test // [20] phi from main::@7 to main::@8 [phi:main::@7->main::@8] @@ -855,8 +857,8 @@ main: { // [27] phi (byte) test::i#11 = (byte) 8 [phi:main::@8->test#0] -- vbuz1=vbuc1 lda #8 sta.z test.i - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6 [phi:main::@8->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2>>1^6 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6 [phi:main::@8->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2>>1^6 sta.z test.a jsr test // [22] phi from main::@8 to main::@9 [phi:main::@8->main::@9] @@ -870,8 +872,8 @@ main: { // [27] phi (byte) test::i#11 = (byte) 9 [phi:main::@9->test#0] -- vbuz1=vbuc1 lda #9 sta.z test.i - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 [phi:main::@9->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2>>1^6|1 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 [phi:main::@9->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2>>1^6|1 sta.z test.a jsr test // [24] phi from main::@9 to main::@10 [phi:main::@9->main::@10] @@ -885,8 +887,8 @@ main: { // [27] phi (byte) test::i#11 = (byte) $a [phi:main::@10->test#0] -- vbuz1=vbuc1 lda #$a sta.z test.i - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 [phi:main::@10->test#1] -- vbuz1=vbuc1 - lda #(mod((3+1-1)*6/2,2)<<2>>1^6|1)&1 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 [phi:main::@10->test#1] -- vbuz1=vbuc1 + lda #(((3+1-1)*6/2&2-1)<<2>>1^6|1)&1 sta.z test.a jsr test jmp __breturn @@ -1068,8 +1070,8 @@ main: { test_from___b5: // [27] phi (byte) test::i#11 = (byte) 5 [phi:main::@5->test#0] -- vbuxx=vbuc1 ldx #5 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2 [phi:main::@5->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2) + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1 [phi:main::@5->test#1] -- vbuz1=vbuc1 + lda #(3+1-1)*6/2&2-1 sta.z test.a jsr test // [16] phi from main::@5 to main::@6 [phi:main::@5->main::@6] @@ -1082,8 +1084,8 @@ main: { test_from___b6: // [27] phi (byte) test::i#11 = (byte) 6 [phi:main::@6->test#0] -- vbuxx=vbuc1 ldx #6 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2 [phi:main::@6->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2 [phi:main::@6->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2 sta.z test.a jsr test // [18] phi from main::@6 to main::@7 [phi:main::@6->main::@7] @@ -1096,8 +1098,8 @@ main: { test_from___b7: // [27] phi (byte) test::i#11 = (byte) 7 [phi:main::@7->test#0] -- vbuxx=vbuc1 ldx #7 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1 [phi:main::@7->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2>>1 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1 [phi:main::@7->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2>>1 sta.z test.a jsr test // [20] phi from main::@7 to main::@8 [phi:main::@7->main::@8] @@ -1110,8 +1112,8 @@ main: { test_from___b8: // [27] phi (byte) test::i#11 = (byte) 8 [phi:main::@8->test#0] -- vbuxx=vbuc1 ldx #8 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6 [phi:main::@8->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2>>1^6 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6 [phi:main::@8->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2>>1^6 sta.z test.a jsr test // [22] phi from main::@8 to main::@9 [phi:main::@8->main::@9] @@ -1124,8 +1126,8 @@ main: { test_from___b9: // [27] phi (byte) test::i#11 = (byte) 9 [phi:main::@9->test#0] -- vbuxx=vbuc1 ldx #9 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 [phi:main::@9->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2>>1^6|1 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 [phi:main::@9->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2>>1^6|1 sta.z test.a jsr test // [24] phi from main::@9 to main::@10 [phi:main::@9->main::@10] @@ -1138,8 +1140,8 @@ main: { test_from___b10: // [27] phi (byte) test::i#11 = (byte) $a [phi:main::@10->test#0] -- vbuxx=vbuc1 ldx #$a - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 [phi:main::@10->test#1] -- vbuz1=vbuc1 - lda #(mod((3+1-1)*6/2,2)<<2>>1^6|1)&1 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 [phi:main::@10->test#1] -- vbuz1=vbuc1 + lda #(((3+1-1)*6/2&2-1)<<2>>1^6|1)&1 sta.z test.a jsr test jmp __breturn @@ -1372,8 +1374,8 @@ main: { // [27] phi from main::@5 to test [phi:main::@5->test] // [27] phi (byte) test::i#11 = (byte) 5 [phi:main::@5->test#0] -- vbuxx=vbuc1 ldx #5 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2 [phi:main::@5->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2) + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1 [phi:main::@5->test#1] -- vbuz1=vbuc1 + lda #(3+1-1)*6/2&2-1 sta.z test.a jsr test // [16] phi from main::@5 to main::@6 [phi:main::@5->main::@6] @@ -1383,8 +1385,8 @@ main: { // [27] phi from main::@6 to test [phi:main::@6->test] // [27] phi (byte) test::i#11 = (byte) 6 [phi:main::@6->test#0] -- vbuxx=vbuc1 ldx #6 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2 [phi:main::@6->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2 [phi:main::@6->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2 sta.z test.a jsr test // [18] phi from main::@6 to main::@7 [phi:main::@6->main::@7] @@ -1394,8 +1396,8 @@ main: { // [27] phi from main::@7 to test [phi:main::@7->test] // [27] phi (byte) test::i#11 = (byte) 7 [phi:main::@7->test#0] -- vbuxx=vbuc1 ldx #7 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1 [phi:main::@7->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2>>1 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1 [phi:main::@7->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2>>1 sta.z test.a jsr test // [20] phi from main::@7 to main::@8 [phi:main::@7->main::@8] @@ -1405,8 +1407,8 @@ main: { // [27] phi from main::@8 to test [phi:main::@8->test] // [27] phi (byte) test::i#11 = (byte) 8 [phi:main::@8->test#0] -- vbuxx=vbuc1 ldx #8 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6 [phi:main::@8->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2>>1^6 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6 [phi:main::@8->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2>>1^6 sta.z test.a jsr test // [22] phi from main::@8 to main::@9 [phi:main::@8->main::@9] @@ -1416,8 +1418,8 @@ main: { // [27] phi from main::@9 to test [phi:main::@9->test] // [27] phi (byte) test::i#11 = (byte) 9 [phi:main::@9->test#0] -- vbuxx=vbuc1 ldx #9 - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 [phi:main::@9->test#1] -- vbuz1=vbuc1 - lda #mod((3+1-1)*6/2,2)<<2>>1^6|1 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1 [phi:main::@9->test#1] -- vbuz1=vbuc1 + lda #((3+1-1)*6/2&2-1)<<2>>1^6|1 sta.z test.a jsr test // [24] phi from main::@9 to main::@10 [phi:main::@9->main::@10] @@ -1427,8 +1429,8 @@ main: { // [27] phi from main::@10 to test [phi:main::@10->test] // [27] phi (byte) test::i#11 = (byte) $a [phi:main::@10->test#0] -- vbuxx=vbuc1 ldx #$a - // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2%(byte) 2<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 [phi:main::@10->test#1] -- vbuz1=vbuc1 - lda #(mod((3+1-1)*6/2,2)<<2>>1^6|1)&1 + // [27] phi (byte) test::a#11 = (byte) 3+(byte) 1-(byte) 1*(byte) 6/(byte) 2&(byte) 2-(byte) 1<<(byte) 2>>(byte) 1^(byte) 6|(byte) 1&(byte) 1 [phi:main::@10->test#1] -- vbuz1=vbuc1 + lda #(((3+1-1)*6/2&2-1)<<2>>1^6|1)&1 sta.z test.a jsr test // main::@return diff --git a/src/test/ref/bitmap-plot-0.log b/src/test/ref/bitmap-plot-0.log index dcc0ab688..847645460 100644 --- a/src/test/ref/bitmap-plot-0.log +++ b/src/test/ref/bitmap-plot-0.log @@ -2321,12 +2321,12 @@ Allocated (was zp[2]:24) zp[2]:8 [ bitmap_plot::plotter#0 bitmap_plot::plotter#1 Allocated (was zp[2]:26) zp[2]:10 [ bitmap_plot::$1 ] Allocated (was zp[1]:33) zp[1]:12 [ bitmap_init::$7 main::y#2 main::y#1 ] Interrupt procedure irq clobbers ACNZ -Removing interrupt register storage stx regx+1 in CHU154 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage sty regy+1 in CHU154 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regx: in CHU163 [85] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldx #00 in CHU163 [85] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regy: in CHU163 [85] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldy #00 in CHU163 [85] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage stx regx+1 in 154 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage sty regy+1 in 154 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regx: in 163 [85] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldx #00 in 163 [85] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regy: in 163 [85] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldy #00 in 163 [85] return - exit interrupt(HARDWARE_CLOBBER) ASSEMBLER BEFORE OPTIMIZATION // File Comments diff --git a/src/test/ref/bitmap-plot-1.log b/src/test/ref/bitmap-plot-1.log index c68f7ac80..d5e582778 100644 --- a/src/test/ref/bitmap-plot-1.log +++ b/src/test/ref/bitmap-plot-1.log @@ -6119,12 +6119,12 @@ Allocated (was zp[4]:163) zp[4]:28 [ sin16s::$4 mul16u::mb#2 mul16u::mb#0 mul16u Allocated (was zp[2]:169) zp[2]:32 [ mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 main::idx_y#3 main::idx_y#10 main::idx_y#1 ] Allocated (was zp[2]:211) zp[2]:34 [ div32u16u::quotient_hi#0 sin16s::x1#0 ] Interrupt procedure irq clobbers ACNZ -Removing interrupt register storage stx regx+1 in CHU422 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage sty regy+1 in CHU422 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regx: in CHU431 [230] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldx #00 in CHU431 [230] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regy: in CHU431 [230] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldy #00 in CHU431 [230] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage stx regx+1 in 422 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage sty regy+1 in 422 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regx: in 431 [230] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldx #00 in 431 [230] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regy: in 431 [230] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldy #00 in 431 [230] return - exit interrupt(HARDWARE_CLOBBER) ASSEMBLER BEFORE OPTIMIZATION // File Comments diff --git a/src/test/ref/bitmap-plot-2.log b/src/test/ref/bitmap-plot-2.log index 09fda018f..b36c9751a 100644 --- a/src/test/ref/bitmap-plot-2.log +++ b/src/test/ref/bitmap-plot-2.log @@ -6413,12 +6413,12 @@ Allocated (was zp[4]:162) zp[4]:28 [ sin16s::$4 mul16u::mb#2 mul16u::mb#0 mul16u Allocated (was zp[2]:168) zp[2]:32 [ mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 bitmap_init::yoffs#2 bitmap_init::yoffs#4 bitmap_init::yoffs#1 main::idx_y#3 main::idx_y#10 main::idx_y#1 ] Allocated (was zp[2]:210) zp[2]:34 [ div32u16u::quotient_hi#0 sin16s::x1#0 sin16s_gen2::$9 mul16s::$13 mul16s::$17 ] Interrupt procedure irq clobbers ACNZ -Removing interrupt register storage stx regx+1 in CHU441 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage sty regy+1 in CHU441 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regx: in CHU450 [239] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldx #00 in CHU450 [239] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regy: in CHU450 [239] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldy #00 in CHU450 [239] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage stx regx+1 in 441 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage sty regy+1 in 441 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regx: in 450 [239] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldx #00 in 450 [239] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regy: in 450 [239] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldy #00 in 450 [239] return - exit interrupt(HARDWARE_CLOBBER) ASSEMBLER BEFORE OPTIMIZATION // File Comments diff --git a/src/test/ref/clobber-a-problem.log b/src/test/ref/clobber-a-problem.log index 336b9092d..f4e1068a1 100644 --- a/src/test/ref/clobber-a-problem.log +++ b/src/test/ref/clobber-a-problem.log @@ -313,9 +313,9 @@ Attempting to uplift remaining variables inzp[1]:3 [ irq_raster_next ] Uplifting [] best 246 combination zp[1]:3 [ irq_raster_next ] Allocated (was zp[1]:3) zp[1]:2 [ irq_raster_next ] Interrupt procedure irq clobbers AXCNZ -Removing interrupt register storage sty regy+1 in CHU16 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regy: in CHU30 [16] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldy #00 in CHU30 [16] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage sty regy+1 in 16 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regy: in 30 [16] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldy #00 in 30 [16] return - exit interrupt(HARDWARE_CLOBBER) ASSEMBLER BEFORE OPTIMIZATION // File Comments diff --git a/src/test/ref/complex/tetris/test-sprites.log b/src/test/ref/complex/tetris/test-sprites.log index 0e3d45278..502598257 100644 --- a/src/test/ref/complex/tetris/test-sprites.log +++ b/src/test/ref/complex/tetris/test-sprites.log @@ -2443,9 +2443,9 @@ Allocated (was zp[1]:13) zp[1]:7 [ irq_sprite_ptr ] Allocated (was zp[1]:14) zp[1]:8 [ irq_cnt ] Allocated (was zp[1]:21) zp[1]:9 [ sprites_irq::raster_sprite_gfx_modify ] Interrupt procedure sprites_irq clobbers AXCNZV -Removing interrupt register storage sty regy+1 in CHU127 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regy: in CHU161 [97] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldy #00 in CHU161 [97] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage sty regy+1 in 127 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regy: in 161 [97] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldy #00 in 161 [97] return - exit interrupt(HARDWARE_CLOBBER) ASSEMBLER BEFORE OPTIMIZATION // File Comments diff --git a/src/test/ref/complex/tetris/tetris.log b/src/test/ref/complex/tetris/tetris.log index cafe323d0..1c61d5999 100644 --- a/src/test/ref/complex/tetris/tetris.log +++ b/src/test/ref/complex/tetris/tetris.log @@ -16781,9 +16781,9 @@ Allocated (was zp[1]:193) zp[1]:45 [ keyboard_event_pressed::row_bits#0 play_spa Allocated (was zp[1]:198) zp[1]:46 [ keyboard_event_scan::row_scan#0 play_lock_current::i#1 play_collision::i#1 ] Allocated (was zp[1]:218) zp[1]:47 [ sprites_irq::raster_sprite_gfx_modify ] Interrupt procedure sprites_irq clobbers AXCNZV -Removing interrupt register storage sty regy+1 in CHU1185 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regy: in CHU1219 [576] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldy #00 in CHU1219 [576] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage sty regy+1 in 1185 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regy: in 1219 [576] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldy #00 in 1219 [576] return - exit interrupt(HARDWARE_CLOBBER) ASSEMBLER BEFORE OPTIMIZATION // File Comments diff --git a/src/test/ref/double-indexing-arrays.asm b/src/test/ref/double-indexing-arrays.asm index d796a2780..827f8e883 100644 --- a/src/test/ref/double-indexing-arrays.asm +++ b/src/test/ref/double-indexing-arrays.asm @@ -5,35 +5,35 @@ .label SCREEN = $400 .label COLS = $d800 main: { - ldy #0 + ldx #0 __b1: - lda MAPDATA,y - sta SCREEN,y - ldx MAPDATA,y - lda COLORMAP1,x - sta COLS,y - lda MAPDATA+$c8,y - sta SCREEN+$c8,y - ldx MAPDATA+$c8,y - lda COLORMAP1,x - sta COLS+$c8,y - lda MAPDATA+$190,y - sta SCREEN+$190,y - ldx MAPDATA+$190,y - lda COLORMAP1,x - sta COLS+$190,y - lda MAPDATA+$258,y - sta SCREEN+$258,y - ldx MAPDATA+$258,y - lda COLORMAP2,x - sta COLS+$258,y - lda MAPDATA+$320,y - sta SCREEN+$320,y - ldx MAPDATA+$320,y - lda COLORMAP2,x - sta COLS+$320,y - iny - cpy #$c9 + lda MAPDATA,x + sta SCREEN,x + ldy MAPDATA,x + lda COLORMAP1,y + sta COLS,x + lda MAPDATA+$c8,x + sta SCREEN+$c8,x + ldy MAPDATA+$c8,x + lda COLORMAP1,y + sta COLS+$c8,x + lda MAPDATA+$190,x + sta SCREEN+$190,x + ldy MAPDATA+$190,x + lda COLORMAP1,y + sta COLS+$190,x + lda MAPDATA+$258,x + sta SCREEN+$258,x + ldy MAPDATA+$258,x + lda COLORMAP2,y + sta COLS+$258,x + lda MAPDATA+$320,x + sta SCREEN+$320,x + ldy MAPDATA+$320,x + lda COLORMAP2,y + sta COLS+$320,x + inx + cpx #$c9 bne __b1 rts } diff --git a/src/test/ref/double-indexing-arrays.log b/src/test/ref/double-indexing-arrays.log index 91373a865..0833d4858 100644 --- a/src/test/ref/double-indexing-arrays.log +++ b/src/test/ref/double-indexing-arrays.log @@ -82,10 +82,10 @@ SYMBOL TABLE SSA (number~) main::$9 (label) main::@1 (label) main::@return -(byte) main::x !reg byte y -(byte) main::x#0 !reg byte y -(byte) main::x#1 !reg byte y -(byte) main::x#2 !reg byte y +(byte) main::x +(byte) main::x#0 +(byte) main::x#1 +(byte) main::x#2 Adding number conversion cast (unumber) $c8 in (number~) main::$0 ← (number) $c8 + (byte) main::x#2 Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (unumber)(number) $c8 + (byte) main::x#2 @@ -301,14 +301,15 @@ main::@return: scope:[main] from main::@1 VARIABLE REGISTER WEIGHTS (void()) main() -(byte) main::x !reg byte y -(byte) main::x#1 !reg byte y 16.5 -(byte) main::x#2 !reg byte y 22.0 +(byte) main::x +(byte) main::x#1 16.5 +(byte) main::x#2 22.0 Initial phi equivalence classes [ main::x#2 main::x#1 ] Complete equivalence classes [ main::x#2 main::x#1 ] +Allocated zp[1]:2 [ main::x#2 main::x#1 ] INITIAL ASM Target platform is c64basic / MOS6502X @@ -339,10 +340,12 @@ __bend_from___b1: __bend: // main main: { + .label x = 2 // [5] phi from main to main::@1 [phi:main->main::@1] __b1_from_main: - // [5] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 - ldy #0 + // [5] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 + lda #0 + sta.z x jmp __b1 // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] __b1_from___b1: @@ -350,45 +353,56 @@ main: { jmp __b1 // main::@1 __b1: - // [6] *((const byte*) SCREEN + (byte) main::x#2) ← *((const byte*) MAPDATA + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy + // [6] *((const byte*) SCREEN + (byte) main::x#2) ← *((const byte*) MAPDATA + (byte) main::x#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + ldy.z x lda MAPDATA,y sta SCREEN,y - // [7] *((const byte*) COLS + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA,y - lda COLORMAP1,x - sta COLS,y - // [8] *((const byte*) SCREEN+(byte) $c8 + (byte) main::x#2) ← *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy + // [7] *((const byte*) COLS + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA + (byte) main::x#2)) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_(pbuc3_derefidx_vbuz1) + ldx.z x + ldy MAPDATA,x + lda COLORMAP1,y + sta COLS,x + // [8] *((const byte*) SCREEN+(byte) $c8 + (byte) main::x#2) ← *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + ldy.z x lda MAPDATA+$c8,y sta SCREEN+$c8,y - // [9] *((const byte*) COLS+(byte) $c8 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$c8,y - lda COLORMAP1,x - sta COLS+$c8,y - // [10] *((const byte*) SCREEN+(word) $190 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy + // [9] *((const byte*) COLS+(byte) $c8 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2)) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_(pbuc3_derefidx_vbuz1) + ldx.z x + ldy MAPDATA+$c8,x + lda COLORMAP1,y + sta COLS+$c8,x + // [10] *((const byte*) SCREEN+(word) $190 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + ldy.z x lda MAPDATA+$190,y sta SCREEN+$190,y - // [11] *((const byte*) COLS+(word) $190 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$190,y - lda COLORMAP1,x - sta COLS+$190,y - // [12] *((const byte*) SCREEN+(word) $258 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy + // [11] *((const byte*) COLS+(word) $190 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2)) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_(pbuc3_derefidx_vbuz1) + ldx.z x + ldy MAPDATA+$190,x + lda COLORMAP1,y + sta COLS+$190,x + // [12] *((const byte*) SCREEN+(word) $258 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + ldy.z x lda MAPDATA+$258,y sta SCREEN+$258,y - // [13] *((const byte*) COLS+(word) $258 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$258,y - lda COLORMAP2,x - sta COLS+$258,y - // [14] *((const byte*) SCREEN+(word) $320 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy + // [13] *((const byte*) COLS+(word) $258 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2)) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_(pbuc3_derefidx_vbuz1) + ldx.z x + ldy MAPDATA+$258,x + lda COLORMAP2,y + sta COLS+$258,x + // [14] *((const byte*) SCREEN+(word) $320 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + ldy.z x lda MAPDATA+$320,y sta SCREEN+$320,y - // [15] *((const byte*) COLS+(word) $320 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$320,y - lda COLORMAP2,x - sta COLS+$320,y - // [16] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuyy=_inc_vbuyy - iny - // [17] if((byte) main::x#1!=(byte) $c9) goto main::@1 -- vbuyy_neq_vbuc1_then_la1 - cpy #$c9 + // [15] *((const byte*) COLS+(word) $320 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2)) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_(pbuc3_derefidx_vbuz1) + ldx.z x + ldy MAPDATA+$320,x + lda COLORMAP2,y + sta COLS+$320,x + // [16] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuz1=_inc_vbuz1 + inc.z x + // [17] if((byte) main::x#1!=(byte) $c9) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$c9 + cmp.z x bne __b1_from___b1 jmp __breturn // main::@return @@ -403,23 +417,33 @@ main: { REGISTER UPLIFT POTENTIAL REGISTERS Statement [6] *((const byte*) SCREEN + (byte) main::x#2) ← *((const byte*) MAPDATA + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a -Statement [7] *((const byte*) COLS + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a reg byte x +Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::x#2 main::x#1 ] +Statement [7] *((const byte*) COLS + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a Statement [8] *((const byte*) SCREEN+(byte) $c8 + (byte) main::x#2) ← *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a -Statement [9] *((const byte*) COLS+(byte) $c8 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a reg byte x +Statement [9] *((const byte*) COLS+(byte) $c8 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a Statement [10] *((const byte*) SCREEN+(word) $190 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a -Statement [11] *((const byte*) COLS+(word) $190 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a reg byte x +Statement [11] *((const byte*) COLS+(word) $190 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a Statement [12] *((const byte*) SCREEN+(word) $258 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a -Statement [13] *((const byte*) COLS+(word) $258 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a reg byte x +Statement [13] *((const byte*) COLS+(word) $258 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a Statement [14] *((const byte*) SCREEN+(word) $320 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a -Statement [15] *((const byte*) COLS+(word) $320 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a reg byte x -Statement [16] (byte) main::x#1 ← ++ (byte) main::x#2 [ main::x#1 ] ( main:2 [ main::x#1 ] ) always clobbers reg byte y -Potential registers reg byte y [ main::x#2 main::x#1 ] : reg byte y , +Statement [15] *((const byte*) COLS+(word) $320 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [6] *((const byte*) SCREEN + (byte) main::x#2) ← *((const byte*) MAPDATA + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [7] *((const byte*) COLS + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [8] *((const byte*) SCREEN+(byte) $c8 + (byte) main::x#2) ← *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [9] *((const byte*) COLS+(byte) $c8 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [10] *((const byte*) SCREEN+(word) $190 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [11] *((const byte*) COLS+(word) $190 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [12] *((const byte*) SCREEN+(word) $258 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [13] *((const byte*) COLS+(word) $258 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [14] *((const byte*) SCREEN+(word) $320 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Statement [15] *((const byte*) COLS+(word) $320 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2)) [ main::x#2 ] ( main:2 [ main::x#2 ] ) always clobbers reg byte a +Potential registers zp[1]:2 [ main::x#2 main::x#1 ] : zp[1]:2 , reg byte x , reg byte y , REGISTER UPLIFT SCOPES -Uplift Scope [main] 38.5: reg byte y [ main::x#2 main::x#1 ] +Uplift Scope [main] 38.5: zp[1]:2 [ main::x#2 main::x#1 ] Uplift Scope [] -Uplifting [main] best 1368 combination reg byte y [ main::x#2 main::x#1 ] +Uplifting [main] best 1368 combination reg byte x [ main::x#2 main::x#1 ] Uplifting [] best 1368 combination ASSEMBLER BEFORE OPTIMIZATION @@ -452,8 +476,8 @@ __bend: main: { // [5] phi from main to main::@1 [phi:main->main::@1] __b1_from_main: - // [5] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 - ldy #0 + // [5] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 jmp __b1 // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] __b1_from___b1: @@ -461,45 +485,45 @@ main: { jmp __b1 // main::@1 __b1: - // [6] *((const byte*) SCREEN + (byte) main::x#2) ← *((const byte*) MAPDATA + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA,y - sta SCREEN,y - // [7] *((const byte*) COLS + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA,y - lda COLORMAP1,x - sta COLS,y - // [8] *((const byte*) SCREEN+(byte) $c8 + (byte) main::x#2) ← *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA+$c8,y - sta SCREEN+$c8,y - // [9] *((const byte*) COLS+(byte) $c8 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$c8,y - lda COLORMAP1,x - sta COLS+$c8,y - // [10] *((const byte*) SCREEN+(word) $190 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA+$190,y - sta SCREEN+$190,y - // [11] *((const byte*) COLS+(word) $190 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$190,y - lda COLORMAP1,x - sta COLS+$190,y - // [12] *((const byte*) SCREEN+(word) $258 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA+$258,y - sta SCREEN+$258,y - // [13] *((const byte*) COLS+(word) $258 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$258,y - lda COLORMAP2,x - sta COLS+$258,y - // [14] *((const byte*) SCREEN+(word) $320 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA+$320,y - sta SCREEN+$320,y - // [15] *((const byte*) COLS+(word) $320 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$320,y - lda COLORMAP2,x - sta COLS+$320,y - // [16] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuyy=_inc_vbuyy - iny - // [17] if((byte) main::x#1!=(byte) $c9) goto main::@1 -- vbuyy_neq_vbuc1_then_la1 - cpy #$c9 + // [6] *((const byte*) SCREEN + (byte) main::x#2) ← *((const byte*) MAPDATA + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA,x + sta SCREEN,x + // [7] *((const byte*) COLS + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA,x + lda COLORMAP1,y + sta COLS,x + // [8] *((const byte*) SCREEN+(byte) $c8 + (byte) main::x#2) ← *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA+$c8,x + sta SCREEN+$c8,x + // [9] *((const byte*) COLS+(byte) $c8 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA+$c8,x + lda COLORMAP1,y + sta COLS+$c8,x + // [10] *((const byte*) SCREEN+(word) $190 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA+$190,x + sta SCREEN+$190,x + // [11] *((const byte*) COLS+(word) $190 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA+$190,x + lda COLORMAP1,y + sta COLS+$190,x + // [12] *((const byte*) SCREEN+(word) $258 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA+$258,x + sta SCREEN+$258,x + // [13] *((const byte*) COLS+(word) $258 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA+$258,x + lda COLORMAP2,y + sta COLS+$258,x + // [14] *((const byte*) SCREEN+(word) $320 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA+$320,x + sta SCREEN+$320,x + // [15] *((const byte*) COLS+(word) $320 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA+$320,x + lda COLORMAP2,y + sta COLS+$320,x + // [16] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuxx=_inc_vbuxx + inx + // [17] if((byte) main::x#1!=(byte) $c9) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 + cpx #$c9 bne __b1_from___b1 jmp __breturn // main::@return @@ -550,11 +574,11 @@ FINAL SYMBOL TABLE (void()) main() (label) main::@1 (label) main::@return -(byte) main::x !reg byte y -(byte) main::x#1 !reg byte y 16.5 -(byte) main::x#2 !reg byte y 22.0 +(byte) main::x +(byte) main::x#1 reg byte x 16.5 +(byte) main::x#2 reg byte x 22.0 -reg byte y [ main::x#2 main::x#1 ] +reg byte x [ main::x#2 main::x#1 ] FINAL ASSEMBLER @@ -579,62 +603,62 @@ Score: 1266 // main main: { // [5] phi from main to main::@1 [phi:main->main::@1] - // [5] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 - ldy #0 + // [5] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] // [5] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@1->main::@1#0] -- register_copy // main::@1 __b1: // SCREEN[x] = MAPDATA[x] - // [6] *((const byte*) SCREEN + (byte) main::x#2) ← *((const byte*) MAPDATA + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA,y - sta SCREEN,y + // [6] *((const byte*) SCREEN + (byte) main::x#2) ← *((const byte*) MAPDATA + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA,x + sta SCREEN,x // COLS[x] = COLORMAP1[MAPDATA[x]] - // [7] *((const byte*) COLS + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA,y - lda COLORMAP1,x - sta COLS,y + // [7] *((const byte*) COLS + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA,x + lda COLORMAP1,y + sta COLS,x // SCREEN[200+x] = MAPDATA[200+x] - // [8] *((const byte*) SCREEN+(byte) $c8 + (byte) main::x#2) ← *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA+$c8,y - sta SCREEN+$c8,y + // [8] *((const byte*) SCREEN+(byte) $c8 + (byte) main::x#2) ← *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA+$c8,x + sta SCREEN+$c8,x // COLS[200+x] = COLORMAP1[MAPDATA[200+x]] - // [9] *((const byte*) COLS+(byte) $c8 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$c8,y - lda COLORMAP1,x - sta COLS+$c8,y + // [9] *((const byte*) COLS+(byte) $c8 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(byte) $c8 + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA+$c8,x + lda COLORMAP1,y + sta COLS+$c8,x // SCREEN[400+x] = MAPDATA[400+x] - // [10] *((const byte*) SCREEN+(word) $190 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA+$190,y - sta SCREEN+$190,y + // [10] *((const byte*) SCREEN+(word) $190 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA+$190,x + sta SCREEN+$190,x // COLS[400+x] = COLORMAP1[MAPDATA[400+x]] - // [11] *((const byte*) COLS+(word) $190 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$190,y - lda COLORMAP1,x - sta COLS+$190,y + // [11] *((const byte*) COLS+(word) $190 + (byte) main::x#2) ← *((const byte*) COLORMAP1 + *((const byte*) MAPDATA+(word) $190 + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA+$190,x + lda COLORMAP1,y + sta COLS+$190,x // SCREEN[600+x] = MAPDATA[600+x] - // [12] *((const byte*) SCREEN+(word) $258 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA+$258,y - sta SCREEN+$258,y + // [12] *((const byte*) SCREEN+(word) $258 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA+$258,x + sta SCREEN+$258,x // COLS[600+x] = COLORMAP2[MAPDATA[600+x]] - // [13] *((const byte*) COLS+(word) $258 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$258,y - lda COLORMAP2,x - sta COLS+$258,y + // [13] *((const byte*) COLS+(word) $258 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $258 + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA+$258,x + lda COLORMAP2,y + sta COLS+$258,x // SCREEN[800+x] = MAPDATA[800+x] - // [14] *((const byte*) SCREEN+(word) $320 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy - lda MAPDATA+$320,y - sta SCREEN+$320,y + // [14] *((const byte*) SCREEN+(word) $320 + (byte) main::x#2) ← *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MAPDATA+$320,x + sta SCREEN+$320,x // COLS[800+x] = COLORMAP2[MAPDATA[800+x]] - // [15] *((const byte*) COLS+(word) $320 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2)) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_(pbuc3_derefidx_vbuyy) - ldx MAPDATA+$320,y - lda COLORMAP2,x - sta COLS+$320,y - // for (byte register(y) x: 0..200) - // [16] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuyy=_inc_vbuyy - iny - // [17] if((byte) main::x#1!=(byte) $c9) goto main::@1 -- vbuyy_neq_vbuc1_then_la1 - cpy #$c9 + // [15] *((const byte*) COLS+(word) $320 + (byte) main::x#2) ← *((const byte*) COLORMAP2 + *((const byte*) MAPDATA+(word) $320 + (byte) main::x#2)) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_(pbuc3_derefidx_vbuxx) + ldy MAPDATA+$320,x + lda COLORMAP2,y + sta COLS+$320,x + // for (byte x: 0..200) + // [16] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuxx=_inc_vbuxx + inx + // [17] if((byte) main::x#1!=(byte) $c9) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 + cpx #$c9 bne __b1 // main::@return // } diff --git a/src/test/ref/double-indexing-arrays.sym b/src/test/ref/double-indexing-arrays.sym index 02a5295d4..8965baa2f 100644 --- a/src/test/ref/double-indexing-arrays.sym +++ b/src/test/ref/double-indexing-arrays.sym @@ -9,8 +9,8 @@ (void()) main() (label) main::@1 (label) main::@return -(byte) main::x !reg byte y -(byte) main::x#1 !reg byte y 16.5 -(byte) main::x#2 !reg byte y 22.0 +(byte) main::x +(byte) main::x#1 reg byte x 16.5 +(byte) main::x#2 reg byte x 22.0 -reg byte y [ main::x#2 main::x#1 ] +reg byte x [ main::x#2 main::x#1 ] diff --git a/src/test/ref/irq-hardware-clobber-jsr.log b/src/test/ref/irq-hardware-clobber-jsr.log index 4205040a5..335658b6e 100644 --- a/src/test/ref/irq-hardware-clobber-jsr.log +++ b/src/test/ref/irq-hardware-clobber-jsr.log @@ -354,12 +354,12 @@ Uplifting [irq] best 329 combination Uplifting [do_irq] best 329 combination Uplifting [] best 329 combination Interrupt procedure irq clobbers ANZ -Removing interrupt register storage stx regx+1 in CHU22 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage sty regy+1 in CHU22 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regx: in CHU25 [16] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldx #00 in CHU25 [16] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regy: in CHU25 [16] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldy #00 in CHU25 [16] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage stx regx+1 in 22 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage sty regy+1 in 22 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regx: in 25 [16] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldx #00 in 25 [16] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regy: in 25 [16] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldy #00 in 25 [16] return - exit interrupt(HARDWARE_CLOBBER) ASSEMBLER BEFORE OPTIMIZATION // File Comments diff --git a/src/test/ref/irq-hardware-clobber.log b/src/test/ref/irq-hardware-clobber.log index 218bc1bba..0667a9f33 100644 --- a/src/test/ref/irq-hardware-clobber.log +++ b/src/test/ref/irq-hardware-clobber.log @@ -302,12 +302,12 @@ Uplifting [main] best 314 combination Uplifting [irq] best 314 combination Uplifting [] best 314 combination Interrupt procedure irq clobbers ANZ -Removing interrupt register storage stx regx+1 in CHU22 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage sty regy+1 in CHU22 entry interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regx: in CHU27 [17] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldx #00 in CHU27 [17] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage regy: in CHU27 [17] return - exit interrupt(HARDWARE_CLOBBER) -Removing interrupt register storage ldy #00 in CHU27 [17] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage stx regx+1 in 22 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage sty regy+1 in 22 entry interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regx: in 27 [17] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldx #00 in 27 [17] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage regy: in 27 [17] return - exit interrupt(HARDWARE_CLOBBER) +Removing interrupt register storage ldy #00 in 27 [17] return - exit interrupt(HARDWARE_CLOBBER) ASSEMBLER BEFORE OPTIMIZATION // File Comments