1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Added constant addition consolidation optimization.

This commit is contained in:
Jesper Gravgaard 2017-10-15 17:53:18 +02:00
parent 525ac454cc
commit 7b9e80aaac
45 changed files with 4311 additions and 3671 deletions

View File

@ -141,7 +141,7 @@ public class Compiler {
optimizations.add(new Pass2SelfPhiElimination(program)); optimizations.add(new Pass2SelfPhiElimination(program));
optimizations.add(new Pass2ConditionalJumpSimplification(program)); optimizations.add(new Pass2ConditionalJumpSimplification(program));
optimizations.add(new Pass2ConstantIdentification(program)); optimizations.add(new Pass2ConstantIdentification(program));
optimizations.add(new Pass2ConstantAdditionElimination(program));
pass2OptimizeSSA(program, optimizations); pass2OptimizeSSA(program, optimizations);
// Constant inlining optimizations - as the last step to ensure that constant identification has been completed // Constant inlining optimizations - as the last step to ensure that constant identification has been completed
@ -149,9 +149,6 @@ public class Compiler {
constantOptimizations.add(new Pass2ConstantInlining(program)); constantOptimizations.add(new Pass2ConstantInlining(program));
pass2OptimizeSSA(program, constantOptimizations); pass2OptimizeSSA(program, constantOptimizations);
//optimizations.add(new Pass2ConstantPropagation(program));
//optimizations.add(new Pass2ConstantAdditionElimination(program));
} }
private void pass2OptimizeSSA(Program program, List<Pass2SsaOptimization> optimizations) { private void pass2OptimizeSSA(Program program, List<Pass2SsaOptimization> optimizations) {
@ -160,12 +157,15 @@ public class Compiler {
pass2AssertSSA(program); pass2AssertSSA(program);
ssaOptimized = false; ssaOptimized = false;
for (Pass2SsaOptimization optimization : optimizations) { for (Pass2SsaOptimization optimization : optimizations) {
boolean stepOptimized = optimization.optimize(); boolean stepOptimized = true;
if (stepOptimized) { while (stepOptimized) {
program.getLog().append("Succesful SSA optimization " + optimization.getClass().getSimpleName() + ""); stepOptimized = optimization.optimize();
ssaOptimized = true; if (stepOptimized) {
program.getLog().append("CONTROL FLOW GRAPH"); program.getLog().append("Succesful SSA optimization " + optimization.getClass().getSimpleName() + "");
program.getLog().append(program.getGraph().toString(program)); ssaOptimized = true;
program.getLog().append("CONTROL FLOW GRAPH");
program.getLog().append(program.getGraph().toString(program));
}
} }
} }
} }

View File

@ -1,7 +1,5 @@
package dk.camelot64.kickc.icl; package dk.camelot64.kickc.icl;
import sun.jvm.hotspot.asm.Register;
/** The different registers available for a program */ /** The different registers available for a program */
public class Registers { public class Registers {

View File

@ -61,21 +61,21 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization {
private boolean optimizePointerDereferenceIndexed(StatementAssignment assignment) { private boolean optimizePointerDereferenceIndexed(StatementAssignment assignment) {
PointerDereferenceIndexed pointerDereferenceIndexed = (PointerDereferenceIndexed) assignment.getlValue(); PointerDereferenceIndexed pointerDereferenceIndexed = (PointerDereferenceIndexed) assignment.getlValue();
if(pointerDereferenceIndexed.getPointer() instanceof ConstantInteger && pointerDereferenceIndexed.getIndex() instanceof Constant) { if(pointerDereferenceIndexed.getPointer() instanceof Constant && pointerDereferenceIndexed.getIndex() instanceof Constant) {
ConstantInteger ptrConstant = (ConstantInteger) pointerDereferenceIndexed.getPointer(); Constant ptrConstant = (Constant) pointerDereferenceIndexed.getPointer();
ConstantInteger idxConstant = (ConstantInteger) pointerDereferenceIndexed.getIndex(); Constant idxConstant = (Constant) pointerDereferenceIndexed.getIndex();
int newPtr = ptrConstant.getNumber() + idxConstant.getNumber(); Constant newPtr = new ConstantBinary(ptrConstant, new Operator("+"), idxConstant);
assignment.setlValue(new PointerDereferenceSimple(new ConstantInteger(newPtr))); assignment.setlValue(new PointerDereferenceSimple(newPtr));
getLog().append("Consolidated assigned array index constant in assignment " + assignment.getlValue()); getLog().append("Consolidated assigned array index constant in assignment " + assignment.getlValue());
return true; return true;
} }
if(pointerDereferenceIndexed.getPointer() instanceof ConstantInteger && pointerDereferenceIndexed.getIndex() instanceof VariableRef) { if(pointerDereferenceIndexed.getPointer() instanceof Constant && pointerDereferenceIndexed.getIndex() instanceof VariableRef) {
VariableRef variable = (VariableRef) pointerDereferenceIndexed.getIndex(); VariableRef variable = (VariableRef) pointerDereferenceIndexed.getIndex();
ConstantInteger consolidated = consolidateSubConstants(variable); Constant consolidated = consolidateSubConstants(variable);
if (consolidated != null) { if (consolidated != null) {
ConstantInteger ptrConstant = (ConstantInteger) pointerDereferenceIndexed.getPointer(); Constant ptrConstant = (Constant) pointerDereferenceIndexed.getPointer();
int newPtr = ptrConstant.getNumber() + consolidated.getNumber(); Constant newPtr = new ConstantBinary(ptrConstant, new Operator("+"), consolidated);
pointerDereferenceIndexed.setPointer(new ConstantInteger(newPtr)); pointerDereferenceIndexed.setPointer(newPtr);
getLog().append("Consolidated assigned array index constant in assignment " + assignment.getlValue()); getLog().append("Consolidated assigned array index constant in assignment " + assignment.getlValue());
return true; return true;
} }
@ -84,23 +84,23 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization {
} }
private boolean optimizeArrayDeref(StatementAssignment assignment) { private boolean optimizeArrayDeref(StatementAssignment assignment) {
if (assignment.getrValue1() instanceof ConstantInteger && assignment.getrValue2() instanceof ConstantInteger) { if (assignment.getrValue1() instanceof Constant && assignment.getrValue2() instanceof Constant) {
ConstantInteger ptrConstant = (ConstantInteger) assignment.getrValue1(); Constant ptrConstant = (Constant) assignment.getrValue1();
ConstantInteger idxConstant = (ConstantInteger) assignment.getrValue2(); Constant idxConstant = (Constant) assignment.getrValue2();
int newPtr = ptrConstant.getNumber() + idxConstant.getNumber(); Constant newPtr = new ConstantBinary(ptrConstant, new Operator("+"), idxConstant);
assignment.setrValue1(null); assignment.setrValue1(null);
assignment.setOperator(new Operator("*")); assignment.setOperator(new Operator("*"));
assignment.setrValue2(new ConstantInteger(newPtr)); assignment.setrValue2(newPtr);
getLog().append("Consolidated referenced array index constant in assignment " + assignment.getlValue()); getLog().append("Consolidated referenced array index constant in assignment " + assignment.getlValue());
return true; return true;
} }
if (assignment.getrValue1() instanceof ConstantInteger && assignment.getrValue2() instanceof VariableRef) { if (assignment.getrValue1() instanceof Constant && assignment.getrValue2() instanceof VariableRef) {
VariableRef variable = (VariableRef) assignment.getrValue2(); VariableRef variable = (VariableRef) assignment.getrValue2();
ConstantInteger consolidated = consolidateSubConstants(variable); Constant consolidated = consolidateSubConstants(variable);
if (consolidated != null) { if (consolidated != null) {
ConstantInteger ptrConstant = (ConstantInteger) assignment.getrValue1(); Constant ptrConstant = (Constant) assignment.getrValue1();
int newPtr = ptrConstant.getNumber() + consolidated.getNumber(); Constant newPtr = new ConstantBinary(ptrConstant, new Operator("+"), consolidated);
assignment.setrValue1(new ConstantInteger(newPtr)); assignment.setrValue1(newPtr);
getLog().append("Consolidated referenced array index constant in assignment " + assignment.getlValue()); getLog().append("Consolidated referenced array index constant in assignment " + assignment.getlValue());
return true; return true;
} }
@ -109,27 +109,23 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization {
} }
private boolean optimizePlus(StatementAssignment assignment) { private boolean optimizePlus(StatementAssignment assignment) {
if (assignment.getrValue1() instanceof ConstantInteger && assignment.getrValue2() instanceof VariableRef) { if (assignment.getrValue1() instanceof Constant && assignment.getrValue2() instanceof VariableRef) {
VariableRef variable = (VariableRef) assignment.getrValue2(); VariableRef variable = (VariableRef) assignment.getrValue2();
ConstantInteger consolidated = consolidateSubConstants(variable); Constant consolidated = consolidateSubConstants(variable);
if (consolidated != null) { if (consolidated != null) {
ConstantInteger const1 = (ConstantInteger) assignment.getrValue1(); Constant const1 = (Constant) assignment.getrValue1();
assignment.setrValue1(new ConstantInteger(const1.getNumber() + consolidated.getNumber())); assignment.setrValue1(new ConstantBinary(const1, new Operator("+"), consolidated));
getLog().append("Consolidated constant in assignment " + assignment.getlValue()); getLog().append("Consolidated constant in assignment " + assignment.getlValue());
return true; return true;
} }
} else if (assignment.getrValue1() instanceof VariableRef && assignment.getrValue2() instanceof ConstantInteger) { } else if (assignment.getrValue1() instanceof VariableRef && assignment.getrValue2() instanceof Constant) {
VariableRef variable = (VariableRef) assignment.getrValue1(); VariableRef variable = (VariableRef) assignment.getrValue1();
ConstantInteger consolidated = consolidateSubConstants(variable); Constant consolidated = consolidateSubConstants(variable);
if (consolidated != null) { if (consolidated != null) {
ConstantInteger const2 = (ConstantInteger) assignment.getrValue2(); Constant const2 = (Constant) assignment.getrValue2();
int newNumber = const2.getNumber() + consolidated.getNumber(); Constant newNumber = new ConstantBinary(consolidated, new Operator("+"), const2);
if (newNumber < 0) { assignment.setrValue2(newNumber);
assignment.setrValue2(new ConstantInteger(-newNumber)); // Handling of negative consolidated numbers?
assignment.setOperator(new Operator("-"));
} else {
assignment.setrValue2(new ConstantInteger(newNumber));
}
getLog().append("Consolidated constant in assignment " + assignment.getlValue()); getLog().append("Consolidated constant in assignment " + assignment.getlValue());
return true; return true;
} }
@ -141,41 +137,40 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization {
* Gather up constants from sub addition expressions of a variable, remove them there, and return the aggregated sum. * Gather up constants from sub addition expressions of a variable, remove them there, and return the aggregated sum.
* *
* @param variable The variable to examine * @param variable The variable to examine
* @return The consolidated constant. Null if no sub-constants were found. * @return The consolidated constant. Null if no sub-constants were found, or if the constants cannot be consolidated.
*/ */
private ConstantInteger consolidateSubConstants(VariableRef variable) { private Constant consolidateSubConstants(VariableRef variable) {
if(getUsages(variable) >1) { if(getUsages(variable) >1) {
getLog().append("Multiple usages for variable. Not optimizing sub-constant "+variable.toString(getProgram())); getLog().append("Multiple usages for variable. Not optimizing sub-constant "+variable.toString(getProgram()));
return null; return null;
} }
Variable var = getSymbols().getVariable(variable);
StatementAssignment assignment = getGraph().getAssignment(variable); StatementAssignment assignment = getGraph().getAssignment(variable);
if (assignment != null && assignment.getOperator() != null && "+".equals(assignment.getOperator().getOperator())) { if (assignment != null && assignment.getOperator() != null && "+".equals(assignment.getOperator().getOperator())) {
if (assignment.getrValue1() instanceof ConstantInteger) { if (assignment.getrValue1() instanceof Constant) {
ConstantInteger constant = (ConstantInteger) assignment.getrValue1(); Constant constant = (Constant) assignment.getrValue1();
assignment.setrValue1(null); assignment.setrValue1(null);
assignment.setOperator(null); assignment.setOperator(null);
return constant; return constant;
} else if (assignment.getrValue2() instanceof ConstantInteger) { } else if (assignment.getrValue2() instanceof Constant) {
ConstantInteger constant = (ConstantInteger) assignment.getrValue2(); Constant constant = (Constant) assignment.getrValue2();
assignment.setrValue2(assignment.getrValue1()); assignment.setrValue2(assignment.getrValue1());
assignment.setOperator(null); assignment.setOperator(null);
assignment.setrValue1(null); assignment.setrValue1(null);
return constant; return constant;
} else { } else {
ConstantInteger const1 = null; Constant const1 = null;
if (assignment.getrValue1() instanceof VariableRef) { if (assignment.getrValue1() instanceof VariableRef) {
const1 = consolidateSubConstants((VariableRef) assignment.getrValue1()); const1 = consolidateSubConstants((VariableRef) assignment.getrValue1());
} }
ConstantInteger const2 = null; Constant const2 = null;
if (assignment.getrValue2() instanceof VariableRef) { if (assignment.getrValue2() instanceof VariableRef) {
const2 = consolidateSubConstants((VariableRef) assignment.getrValue2()); const2 = consolidateSubConstants((VariableRef) assignment.getrValue2());
} }
ConstantInteger result = null; Constant result = null;
if (const1 != null) { if (const1 != null) {
result = const1; result = const1;
if (const2 != null) { if (const2 != null) {
result = new ConstantInteger(const1.getNumber() + const2.getNumber()); result = new ConstantBinary(const1, new Operator("+"), const2);
} }
} else if (const2 != null) { } else if (const2 != null) {
result = const2; result = const2;
@ -184,30 +179,30 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization {
} }
} }
if (assignment != null && assignment.getOperator() != null && "-".equals(assignment.getOperator().getOperator())) { if (assignment != null && assignment.getOperator() != null && "-".equals(assignment.getOperator().getOperator())) {
if (assignment.getrValue1() instanceof ConstantInteger) { if (assignment.getrValue1() instanceof Constant) {
ConstantInteger constant = (ConstantInteger) assignment.getrValue1(); Constant constant = (Constant) assignment.getrValue1();
assignment.setrValue1(null); assignment.setrValue1(null);
return constant; return constant;
} else if (assignment.getrValue2() instanceof ConstantInteger) { } else if (assignment.getrValue2() instanceof Constant) {
ConstantInteger constant = (ConstantInteger) assignment.getrValue2(); Constant constant = (Constant) assignment.getrValue2();
assignment.setrValue2(assignment.getrValue1()); assignment.setrValue2(assignment.getrValue1());
assignment.setOperator(null); assignment.setOperator(null);
assignment.setrValue1(null); assignment.setrValue1(null);
return new ConstantInteger(-constant.getNumber()); return new ConstantUnary(new Operator("-"), constant);
} else { } else {
ConstantInteger const1 = null; Constant const1 = null;
if (assignment.getrValue1() instanceof VariableRef) { if (assignment.getrValue1() instanceof VariableRef) {
const1 = consolidateSubConstants((VariableRef) assignment.getrValue1()); const1 = consolidateSubConstants((VariableRef) assignment.getrValue1());
} }
ConstantInteger const2 = null; Constant const2 = null;
if (assignment.getrValue2() instanceof VariableRef) { if (assignment.getrValue2() instanceof VariableRef) {
const2 = consolidateSubConstants((VariableRef) assignment.getrValue2()); const2 = consolidateSubConstants((VariableRef) assignment.getrValue2());
} }
ConstantInteger result = null; Constant result = null;
if (const1 != null) { if (const1 != null) {
result = const1; result = const1;
if (const2 != null) { if (const2 != null) {
result = new ConstantInteger(const1.getNumber() - const2.getNumber()); result = new ConstantBinary(const1, new Operator("-"),const2);
} }
} else if (const2 != null) { } else if (const2 != null) {
result = const2; result = const2;

View File

@ -33,7 +33,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization {
constScope.remove(variable); constScope.remove(variable);
constScope.add(constantVar); constScope.add(constantVar);
constAliases.put(constRef, constantVar.getRef()); constAliases.put(constRef, constantVar.getRef());
getLog().append("Constant " + constantVar.toString(getProgram())); getLog().append("Constant " + constantVar.toString(getProgram()) + " = "+constantVar.getValue());
} }
// Remove assignments to constants in the code // Remove assignments to constants in the code
removeAssignments(constants.keySet()); removeAssignments(constants.keySet());

View File

@ -936,12 +936,12 @@ main::@return: scope:[main] from main::@2
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte) STAR#0 Constant (const byte) STAR#0 = 81
Constant (const byte[1000]) SCREEN#0 Constant (const byte[1000]) SCREEN#0 = 1024
Constant (const byte) main::x#0 Constant (const byte) main::x#0 = 0
Constant (const byte) main::y#0 Constant (const byte) main::y#0 = 0
Constant (const byte) main::x1#0 Constant (const byte) main::x1#0 = 39
Constant (const byte) main::y1#0 Constant (const byte) main::y1#0 = 24
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -987,98 +987,11 @@ main::@return: scope:[main] from main::@2
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Alias (byte) main::yd#0 = (byte) main::yd#1 Constant (const byte) main::xd#0 = main::x1#0-main::x#0
Alias (byte) main::xd#0 = (byte) main::xd#1 Constant (const byte) main::yd#0 = main::y1#0-main::y#0
Succesful SSA optimization Pass2AliasElimination Constant (const byte) main::$3 = main::y#0*40
CONTROL FLOW GRAPH Constant (const byte) STAR#1 = STAR#0
@begin: scope:[] from Constant (const byte) main::x1#2 = main::x1#0
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::xd#0 ← (const byte) main::x1#0 - (const byte) main::x#0
(byte) main::yd#0 ← (const byte) main::y1#0 - (const byte) main::y#0
(byte) main::e#0 ← (byte) main::yd#0 / (byte) 2
(byte~) main::$3 ← (const byte) main::y#0 * (byte) 40
(byte*~) main::$4 ← (const byte[1000]) SCREEN#0 + (byte~) main::$3
(byte*) main::cursor#0 ← (byte*~) main::$4 + (const byte) main::x#0
to:main::@1
main::@1: scope:[main] from main main::@2
(byte) main::y#2 ← phi( main/(const byte) main::y#0 main::@2/(byte) main::y#4 )
(byte) main::x1#2 ← phi( main/(const byte) main::x1#0 )
(byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 )
(byte) main::x#2 ← phi( main/(const byte) main::x#0 main::@2/(byte) main::x#1 )
(byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 )
(byte) STAR#1 ← phi( main/(const byte) STAR#0 )
*((byte*) main::cursor#3) ← (byte) STAR#1
(byte) main::x#1 ← (byte) main::x#2 + (byte) 1
(byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1
(byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#0
if((byte) main::xd#0>=(byte) main::e#1) goto main::@2
to:main::@3
main::@2: scope:[main] from main::@1 main::@3
(byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 )
(byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 )
(byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 )
(byte~) main::$14 ← (byte) main::x1#2 + (byte) 1
if((byte) main::x#1<(byte~) main::$14) goto main::@1
to:main::@return
main::@3: scope:[main] from main::@1
(byte) main::y#1 ← (byte) main::y#2 + (byte) 1
(byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40
(byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#0
to:main::@2
main::@return: scope:[main] from main::@2
return
to:@return
@end: scope:[] from @begin
Redundant Phi (byte) STAR#1 (const byte) STAR#0
Redundant Phi (byte) main::x1#2 (const byte) main::x1#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
(byte) main::xd#0 ← (const byte) main::x1#0 - (const byte) main::x#0
(byte) main::yd#0 ← (const byte) main::y1#0 - (const byte) main::y#0
(byte) main::e#0 ← (byte) main::yd#0 / (byte) 2
(byte~) main::$3 ← (const byte) main::y#0 * (byte) 40
(byte*~) main::$4 ← (const byte[1000]) SCREEN#0 + (byte~) main::$3
(byte*) main::cursor#0 ← (byte*~) main::$4 + (const byte) main::x#0
to:main::@1
main::@1: scope:[main] from main main::@2
(byte) main::y#2 ← phi( main/(const byte) main::y#0 main::@2/(byte) main::y#4 )
(byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 )
(byte) main::x#2 ← phi( main/(const byte) main::x#0 main::@2/(byte) main::x#1 )
(byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 )
*((byte*) main::cursor#3) ← (const byte) STAR#0
(byte) main::x#1 ← (byte) main::x#2 + (byte) 1
(byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1
(byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#0
if((byte) main::xd#0>=(byte) main::e#1) goto main::@2
to:main::@3
main::@2: scope:[main] from main::@1 main::@3
(byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 )
(byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 )
(byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 )
(byte~) main::$14 ← (const byte) main::x1#0 + (byte) 1
if((byte) main::x#1<(byte~) main::$14) goto main::@1
to:main::@return
main::@3: scope:[main] from main::@1
(byte) main::y#1 ← (byte) main::y#2 + (byte) 1
(byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40
(byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#0
to:main::@2
main::@return: scope:[main] from main::@2
return
to:@return
@end: scope:[] from @begin
Constant (const byte) main::xd#0
Constant (const byte) main::yd#0
Constant (const byte) main::$3
Constant (const byte) main::$14
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -1091,33 +1004,39 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@2 main::@1: scope:[main] from main main::@2
(byte) main::y#2 ← phi( main/(const byte) main::y#0 main::@2/(byte) main::y#4 ) (byte) main::y#2 ← phi( main/(const byte) main::y#0 main::@2/(byte) main::y#4 )
(byte) main::xd#1 ← phi( main/(const byte) main::xd#0 )
(byte) main::yd#1 ← phi( main/(const byte) main::yd#0 )
(byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 )
(byte) main::x#2 ← phi( main/(const byte) main::x#0 main::@2/(byte) main::x#1 ) (byte) main::x#2 ← phi( main/(const byte) main::x#0 main::@2/(byte) main::x#1 )
(byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 )
*((byte*) main::cursor#3) ← (const byte) STAR#0 *((byte*) main::cursor#3) ← (const byte) STAR#1
(byte) main::x#1 ← (byte) main::x#2 + (byte) 1 (byte) main::x#1 ← (byte) main::x#2 + (byte) 1
(byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1
(byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 (byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#1
if((const byte) main::xd#0>=(byte) main::e#1) goto main::@2 if((byte) main::xd#1>=(byte) main::e#1) goto main::@2
to:main::@3 to:main::@3
main::@2: scope:[main] from main::@1 main::@3 main::@2: scope:[main] from main::@1 main::@3
(byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 )
(byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 )
(byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 )
if((byte) main::x#1<(const byte) main::$14) goto main::@1 (byte~) main::$14 ← (const byte) main::x1#2 + (byte) 1
if((byte) main::x#1<(byte~) main::$14) goto main::@1
to:main::@return to:main::@return
main::@3: scope:[main] from main::@1 main::@3: scope:[main] from main::@1
(byte) main::y#1 ← (byte) main::y#2 + (byte) 1 (byte) main::y#1 ← (byte) main::y#2 + (byte) 1
(byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40
(byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 (byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#1
to:main::@2 to:main::@2
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte) main::e#0 Constant (const byte) main::e#0 = main::yd#0/2
Constant (const byte*) main::$4 Constant (const byte*) main::$4 = SCREEN#0+main::$3
Constant (const byte) main::yd#1 = main::yd#0
Constant (const byte) main::xd#1 = main::xd#0
Constant (const byte) main::$14 = main::x1#2+1
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -1131,11 +1050,11 @@ main::@1: scope:[main] from main main::@2
(byte) main::e#3 ← phi( main/(const byte) main::e#0 main::@2/(byte) main::e#5 ) (byte) main::e#3 ← phi( main/(const byte) main::e#0 main::@2/(byte) main::e#5 )
(byte) main::x#2 ← phi( main/(const byte) main::x#0 main::@2/(byte) main::x#1 ) (byte) main::x#2 ← phi( main/(const byte) main::x#0 main::@2/(byte) main::x#1 )
(byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 )
*((byte*) main::cursor#3) ← (const byte) STAR#0 *((byte*) main::cursor#3) ← (const byte) STAR#1
(byte) main::x#1 ← (byte) main::x#2 + (byte) 1 (byte) main::x#1 ← (byte) main::x#2 + (byte) 1
(byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1
(byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#1
if((const byte) main::xd#0>=(byte) main::e#1) goto main::@2 if((const byte) main::xd#1>=(byte) main::e#1) goto main::@2
to:main::@3 to:main::@3
main::@2: scope:[main] from main::@1 main::@3 main::@2: scope:[main] from main::@1 main::@3
(byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 )
@ -1146,14 +1065,14 @@ main::@2: scope:[main] from main::@1 main::@3
main::@3: scope:[main] from main::@1 main::@3: scope:[main] from main::@1
(byte) main::y#1 ← (byte) main::y#2 + (byte) 1 (byte) main::y#1 ← (byte) main::y#2 + (byte) 1
(byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40
(byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#1
to:main::@2 to:main::@2
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte*) main::cursor#0 Constant (const byte*) main::cursor#0 = main::$4+main::x#0
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -1166,11 +1085,11 @@ main::@1: scope:[main] from main main::@2
(byte) main::e#3 ← phi( main/(const byte) main::e#0 main::@2/(byte) main::e#5 ) (byte) main::e#3 ← phi( main/(const byte) main::e#0 main::@2/(byte) main::e#5 )
(byte) main::x#2 ← phi( main/(const byte) main::x#0 main::@2/(byte) main::x#1 ) (byte) main::x#2 ← phi( main/(const byte) main::x#0 main::@2/(byte) main::x#1 )
(byte*) main::cursor#3 ← phi( main/(const byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) (byte*) main::cursor#3 ← phi( main/(const byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 )
*((byte*) main::cursor#3) ← (const byte) STAR#0 *((byte*) main::cursor#3) ← (const byte) STAR#1
(byte) main::x#1 ← (byte) main::x#2 + (byte) 1 (byte) main::x#1 ← (byte) main::x#2 + (byte) 1
(byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1
(byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#1
if((const byte) main::xd#0>=(byte) main::e#1) goto main::@2 if((const byte) main::xd#1>=(byte) main::e#1) goto main::@2
to:main::@3 to:main::@3
main::@2: scope:[main] from main::@1 main::@3 main::@2: scope:[main] from main::@1 main::@3
(byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 )
@ -1181,20 +1100,28 @@ main::@2: scope:[main] from main::@1 main::@3
main::@3: scope:[main] from main::@1 main::@3: scope:[main] from main::@1
(byte) main::y#1 ← (byte) main::y#2 + (byte) 1 (byte) main::y#1 ← (byte) main::y#2 + (byte) 1
(byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40
(byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#1
to:main::@2 to:main::@2
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Multiple usages for variable. Not optimizing sub-constant (byte) main::y#2
Multiple usages for variable. Not optimizing sub-constant (byte*) main::cursor#1
Multiple usages for variable. Not optimizing sub-constant (byte) main::y#2
Multiple usages for variable. Not optimizing sub-constant (byte*) main::cursor#1
Constant inlined main::$3 = (byte) 0*(byte) 40 Constant inlined main::$3 = (byte) 0*(byte) 40
Constant inlined main::$4 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40 Constant inlined main::$4 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40
Constant inlined main::xd#1 = (const byte) main::xd#0
Constant inlined main::x#0 = (byte) 0 Constant inlined main::x#0 = (byte) 0
Constant inlined STAR#1 = (const byte) STAR#0
Constant inlined main::x1#2 = (const byte) main::x1#0
Constant inlined main::cursor#0 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40+(byte) 0 Constant inlined main::cursor#0 = (const byte[1000]) SCREEN#0+(byte) 0*(byte) 40+(byte) 0
Constant inlined main::$14 = (const byte) main::x1#0+(byte) 1 Constant inlined main::$14 = (const byte) main::x1#0+(byte) 1
Constant inlined main::y#0 = (byte) 0 Constant inlined main::y#0 = (byte) 0
Constant inlined main::e#0 = (const byte) main::yd#0/(byte) 2 Constant inlined main::e#0 = (const byte) main::yd#0/(byte) 2
Constant inlined main::yd#1 = (const byte) main::yd#0
Succesful SSA optimization Pass2ConstantInlining Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from

View File

@ -767,12 +767,12 @@ CONTROL FLOW GRAPH
to:@2 to:@2
@end: scope:[] from @2 @end: scope:[] from @2
Constant (const byte) STAR#0 Constant (const byte) STAR#0 = 81
Constant (const byte[1000]) screen#0 Constant (const byte[1000]) screen#0 = 1024
Constant (const byte) x#0 Constant (const byte) x#0 = 0
Constant (const byte) y#0 Constant (const byte) y#0 = 0
Constant (const byte) x1#0 Constant (const byte) x1#0 = 39
Constant (const byte) y1#0 Constant (const byte) y1#0 = 24
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -812,86 +812,12 @@ CONTROL FLOW GRAPH
to:@2 to:@2
@end: scope:[] from @2 @end: scope:[] from @2
Alias (byte) yd#0 = (byte) yd#1 Constant (const byte) xd#0 = x1#0-x#0
Alias (byte) xd#0 = (byte) xd#1 Constant (const byte) yd#0 = y1#0-y#0
Succesful SSA optimization Pass2AliasElimination Constant (const byte) $3 = y#0*40
CONTROL FLOW GRAPH Constant (const byte) STAR#1 = STAR#0
@begin: scope:[] from Constant (const byte[1000]) screen#1 = screen#0
(byte) xd#0 ← (const byte) x1#0 - (const byte) x#0 Constant (const byte) x1#2 = x1#0
(byte) yd#0 ← (const byte) y1#0 - (const byte) y#0
(byte) e#0 ← (byte) yd#0 / (byte) 2
(byte~) $3 ← (const byte) y#0 * (byte) 40
(word) idx#0 ← (const byte) x#0 + (byte~) $3
to:@1
@1: scope:[] from @2 @begin
(byte) y#2 ← phi( @2/(byte) y#4 @begin/(const byte) y#0 )
(byte) x1#2 ← phi( @begin/(const byte) x1#0 )
(byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 )
(byte) x#2 ← phi( @2/(byte) x#1 @begin/(const byte) x#0 )
(word) idx#3 ← phi( @2/(word) idx#5 @begin/(word) idx#0 )
(byte[1000]) screen#1 ← phi( @begin/(const byte[1000]) screen#0 )
(byte) STAR#1 ← phi( @begin/(const byte) STAR#0 )
*((byte[1000]) screen#1 + (word) idx#3) ← (byte) STAR#1
(byte) x#1 ← (byte) x#2 + (byte) 1
(word) idx#1 ← (word) idx#3 + (byte) 1
(byte) e#1 ← (byte) e#3 + (byte) yd#0
if((byte) xd#0>=(byte) e#1) goto @2
to:@3
@2: scope:[] from @1 @3
(byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 )
(byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 )
(word) idx#5 ← phi( @1/(word) idx#1 @3/(word) idx#2 )
(byte~) $13 ← (byte) x1#2 + (byte) 1
if((byte) x#1<(byte~) $13) goto @1
to:@end
@3: scope:[] from @1
(byte) y#1 ← (byte) y#2 + (byte) 1
(word) idx#2 ← (word) idx#1 + (byte) 40
(byte) e#2 ← (byte) e#1 - (byte) xd#0
to:@2
@end: scope:[] from @2
Redundant Phi (byte) STAR#1 (const byte) STAR#0
Redundant Phi (byte[1000]) screen#1 (const byte[1000]) screen#0
Redundant Phi (byte) x1#2 (const byte) x1#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) xd#0 ← (const byte) x1#0 - (const byte) x#0
(byte) yd#0 ← (const byte) y1#0 - (const byte) y#0
(byte) e#0 ← (byte) yd#0 / (byte) 2
(byte~) $3 ← (const byte) y#0 * (byte) 40
(word) idx#0 ← (const byte) x#0 + (byte~) $3
to:@1
@1: scope:[] from @2 @begin
(byte) y#2 ← phi( @2/(byte) y#4 @begin/(const byte) y#0 )
(byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 )
(byte) x#2 ← phi( @2/(byte) x#1 @begin/(const byte) x#0 )
(word) idx#3 ← phi( @2/(word) idx#5 @begin/(word) idx#0 )
*((const byte[1000]) screen#0 + (word) idx#3) ← (const byte) STAR#0
(byte) x#1 ← (byte) x#2 + (byte) 1
(word) idx#1 ← (word) idx#3 + (byte) 1
(byte) e#1 ← (byte) e#3 + (byte) yd#0
if((byte) xd#0>=(byte) e#1) goto @2
to:@3
@2: scope:[] from @1 @3
(byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 )
(byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 )
(word) idx#5 ← phi( @1/(word) idx#1 @3/(word) idx#2 )
(byte~) $13 ← (const byte) x1#0 + (byte) 1
if((byte) x#1<(byte~) $13) goto @1
to:@end
@3: scope:[] from @1
(byte) y#1 ← (byte) y#2 + (byte) 1
(word) idx#2 ← (word) idx#1 + (byte) 40
(byte) e#2 ← (byte) e#1 - (byte) xd#0
to:@2
@end: scope:[] from @2
Constant (const byte) xd#0
Constant (const byte) yd#0
Constant (const byte) $3
Constant (const byte) $13
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -900,30 +826,36 @@ CONTROL FLOW GRAPH
to:@1 to:@1
@1: scope:[] from @2 @begin @1: scope:[] from @2 @begin
(byte) y#2 ← phi( @2/(byte) y#4 @begin/(const byte) y#0 ) (byte) y#2 ← phi( @2/(byte) y#4 @begin/(const byte) y#0 )
(byte) xd#1 ← phi( @begin/(const byte) xd#0 )
(byte) yd#1 ← phi( @begin/(const byte) yd#0 )
(byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 )
(byte) x#2 ← phi( @2/(byte) x#1 @begin/(const byte) x#0 ) (byte) x#2 ← phi( @2/(byte) x#1 @begin/(const byte) x#0 )
(word) idx#3 ← phi( @2/(word) idx#5 @begin/(word) idx#0 ) (word) idx#3 ← phi( @2/(word) idx#5 @begin/(word) idx#0 )
*((const byte[1000]) screen#0 + (word) idx#3) ← (const byte) STAR#0 *((const byte[1000]) screen#1 + (word) idx#3) ← (const byte) STAR#1
(byte) x#1 ← (byte) x#2 + (byte) 1 (byte) x#1 ← (byte) x#2 + (byte) 1
(word) idx#1 ← (word) idx#3 + (byte) 1 (word) idx#1 ← (word) idx#3 + (byte) 1
(byte) e#1 ← (byte) e#3 + (const byte) yd#0 (byte) e#1 ← (byte) e#3 + (byte) yd#1
if((const byte) xd#0>=(byte) e#1) goto @2 if((byte) xd#1>=(byte) e#1) goto @2
to:@3 to:@3
@2: scope:[] from @1 @3 @2: scope:[] from @1 @3
(byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 )
(byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 )
(word) idx#5 ← phi( @1/(word) idx#1 @3/(word) idx#2 ) (word) idx#5 ← phi( @1/(word) idx#1 @3/(word) idx#2 )
if((byte) x#1<(const byte) $13) goto @1 (byte~) $13 ← (const byte) x1#2 + (byte) 1
if((byte) x#1<(byte~) $13) goto @1
to:@end to:@end
@3: scope:[] from @1 @3: scope:[] from @1
(byte) y#1 ← (byte) y#2 + (byte) 1 (byte) y#1 ← (byte) y#2 + (byte) 1
(word) idx#2 ← (word) idx#1 + (byte) 40 (word) idx#2 ← (word) idx#1 + (byte) 40
(byte) e#2 ← (byte) e#1 - (const byte) xd#0 (byte) e#2 ← (byte) e#1 - (byte) xd#1
to:@2 to:@2
@end: scope:[] from @2 @end: scope:[] from @2
Constant (const byte) e#0 Constant (const byte) e#0 = yd#0/2
Constant (const word) idx#0 Constant (const word) idx#0 = x#0+$3
Constant (const byte) yd#1 = yd#0
Constant (const byte) xd#1 = xd#0
Constant (const byte) $13 = x1#2+1
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -933,11 +865,11 @@ CONTROL FLOW GRAPH
(byte) e#3 ← phi( @2/(byte) e#5 @begin/(const byte) e#0 ) (byte) e#3 ← phi( @2/(byte) e#5 @begin/(const byte) e#0 )
(byte) x#2 ← phi( @2/(byte) x#1 @begin/(const byte) x#0 ) (byte) x#2 ← phi( @2/(byte) x#1 @begin/(const byte) x#0 )
(word) idx#3 ← phi( @2/(word) idx#5 @begin/(const word) idx#0 ) (word) idx#3 ← phi( @2/(word) idx#5 @begin/(const word) idx#0 )
*((const byte[1000]) screen#0 + (word) idx#3) ← (const byte) STAR#0 *((const byte[1000]) screen#1 + (word) idx#3) ← (const byte) STAR#1
(byte) x#1 ← (byte) x#2 + (byte) 1 (byte) x#1 ← (byte) x#2 + (byte) 1
(word) idx#1 ← (word) idx#3 + (byte) 1 (word) idx#1 ← (word) idx#3 + (byte) 1
(byte) e#1 ← (byte) e#3 + (const byte) yd#0 (byte) e#1 ← (byte) e#3 + (const byte) yd#1
if((const byte) xd#0>=(byte) e#1) goto @2 if((const byte) xd#1>=(byte) e#1) goto @2
to:@3 to:@3
@2: scope:[] from @1 @3 @2: scope:[] from @1 @3
(byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 )
@ -948,14 +880,23 @@ CONTROL FLOW GRAPH
@3: scope:[] from @1 @3: scope:[] from @1
(byte) y#1 ← (byte) y#2 + (byte) 1 (byte) y#1 ← (byte) y#2 + (byte) 1
(word) idx#2 ← (word) idx#1 + (byte) 40 (word) idx#2 ← (word) idx#1 + (byte) 40
(byte) e#2 ← (byte) e#1 - (const byte) xd#0 (byte) e#2 ← (byte) e#1 - (const byte) xd#1
to:@2 to:@2
@end: scope:[] from @2 @end: scope:[] from @2
Multiple usages for variable. Not optimizing sub-constant (byte) y#2
Multiple usages for variable. Not optimizing sub-constant (word) idx#1
Multiple usages for variable. Not optimizing sub-constant (byte) y#2
Multiple usages for variable. Not optimizing sub-constant (word) idx#1
Constant inlined yd#1 = (const byte) yd#0
Constant inlined $13 = (const byte) x1#0+(byte) 1 Constant inlined $13 = (const byte) x1#0+(byte) 1
Constant inlined x1#2 = (const byte) x1#0
Constant inlined e#0 = (const byte) yd#0/(byte) 2 Constant inlined e#0 = (const byte) yd#0/(byte) 2
Constant inlined xd#1 = (const byte) xd#0
Constant inlined y#0 = (byte) 0 Constant inlined y#0 = (byte) 0
Constant inlined idx#0 = (byte) 0+(byte) 0*(byte) 40 Constant inlined idx#0 = (byte) 0+(byte) 0*(byte) 40
Constant inlined screen#1 = (const byte[1000]) screen#0
Constant inlined STAR#1 = (const byte) STAR#0
Constant inlined x#0 = (byte) 0 Constant inlined x#0 = (byte) 0
Constant inlined $3 = (byte) 0*(byte) 40 Constant inlined $3 = (byte) 0*(byte) 40
Succesful SSA optimization Pass2ConstantInlining Succesful SSA optimization Pass2ConstantInlining

View File

@ -402,12 +402,12 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte*) SCREEN#0 Constant (const byte*) SCREEN#0 = 1024
Constant (const byte) STAR#0 Constant (const byte) STAR#0 = 81
Constant (const byte*) VIC#0 Constant (const byte*) VIC#0 = 53248
Constant (const byte) $0 Constant (const byte) $0 = 16*2
Constant (const byte) RED#0 Constant (const byte) RED#0 = 2
Constant (const byte) main::i#0 Constant (const byte) main::i#0 = 40
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -433,33 +433,9 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Redundant Phi (byte) STAR#2 (const byte) STAR#0 Constant (const byte*) $1 = VIC#0+$0
Redundant Phi (byte*) SCREEN#2 (const byte*) SCREEN#0 Constant (const byte) STAR#2 = STAR#0
Succesful SSA optimization Pass2RedundantPhiElimination Constant (const byte*) SCREEN#2 = SCREEN#0
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*~) $1 ← (const byte*) VIC#0 + (const byte) $0
(byte*) BGCOL#0 ← (byte*~) $1 + (byte) 1
call main param-assignment
to:@end
main: scope:[main] from @begin
*((const byte*) SCREEN#0) ← (const byte) STAR#0
*((byte*) BGCOL#0) ← (const byte) RED#0
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
(byte~) main::$0 ← (const byte) STAR#0 + (byte) 1
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 80) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@end: scope:[] from @begin
Constant (const byte*) $1
Constant (const byte) main::$0
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -472,7 +448,8 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) main::$0 (byte~) main::$0 ← (const byte) STAR#2 + (byte) 1
*((const byte*) SCREEN#2 + (byte) main::i#2) ← (byte~) main::$0
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 80) goto main::@1 if((byte) main::i#1!=(byte) 80) goto main::@1
to:main::@return to:main::@return
@ -481,7 +458,8 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte*) BGCOL#0 Constant (const byte*) BGCOL#0 = $1+1
Constant (const byte) main::$0 = STAR#2+1
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -493,7 +471,7 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) main::$0 *((const byte*) SCREEN#2 + (byte) main::i#2) ← (const byte) main::$0
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 80) goto main::@1 if((byte) main::i#1!=(byte) 80) goto main::@1
to:main::@return to:main::@return
@ -502,6 +480,8 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant inlined SCREEN#2 = (const byte*) SCREEN#0
Constant inlined STAR#2 = (const byte) STAR#0
Constant inlined $1 = (const byte*) VIC#0+(byte) 16*(byte) 2 Constant inlined $1 = (const byte*) VIC#0+(byte) 16*(byte) 2
Constant inlined $0 = (byte) 16*(byte) 2 Constant inlined $0 = (byte) 16*(byte) 2
Constant inlined main::i#0 = (byte) 40 Constant inlined main::i#0 = (byte) 40

View File

@ -1,15 +1,16 @@
.const fibs = $1100
jsr main jsr main
main: { main: {
lda #$0 lda #$0
sta $1100 sta fibs+$0
lda #$1 lda #$1
sta $1101 sta fibs+$1
ldx #$0 ldx #$0
b1: b1:
lda $1100,x lda fibs,x
clc clc
adc $1101,x adc fibs+$1,x
sta $1102,x sta fibs+$2,x
inx inx
cpx #$f cpx #$f
bcc b1 bcc b1

View File

@ -3,15 +3,15 @@
to:@end to:@end
@end: scope:[] from @begin @end: scope:[] from @begin
main: scope:[main] from @begin main: scope:[main] from @begin
[1] *((word) 4352) ← (byte) 0 [ ] [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ]
[2] *((word) 4353) ← (byte) 1 [ ] [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ]
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
[3] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ] [3] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ]
[4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] [4] (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2 [ main::i#2 main::$1 ]
[5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] [5] (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
[6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ]
[7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] [7] *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ]
[8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ]
to:main::@return to:main::@return

View File

@ -250,51 +250,21 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (byte[15]) fibs#0 (word) 4352 Alias (byte[15]) fibs#0 = (byte[15]) fibs#1
Constant (byte) main::i#0 (byte) 0 Succesful SSA optimization Pass2AliasElimination
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
(byte[15]) fibs#0 ← (word) 4352
call main param-assignment call main param-assignment
to:@end to:@end
main: scope:[main] from @begin main: scope:[main] from @begin
(byte[15]) fibs#1 ← phi( @begin/(word) 4352 ) *((byte[15]) fibs#0 + (byte) 0) ← (byte) 0
*((byte[15]) fibs#1 + (byte) 0) ← (byte) 0 *((byte[15]) fibs#0 + (byte) 1) ← (byte) 1
*((byte[15]) fibs#1 + (byte) 1) ← (byte) 1 (byte) main::i#0 ← (byte) 0
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte[15]) fibs#2 ← phi( main/(byte[15]) fibs#1 main::@1/(byte[15]) fibs#2 ) (byte[15]) fibs#2 ← phi( main/(byte[15]) fibs#0 main::@1/(byte[15]) fibs#2 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 2
(byte~) main::$1 ← (byte[15]) fibs#2 *idx (byte) main::i#2
(byte~) main::$2 ← (byte) main::i#2 + (byte) 1
(byte~) main::$3 ← (byte[15]) fibs#2 *idx (byte~) main::$2
(byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3
*((byte[15]) fibs#2 + (byte~) main::$0) ← (byte~) main::$4
(byte) main::i#1 ← ++ (byte) main::i#2
(boolean~) main::$5 ← (byte) main::i#1 < (byte) 15
if((boolean~) main::$5) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@end: scope:[] from @begin
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Redundant Phi (byte[15]) fibs#1 (word) 4352
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
*((word) 4352 + (byte) 0) ← (byte) 0
*((word) 4352 + (byte) 1) ← (byte) 1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte[15]) fibs#2 ← phi( main/(word) 4352 main::@1/(byte[15]) fibs#2 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 2 (byte~) main::$0 ← (byte) main::i#2 + (byte) 2
(byte~) main::$1 ← (byte[15]) fibs#2 *idx (byte) main::i#2 (byte~) main::$1 ← (byte[15]) fibs#2 *idx (byte) main::i#2
(byte~) main::$2 ← (byte) main::i#2 + (byte) 1 (byte~) main::$2 ← (byte) main::i#2 + (byte) 1
@ -314,15 +284,17 @@ Self Phi Eliminated (byte[15]) fibs#2
Succesful SSA optimization Pass2SelfPhiElimination Succesful SSA optimization Pass2SelfPhiElimination
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
(byte[15]) fibs#0 ← (word) 4352
call main param-assignment call main param-assignment
to:@end to:@end
main: scope:[main] from @begin main: scope:[main] from @begin
*((word) 4352 + (byte) 0) ← (byte) 0 *((byte[15]) fibs#0 + (byte) 0) ← (byte) 0
*((word) 4352 + (byte) 1) ← (byte) 1 *((byte[15]) fibs#0 + (byte) 1) ← (byte) 1
(byte) main::i#0 ← (byte) 0
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte[15]) fibs#2 ← phi( main/(word) 4352 ) (byte[15]) fibs#2 ← phi( main/(byte[15]) fibs#0 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 2 (byte~) main::$0 ← (byte) main::i#2 + (byte) 2
(byte~) main::$1 ← (byte[15]) fibs#2 *idx (byte) main::i#2 (byte~) main::$1 ← (byte[15]) fibs#2 *idx (byte) main::i#2
(byte~) main::$2 ← (byte) main::i#2 + (byte) 1 (byte~) main::$2 ← (byte) main::i#2 + (byte) 1
@ -342,15 +314,17 @@ Simple Condition (boolean~) main::$5 if((byte) main::i#1<(byte) 15) goto main::@
Succesful SSA optimization Pass2ConditionalJumpSimplification Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
(byte[15]) fibs#0 ← (word) 4352
call main param-assignment call main param-assignment
to:@end to:@end
main: scope:[main] from @begin main: scope:[main] from @begin
*((word) 4352 + (byte) 0) ← (byte) 0 *((byte[15]) fibs#0 + (byte) 0) ← (byte) 0
*((word) 4352 + (byte) 1) ← (byte) 1 *((byte[15]) fibs#0 + (byte) 1) ← (byte) 1
(byte) main::i#0 ← (byte) 0
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte[15]) fibs#2 ← phi( main/(word) 4352 ) (byte[15]) fibs#2 ← phi( main/(byte[15]) fibs#0 )
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 2 (byte~) main::$0 ← (byte) main::i#2 + (byte) 2
(byte~) main::$1 ← (byte[15]) fibs#2 *idx (byte) main::i#2 (byte~) main::$1 ← (byte[15]) fibs#2 *idx (byte) main::i#2
(byte~) main::$2 ← (byte) main::i#2 + (byte) 1 (byte~) main::$2 ← (byte) main::i#2 + (byte) 1
@ -365,24 +339,26 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (byte[15]) fibs#2 (word) 4352 Constant (const byte[15]) fibs#0 = 4352
Succesful SSA optimization Pass2ConstantPropagation Constant (const byte) main::i#0 = 0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
to:@end to:@end
main: scope:[main] from @begin main: scope:[main] from @begin
*((word) 4352 + (byte) 0) ← (byte) 0 *((const byte[15]) fibs#0 + (byte) 0) ← (byte) 0
*((word) 4352 + (byte) 1) ← (byte) 1 *((const byte[15]) fibs#0 + (byte) 1) ← (byte) 1
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) (byte[15]) fibs#2 ← phi( main/(const byte[15]) fibs#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 2 (byte~) main::$0 ← (byte) main::i#2 + (byte) 2
(byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 (byte~) main::$1 ← (byte[15]) fibs#2 *idx (byte) main::i#2
(byte~) main::$2 ← (byte) main::i#2 + (byte) 1 (byte~) main::$2 ← (byte) main::i#2 + (byte) 1
(byte~) main::$3 ← (word) 4352 *idx (byte~) main::$2 (byte~) main::$3 ← (byte[15]) fibs#2 *idx (byte~) main::$2
(byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3
*((word) 4352 + (byte~) main::$0) ← (byte~) main::$4 *((byte[15]) fibs#2 + (byte~) main::$0) ← (byte~) main::$4
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1<(byte) 15) goto main::@1 if((byte) main::i#1<(byte) 15) goto main::@1
to:main::@return to:main::@return
@ -391,30 +367,56 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Consolidated assigned array index constant in assignment *(4352) Constant (const byte[15]) fibs#2 = fibs#0
Consolidated assigned array index constant in assignment *(4353) Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
*((const byte[15]) fibs#0 + (byte) 0) ← (byte) 0
*((const byte[15]) fibs#0 + (byte) 1) ← (byte) 1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 + (byte) 2
(byte~) main::$1 ← (const byte[15]) fibs#2 *idx (byte) main::i#2
(byte~) main::$2 ← (byte) main::i#2 + (byte) 1
(byte~) main::$3 ← (const byte[15]) fibs#2 *idx (byte~) main::$2
(byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3
*((const byte[15]) fibs#2 + (byte~) main::$0) ← (byte~) main::$4
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1<(byte) 15) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@end: scope:[] from @begin
Consolidated assigned array index constant in assignment *(fibs#0+0)
Consolidated assigned array index constant in assignment *(fibs#0+1)
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2 Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2 Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2 Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Consolidated referenced array index constant in assignment main::$3 Consolidated referenced array index constant in assignment main::$3
Consolidated assigned array index constant in assignment *(4354 + main::$0) Consolidated assigned array index constant in assignment *(fibs#2+2 + main::$0)
Succesful SSA optimization Pass2ConstantAdditionElimination Succesful SSA optimization Pass2ConstantAdditionElimination
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
to:@end to:@end
main: scope:[main] from @begin main: scope:[main] from @begin
*((word) 4352) ← (byte) 0 *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0
*((word) 4353) ← (byte) 1 *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
(byte~) main::$0 ← (byte) main::i#2 (byte~) main::$0 ← (byte) main::i#2
(byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 (byte~) main::$1 ← (const byte[15]) fibs#2 *idx (byte) main::i#2
(byte~) main::$2 ← (byte) main::i#2 (byte~) main::$2 ← (byte) main::i#2
(byte~) main::$3 ← (word) 4353 *idx (byte~) main::$2 (byte~) main::$3 ← (const byte[15]) fibs#2+(byte) 1 *idx (byte~) main::$2
(byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3
*((word) 4354 + (byte~) main::$0) ← (byte~) main::$4 *((const byte[15]) fibs#2+(byte) 2 + (byte~) main::$0) ← (byte~) main::$4
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1<(byte) 15) goto main::@1 if((byte) main::i#1<(byte) 15) goto main::@1
to:main::@return to:main::@return
@ -423,6 +425,7 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Alias (byte) main::i#2 = (byte~) main::$0 (byte~) main::$2 Alias (byte) main::i#2 = (byte~) main::$0 (byte~) main::$2
Succesful SSA optimization Pass2AliasElimination Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@ -430,15 +433,15 @@ CONTROL FLOW GRAPH
call main param-assignment call main param-assignment
to:@end to:@end
main: scope:[main] from @begin main: scope:[main] from @begin
*((word) 4352) ← (byte) 0 *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0
*((word) 4353) ← (byte) 1 *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
(byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 (byte~) main::$1 ← (const byte[15]) fibs#2 *idx (byte) main::i#2
(byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 (byte~) main::$3 ← (const byte[15]) fibs#2+(byte) 1 *idx (byte) main::i#2
(byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3
*((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 *((const byte[15]) fibs#2+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1<(byte) 15) goto main::@1 if((byte) main::i#1<(byte) 15) goto main::@1
to:main::@return to:main::@return
@ -450,10 +453,39 @@ main::@return: scope:[main] from main::@1
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2 Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2 Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2 Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Constant inlined fibs#2 = (const byte[15]) fibs#0
Constant inlined main::i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@end
main: scope:[main] from @begin
*((const byte[15]) fibs#0+(byte) 0) ← (byte) 0
*((const byte[15]) fibs#0+(byte) 1) ← (byte) 1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
(byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2
(byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2
(byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3
*((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1<(byte) 15) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@end: scope:[] from @begin
FINAL SYMBOL TABLE FINAL SYMBOL TABLE
(label) @begin (label) @begin
(label) @end (label) @end
(byte[15]) fibs (byte[15]) fibs
(const byte[15]) fibs#0 = (word) 4352
(void()) main() (void()) main()
(byte~) main::$1 (byte~) main::$1
(byte~) main::$3 (byte~) main::$3
@ -473,15 +505,15 @@ CONTROL FLOW GRAPH - PHI LIFTED
to:@end to:@end
@end: scope:[] from @begin @end: scope:[] from @begin
main: scope:[main] from @begin main: scope:[main] from @begin
*((word) 4352) ← (byte) 0 *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0
*((word) 4353) ← (byte) 1 *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@3 main::@1: scope:[main] from main main::@3
(byte) main::i#2 ← phi( main/(byte) 0 main::@3/(byte~) main::i#3 ) (byte) main::i#2 ← phi( main/(byte) 0 main::@3/(byte~) main::i#3 )
(byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2
(byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2
(byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3
*((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1<(byte) 15) goto main::@3 if((byte) main::i#1<(byte) 15) goto main::@3
to:main::@return to:main::@return
@ -504,15 +536,15 @@ CONTROL FLOW GRAPH - LIVE RANGES FOUND
to:@end to:@end
@end: scope:[] from @begin @end: scope:[] from @begin
main: scope:[main] from @begin main: scope:[main] from @begin
[1] *((word) 4352) ← (byte) 0 [ ] [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ]
[2] *((word) 4353) ← (byte) 1 [ ] [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ]
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@3 main::@1: scope:[main] from main main::@3
[3] (byte) main::i#2 ← phi( main/(byte) 0 main::@3/(byte~) main::i#3 ) [ main::i#2 ] [3] (byte) main::i#2 ← phi( main/(byte) 0 main::@3/(byte~) main::i#3 ) [ main::i#2 ]
[4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] [4] (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2 [ main::i#2 main::$1 ]
[5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] [5] (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
[6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ]
[7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] [7] *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ]
[8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[9] if((byte) main::i#1<(byte) 15) goto main::@3 [ main::i#1 ] [9] if((byte) main::i#1<(byte) 15) goto main::@3 [ main::i#1 ]
to:main::@return to:main::@return
@ -537,15 +569,15 @@ CONTROL FLOW GRAPH - PHI MEM COALESCED
to:@end to:@end
@end: scope:[] from @begin @end: scope:[] from @begin
main: scope:[main] from @begin main: scope:[main] from @begin
[1] *((word) 4352) ← (byte) 0 [ ] [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ]
[2] *((word) 4353) ← (byte) 1 [ ] [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ]
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
[3] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ] [3] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ]
[4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] [4] (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2 [ main::i#2 main::$1 ]
[5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] [5] (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
[6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ]
[7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] [7] *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ]
[8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
[9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ]
to:main::@return to:main::@return
@ -597,7 +629,8 @@ Allocated zp ZP_BYTE:3 [ main::$1 ]
Allocated zp ZP_BYTE:4 [ main::$3 ] Allocated zp ZP_BYTE:4 [ main::$3 ]
Allocated zp ZP_BYTE:5 [ main::$4 ] Allocated zp ZP_BYTE:5 [ main::$4 ]
INITIAL ASM INITIAL ASM
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const fibs = $1100
//SEG1 @begin //SEG1 @begin
bbegin: bbegin:
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
@ -611,12 +644,12 @@ main: {
.label _3 = 4 .label _3 = 4
.label _4 = 5 .label _4 = 5
.label i = 2 .label i = 2
//SEG5 [1] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2 //SEG5 [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #$0 lda #$0
sta $1100 sta fibs+$0
//SEG6 [2] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2 //SEG6 [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1 lda #$1
sta $1101 sta fibs+$1
//SEG7 [3] phi from main to main::@1 //SEG7 [3] phi from main to main::@1
b1_from_main: b1_from_main:
//SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- zpby1=coby1 //SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- zpby1=coby1
@ -629,23 +662,23 @@ main: {
jmp b1 jmp b1
//SEG11 main::@1 //SEG11 main::@1
b1: b1:
//SEG12 [4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- zpby1=cowo1_staridx_zpby2 //SEG12 [4] (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- zpby1=cowo1_staridx_zpby2
ldx i ldx i
lda $1100,x lda fibs,x
sta _1 sta _1
//SEG13 [5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] -- zpby1=cowo1_staridx_zpby2 //SEG13 [5] (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] -- zpby1=cowo1_staridx_zpby2
ldx i ldx i
lda $1101,x lda fibs+$1,x
sta _3 sta _3
//SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- zpby1=zpby2_plus_zpby3 //SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- zpby1=zpby2_plus_zpby3
lda _1 lda _1
clc clc
adc _3 adc _3
sta _4 sta _4
//SEG15 [7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby2 //SEG15 [7] *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_zpby1=zpby2
lda _4 lda _4
ldx i ldx i
sta $1102,x sta fibs+$2,x
//SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- zpby1=_inc_zpby1 //SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- zpby1=_inc_zpby1
inc i inc i
//SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- zpby1_lt_coby1_then_la1 //SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- zpby1_lt_coby1_then_la1
@ -659,10 +692,10 @@ main: {
rts rts
} }
Statement [1] *((word) 4352) ← (byte) 0 [ ] always clobbers reg byte a Statement [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ] always clobbers reg byte a
Statement [2] *((word) 4353) ← (byte) 1 [ ] always clobbers reg byte a Statement [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ] always clobbers reg byte a
Statement [1] *((word) 4352) ← (byte) 0 [ ] always clobbers reg byte a Statement [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ] always clobbers reg byte a
Statement [2] *((word) 4353) ← (byte) 1 [ ] always clobbers reg byte a Statement [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ] always clobbers reg byte a
Equivalence Class zp ZP_BYTE:4 [ main::$3 ] has ALU potential. Equivalence Class zp ZP_BYTE:4 [ main::$3 ] has ALU potential.
REGISTER UPLIFT POTENTIAL REGISTERS REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y ,
@ -719,7 +752,8 @@ Removing instruction jmp b1
Removing instruction jmp breturn Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const fibs = $1100
//SEG1 @begin //SEG1 @begin
bbegin: bbegin:
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
@ -728,12 +762,12 @@ bbegin:
bend: bend:
//SEG4 main //SEG4 main
main: { main: {
//SEG5 [1] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2 //SEG5 [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #$0 lda #$0
sta $1100 sta fibs+$0
//SEG6 [2] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2 //SEG6 [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1 lda #$1
sta $1101 sta fibs+$1
//SEG7 [3] phi from main to main::@1 //SEG7 [3] phi from main to main::@1
b1_from_main: b1_from_main:
//SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1 //SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1
@ -744,15 +778,15 @@ main: {
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy //SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1 //SEG11 main::@1
b1: b1:
//SEG12 [4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby //SEG12 [4] (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby
lda $1100,x lda fibs,x
//SEG13 [5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] //SEG13 [5] (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
// [5] main::$3 ← 4353 *idx main::i#2 // ALU // [5] main::$3 ← fibs#0+1 *idx main::i#2 // ALU
//SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby //SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby
clc clc
adc $1101,x adc fibs+$1,x
//SEG15 [7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby //SEG15 [7] *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby
sta $1102,x sta fibs+$2,x
//SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby //SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx inx
//SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1 //SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1
@ -768,7 +802,8 @@ Replacing label b1_from_b1 with b1
Removing instruction b1_from_b1: Removing instruction b1_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const fibs = $1100
//SEG1 @begin //SEG1 @begin
bbegin: bbegin:
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
@ -777,12 +812,12 @@ bbegin:
bend: bend:
//SEG4 main //SEG4 main
main: { main: {
//SEG5 [1] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2 //SEG5 [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #$0 lda #$0
sta $1100 sta fibs+$0
//SEG6 [2] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2 //SEG6 [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1 lda #$1
sta $1101 sta fibs+$1
//SEG7 [3] phi from main to main::@1 //SEG7 [3] phi from main to main::@1
b1_from_main: b1_from_main:
//SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1 //SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1
@ -792,15 +827,15 @@ main: {
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy //SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1 //SEG11 main::@1
b1: b1:
//SEG12 [4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby //SEG12 [4] (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby
lda $1100,x lda fibs,x
//SEG13 [5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] //SEG13 [5] (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
// [5] main::$3 ← 4353 *idx main::i#2 // ALU // [5] main::$3 ← fibs#0+1 *idx main::i#2 // ALU
//SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby //SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby
clc clc
adc $1101,x adc fibs+$1,x
//SEG15 [7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby //SEG15 [7] *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby
sta $1102,x sta fibs+$2,x
//SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby //SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx inx
//SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1 //SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1
@ -818,19 +853,20 @@ Removing instruction b1_from_main:
Removing instruction breturn: Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const fibs = $1100
//SEG1 @begin //SEG1 @begin
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
jsr main jsr main
//SEG3 @end //SEG3 @end
//SEG4 main //SEG4 main
main: { main: {
//SEG5 [1] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2 //SEG5 [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #$0 lda #$0
sta $1100 sta fibs+$0
//SEG6 [2] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2 //SEG6 [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1 lda #$1
sta $1101 sta fibs+$1
//SEG7 [3] phi from main to main::@1 //SEG7 [3] phi from main to main::@1
//SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1 //SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1
ldx #$0 ldx #$0
@ -839,15 +875,15 @@ main: {
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy //SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1 //SEG11 main::@1
b1: b1:
//SEG12 [4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby //SEG12 [4] (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby
lda $1100,x lda fibs,x
//SEG13 [5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] //SEG13 [5] (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
// [5] main::$3 ← 4353 *idx main::i#2 // ALU // [5] main::$3 ← fibs#0+1 *idx main::i#2 // ALU
//SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby //SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby
clc clc
adc $1101,x adc fibs+$1,x
//SEG15 [7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby //SEG15 [7] *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby
sta $1102,x sta fibs+$2,x
//SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby //SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx inx
//SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1 //SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1
@ -861,19 +897,20 @@ main: {
Removing instruction jmp b1 Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const fibs = $1100
//SEG1 @begin //SEG1 @begin
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
jsr main jsr main
//SEG3 @end //SEG3 @end
//SEG4 main //SEG4 main
main: { main: {
//SEG5 [1] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2 //SEG5 [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #$0 lda #$0
sta $1100 sta fibs+$0
//SEG6 [2] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2 //SEG6 [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1 lda #$1
sta $1101 sta fibs+$1
//SEG7 [3] phi from main to main::@1 //SEG7 [3] phi from main to main::@1
//SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1 //SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1
ldx #$0 ldx #$0
@ -881,15 +918,15 @@ main: {
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy //SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1 //SEG11 main::@1
b1: b1:
//SEG12 [4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby //SEG12 [4] (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby
lda $1100,x lda fibs,x
//SEG13 [5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] //SEG13 [5] (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
// [5] main::$3 ← 4353 *idx main::i#2 // ALU // [5] main::$3 ← fibs#0+1 *idx main::i#2 // ALU
//SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby //SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby
clc clc
adc $1101,x adc fibs+$1,x
//SEG15 [7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby //SEG15 [7] *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby
sta $1102,x sta fibs+$2,x
//SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby //SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx inx
//SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1 //SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1
@ -904,6 +941,7 @@ FINAL SYMBOL TABLE
(label) @begin (label) @begin
(label) @end (label) @end
(byte[15]) fibs (byte[15]) fibs
(const byte[15]) fibs#0 = (word) 4352
(void()) main() (void()) main()
(byte~) main::$1 reg byte a 11.0 (byte~) main::$1 reg byte a 11.0
(byte~) main::$3 reg byte alu 22.0 (byte~) main::$3 reg byte alu 22.0
@ -920,19 +958,20 @@ reg byte alu [ main::$3 ]
reg byte a [ main::$4 ] reg byte a [ main::$4 ]
FINAL CODE FINAL CODE
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const fibs = $1100
//SEG1 @begin //SEG1 @begin
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
jsr main jsr main
//SEG3 @end //SEG3 @end
//SEG4 main //SEG4 main
main: { main: {
//SEG5 [1] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2 //SEG5 [1] *((const byte[15]) fibs#0+(byte) 0) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #$0 lda #$0
sta $1100 sta fibs+$0
//SEG6 [2] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2 //SEG6 [2] *((const byte[15]) fibs#0+(byte) 1) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #$1 lda #$1
sta $1101 sta fibs+$1
//SEG7 [3] phi from main to main::@1 //SEG7 [3] phi from main to main::@1
//SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1 //SEG8 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1
ldx #$0 ldx #$0
@ -940,15 +979,15 @@ main: {
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy //SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG11 main::@1 //SEG11 main::@1
b1: b1:
//SEG12 [4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby //SEG12 [4] (byte~) main::$1 ← (const byte[15]) fibs#0 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby
lda $1100,x lda fibs,x
//SEG13 [5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ] //SEG13 [5] (byte~) main::$3 ← (const byte[15]) fibs#0+(byte) 1 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
// [5] main::$3 ← 4353 *idx main::i#2 // ALU // [5] main::$3 ← fibs#0+1 *idx main::i#2 // ALU
//SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby //SEG14 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby
clc clc
adc $1101,x adc fibs+$1,x
//SEG15 [7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby //SEG15 [7] *((const byte[15]) fibs#0+(byte) 2 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby
sta $1102,x sta fibs+$2,x
//SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby //SEG16 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
inx inx
//SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1 //SEG17 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1

View File

@ -1,6 +1,7 @@
(label) @begin (label) @begin
(label) @end (label) @end
(byte[15]) fibs (byte[15]) fibs
(const byte[15]) fibs#0 = (word) 4352
(void()) main() (void()) main()
(byte~) main::$1 reg byte a 11.0 (byte~) main::$1 reg byte a 11.0
(byte~) main::$3 reg byte alu 22.0 (byte~) main::$3 reg byte alu 22.0

View File

@ -28,9 +28,9 @@ plot: {
.label y = 4 .label y = 4
lda #$10 lda #$10
sta y sta y
lda #<(SCREEN+($5*$28))+$c lda #<SCREEN+(($5*$28)+$c)
sta line sta line
lda #>(SCREEN+($5*$28))+$c lda #>SCREEN+(($5*$28)+$c)
sta line+$1 sta line+$1
ldx #$0 ldx #$0
b1: b1:

File diff suppressed because it is too large Load Diff

View File

@ -282,8 +282,8 @@ main::@return: scope:[main] from main::@1
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Constant (const byte*) SCREEN#0 Constant (const byte*) SCREEN#0 = 1024
Constant (const byte) main::i#0 Constant (const byte) main::i#0 = 0
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -305,8 +305,8 @@ main::@return: scope:[main] from main::@1
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Redundant Phi (byte*) SCREEN#1 (const byte*) SCREEN#0 Constant (const byte*) SCREEN#1 = SCREEN#0
Succesful SSA optimization Pass2RedundantPhiElimination Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
to:@1 to:@1
@ -314,7 +314,7 @@ main: scope:[main] from @1
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) main::i#2 *((const byte*) SCREEN#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 100) goto main::@1 if((byte) main::i#1!=(byte) 100) goto main::@1
to:main::@return to:main::@return
@ -326,6 +326,9 @@ main::@return: scope:[main] from main::@1
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Constant inlined SCREEN#1 = (const byte*) SCREEN#0
Constant inlined main::i#0 = (byte) 0 Constant inlined main::i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH CONTROL FLOW GRAPH

View File

@ -434,10 +434,10 @@ main::@return: scope:[main] from main::@2
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Constant (const byte*) SCREEN1#0 Constant (const byte*) SCREEN1#0 = 1024
Constant (const byte*) SCREEN2#0 Constant (const byte*) SCREEN2#0 = 1280
Constant (const byte) main::i#0 Constant (const byte) main::i#0 = 0
Constant (const byte) main::j#0 Constant (const byte) main::j#0 = 100
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -469,6 +469,68 @@ main::@return: scope:[main] from main::@2
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Constant (const byte*) SCREEN1#1 = SCREEN1#0
Constant (const byte*) SCREEN2#2 = SCREEN2#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((const byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@3
main::@3: scope:[main] from main::@1
to:main::@2
main::@2: scope:[main] from main::@2 main::@3
(byte*) SCREEN2#1 ← phi( main::@3/(const byte*) SCREEN2#2 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(const byte) main::j#0 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
@1: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @1
Constant (const byte*) SCREEN2#1 = SCREEN2#2
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((const byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@3
main::@3: scope:[main] from main::@1
to:main::@2
main::@2: scope:[main] from main::@2 main::@3
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(const byte) main::j#0 )
*((const byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
@1: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @1
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::j#2
Culled Empty Block (label) main::@3 Culled Empty Block (label) main::@3
Succesful SSA optimization Pass2CullEmptyBlocks Succesful SSA optimization Pass2CullEmptyBlocks
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@ -477,74 +539,14 @@ CONTROL FLOW GRAPH
main: scope:[main] from @1 main: scope:[main] from @1
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1 main::@1: scope:[main] from main main::@1
(byte*) SCREEN2#2 ← phi( main/(const byte*) SCREEN2#0 )
(byte*) SCREEN1#1 ← phi( main/(const byte*) SCREEN1#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2 *((const byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1 if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2 main::@2: scope:[main] from main::@1 main::@2
(byte*) SCREEN2#1 ← phi( main::@1/(byte*) SCREEN2#2 )
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(const byte) main::j#0 ) (byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(const byte) main::j#0 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2 *((const byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
@1: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @1
Alias (byte*) SCREEN2#1 = (byte*) SCREEN2#2
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) SCREEN2#1 ← phi( main/(const byte*) SCREEN2#0 )
(byte*) SCREEN1#1 ← phi( main/(const byte*) SCREEN1#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) SCREEN1#1 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1 main::@2
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(const byte) main::j#0 )
*((byte*) SCREEN2#1 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
@1: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @1
Redundant Phi (byte*) SCREEN1#1 (const byte*) SCREEN1#0
Redundant Phi (byte*) SCREEN2#1 (const byte*) SCREEN2#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from @1
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
*((const byte*) SCREEN1#0 + (byte) main::i#2) ← (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 0) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1 main::@2
(byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@1/(const byte) main::j#0 )
*((const byte*) SCREEN2#0 + (byte) main::j#2) ← (byte) main::j#2
(byte) main::j#1 ← -- (byte) main::j#2 (byte) main::j#1 ← -- (byte) main::j#2
if((byte) main::j#1!=(byte) 255) goto main::@2 if((byte) main::j#1!=(byte) 255) goto main::@2
to:main::@return to:main::@return
@ -556,6 +558,13 @@ main::@return: scope:[main] from main::@2
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::j#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::j#2
Constant inlined SCREEN1#1 = (const byte*) SCREEN1#0
Constant inlined SCREEN2#1 = (const byte*) SCREEN2#0
Constant inlined SCREEN2#2 = (const byte*) SCREEN2#0
Constant inlined main::j#0 = (byte) 100 Constant inlined main::j#0 = (byte) 100
Constant inlined main::i#0 = (byte) 0 Constant inlined main::i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining Succesful SSA optimization Pass2ConstantInlining

View File

@ -417,8 +417,8 @@ main::@return: scope:[main] from main::@2
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte*) SCREEN#0 Constant (const byte*) SCREEN#0 = 1024
Constant (const byte) main::i#0 Constant (const byte) main::i#0 = 0
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -443,8 +443,8 @@ main::@return: scope:[main] from main::@2
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#1 (const byte*) SCREEN#0 Constant (const byte*) SCREEN#1 = SCREEN#0
Succesful SSA optimization Pass2RedundantPhiElimination Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -460,13 +460,14 @@ main::@2: scope:[main] from main::@1 main::@3
if((byte) main::i#1<(byte) 100) goto main::@1 if((byte) main::i#1<(byte) 100) goto main::@1
to:main::@return to:main::@return
main::@3: scope:[main] from main::@1 main::@3: scope:[main] from main::@1
*((const byte*) SCREEN#0) ← (byte) main::i#2 *((const byte*) SCREEN#1) ← (byte) main::i#2
to:main::@2 to:main::@2
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant inlined SCREEN#1 = (const byte*) SCREEN#0
Constant inlined main::i#0 = (byte) 0 Constant inlined main::i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH CONTROL FLOW GRAPH

View File

@ -361,8 +361,12 @@ inc::@return: scope:[inc] from inc
to:@return to:@return
@end: scope:[] from @3 @end: scope:[] from @3
Constant (const byte) i#0 Not aliassing across scopes: main::$0 inc::return#0
Constant (const byte) main::a#0 Not aliassing across scopes: main::$2 inc::return#0
Not aliassing across scopes: i#1 inc::$0
Not aliassing across scopes: inc::return#0 i#1
Constant (const byte) i#0 = 0
Constant (const byte) main::a#0 = 4
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from

View File

@ -281,8 +281,8 @@ CONTROL FLOW GRAPH
to:@2 to:@2
@end: scope:[] from @2 @end: scope:[] from @2
Constant (const byte) i#0 Constant (const byte) i#0 = 10
Constant (const byte) s#0 Constant (const byte) s#0 = 0
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from

View File

@ -450,9 +450,9 @@ nest::@return: scope:[nest] from nest::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte*) SCREEN#0 Constant (const byte*) SCREEN#0 = 1024
Constant (const byte) main::i#0 Constant (const byte) main::i#0 = 100
Constant (const byte) nest::j#0 Constant (const byte) nest::j#0 = 100
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -486,8 +486,8 @@ nest::@return: scope:[nest] from nest::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Alias (byte*) SCREEN#1 = (byte*) SCREEN#2 Constant (const byte*) SCREEN#2 = SCREEN#0
Succesful SSA optimization Pass2AliasElimination Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -495,7 +495,6 @@ CONTROL FLOW GRAPH
main: scope:[main] from @begin main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@3 main::@1: scope:[main] from main main::@3
(byte*) SCREEN#1 ← phi( main/(const byte*) SCREEN#0 )
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@3/(byte) main::i#1 )
call nest param-assignment call nest param-assignment
to:main::@3 to:main::@3
@ -509,6 +508,7 @@ main::@return: scope:[main] from main::@3
nest: scope:[nest] from main::@1 nest: scope:[nest] from main::@1
to:nest::@1 to:nest::@1
nest::@1: scope:[nest] from nest nest::@1 nest::@1: scope:[nest] from nest nest::@1
(byte*) SCREEN#1 ← phi( nest/(const byte*) SCREEN#2 )
(byte) nest::j#2 ← phi( nest/(const byte) nest::j#0 nest::@1/(byte) nest::j#1 ) (byte) nest::j#2 ← phi( nest/(const byte) nest::j#0 nest::@1/(byte) nest::j#1 )
*((byte*) SCREEN#1) ← (byte) nest::j#2 *((byte*) SCREEN#1) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2 (byte) nest::j#1 ← -- (byte) nest::j#2
@ -519,8 +519,8 @@ nest::@return: scope:[nest] from nest::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#1 (const byte*) SCREEN#0 Constant (const byte*) SCREEN#1 = SCREEN#2
Succesful SSA optimization Pass2RedundantPhiElimination Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -542,7 +542,7 @@ nest: scope:[nest] from main::@1
to:nest::@1 to:nest::@1
nest::@1: scope:[nest] from nest nest::@1 nest::@1: scope:[nest] from nest nest::@1
(byte) nest::j#2 ← phi( nest/(const byte) nest::j#0 nest::@1/(byte) nest::j#1 ) (byte) nest::j#2 ← phi( nest/(const byte) nest::j#0 nest::@1/(byte) nest::j#1 )
*((const byte*) SCREEN#0) ← (byte) nest::j#2 *((const byte*) SCREEN#1) ← (byte) nest::j#2
(byte) nest::j#1 ← -- (byte) nest::j#2 (byte) nest::j#1 ← -- (byte) nest::j#2
if((byte) nest::j#1>(byte) 0) goto nest::@1 if((byte) nest::j#1>(byte) 0) goto nest::@1
to:nest::@return to:nest::@return
@ -551,6 +551,8 @@ nest::@return: scope:[nest] from nest::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant inlined SCREEN#2 = (const byte*) SCREEN#0
Constant inlined SCREEN#1 = (const byte*) SCREEN#0
Constant inlined main::i#0 = (byte) 100 Constant inlined main::i#0 = (byte) 100
Constant inlined nest::j#0 = (byte) 100 Constant inlined nest::j#0 = (byte) 100
Succesful SSA optimization Pass2ConstantInlining Succesful SSA optimization Pass2ConstantInlining

View File

@ -1016,13 +1016,13 @@ nest2::@return: scope:[nest2] from nest2::@3
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte*) SCREEN#0 Constant (const byte*) SCREEN#0 = 1024
Constant (const byte) main::i#0 Constant (const byte) main::i#0 = 100
Constant (const byte) main::j#0 Constant (const byte) main::j#0 = 100
Constant (const byte) nest1::i#0 Constant (const byte) nest1::i#0 = 100
Constant (const byte) nest1::j#0 Constant (const byte) nest1::j#0 = 100
Constant (const byte) nest2::i#0 Constant (const byte) nest2::i#0 = 100
Constant (const byte) nest2::j#0 Constant (const byte) nest2::j#0 = 100
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -1242,7 +1242,7 @@ nest2::@return: scope:[nest2] from nest2::@3
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte*) SCREEN#10 Constant (const byte*) SCREEN#10 = SCREEN#0
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -1310,8 +1310,8 @@ nest2::@return: scope:[nest2] from nest2::@3
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Alias (byte*) SCREEN#1 = (byte*) SCREEN#3 Constant (const byte*) SCREEN#3 = SCREEN#10
Succesful SSA optimization Pass2AliasElimination Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -1339,7 +1339,6 @@ main::@return: scope:[main] from main::@3
nest1: scope:[nest1] from main::@2 nest1: scope:[nest1] from main::@2
to:nest1::@1 to:nest1::@1
nest1::@1: scope:[nest1] from nest1 nest1::@3 nest1::@1: scope:[nest1] from nest1 nest1::@3
(byte*) SCREEN#1 ← phi( nest1/(const byte*) SCREEN#10 )
(byte) nest1::i#2 ← phi( nest1/(const byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 ) (byte) nest1::i#2 ← phi( nest1/(const byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
to:nest1::@2 to:nest1::@2
nest1::@2: scope:[nest1] from nest1::@1 nest1::@5 nest1::@2: scope:[nest1] from nest1::@1 nest1::@5
@ -1361,6 +1360,7 @@ nest2: scope:[nest2] from nest1::@2
to:nest2::@1 to:nest2::@1
nest2::@1: scope:[nest2] from nest2 nest2::@3 nest2::@1: scope:[nest2] from nest2 nest2::@3
(byte) nest2::i#2 ← phi( nest2/(const byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 ) (byte) nest2::i#2 ← phi( nest2/(const byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
(byte*) SCREEN#1 ← phi( nest2/(const byte*) SCREEN#3 )
to:nest2::@2 to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2 nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 ) (byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
@ -1377,8 +1377,8 @@ nest2::@return: scope:[nest2] from nest2::@3
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Redundant Phi (byte*) SCREEN#1 (const byte*) SCREEN#10 Constant (const byte*) SCREEN#1 = SCREEN#3
Succesful SSA optimization Pass2RedundantPhiElimination Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -1430,7 +1430,7 @@ nest2::@1: scope:[nest2] from nest2 nest2::@3
to:nest2::@2 to:nest2::@2
nest2::@2: scope:[nest2] from nest2::@1 nest2::@2 nest2::@2: scope:[nest2] from nest2::@1 nest2::@2
(byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 ) (byte) nest2::j#2 ← phi( nest2::@1/(const byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
*((const byte*) SCREEN#10) ← (byte) nest2::j#2 *((const byte*) SCREEN#1) ← (byte) nest2::j#2
(byte) nest2::j#1 ← -- (byte) nest2::j#2 (byte) nest2::j#1 ← -- (byte) nest2::j#2
if((byte) nest2::j#1>(byte) 0) goto nest2::@2 if((byte) nest2::j#1>(byte) 0) goto nest2::@2
to:nest2::@3 to:nest2::@3
@ -1446,6 +1446,8 @@ nest2::@return: scope:[nest2] from nest2::@3
Constant inlined nest1::i#0 = (byte) 100 Constant inlined nest1::i#0 = (byte) 100
Constant inlined nest1::j#0 = (byte) 100 Constant inlined nest1::j#0 = (byte) 100
Constant inlined nest2::i#0 = (byte) 100 Constant inlined nest2::i#0 = (byte) 100
Constant inlined SCREEN#1 = (const byte*) SCREEN#0
Constant inlined SCREEN#3 = (const byte*) SCREEN#0
Constant inlined nest2::j#0 = (byte) 100 Constant inlined nest2::j#0 = (byte) 100
Constant inlined main::j#0 = (byte) 100 Constant inlined main::j#0 = (byte) 100
Constant inlined main::i#0 = (byte) 100 Constant inlined main::i#0 = (byte) 100

View File

@ -418,8 +418,8 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte) main::i#0 Constant (const byte) main::i#0 = 100
Constant (const byte) main::s#0 Constant (const byte) main::s#0 = 0
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from

View File

@ -1,9 +1,10 @@
.const p = $1100
ldx #$5 ldx #$5
b1: b1:
txa txa
clc clc
adc #$4 adc #$2+$2
sta $1100,x sta p,x
inx inx
cpx #$a cpx #$a
bcc b1 bcc b1

View File

@ -2,8 +2,8 @@
to:@1 to:@1
@1: scope:[] from @1 @begin @1: scope:[] from @1 @begin
[0] (byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 ) [ i#2 ] [0] (byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 ) [ i#2 ]
[1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ]
[2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] [2] *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1 [ i#2 ]
[3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ]
[4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ]
to:@end to:@end

View File

@ -132,55 +132,18 @@ INITIAL SSA SYMBOL TABLE
(byte[16]) p#0 (byte[16]) p#0
(byte[16]) p#1 (byte[16]) p#1
Constant (byte[16]) p#0 (word) 4352
Constant (byte) i#0 (byte) 5
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@1: scope:[] from @1 @begin
(byte[16]) p#1 ← phi( @1/(byte[16]) p#1 @begin/(word) 4352 )
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 )
(byte~) $0 ← (byte) 2 + (byte) i#2
(byte~) $1 ← (byte~) $0 + (byte) 2
*((byte[16]) p#1 + (byte) i#2) ← (byte~) $1
(byte~) $2 ← (byte) i#2 + (byte) 1
(byte) i#1 ← (byte~) $2
(boolean~) $3 ← (byte) i#1 < (byte) 10
if((boolean~) $3) goto @1
to:@end
@end: scope:[] from @1
Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Consolidated constant in assignment $1
Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Succesful SSA optimization Pass2ConstantAdditionElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@1: scope:[] from @1 @begin
(byte[16]) p#1 ← phi( @1/(byte[16]) p#1 @begin/(word) 4352 )
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 )
(byte~) $0 ← (byte) i#2
(byte~) $1 ← (byte~) $0 + (byte) 4
*((byte[16]) p#1 + (byte) i#2) ← (byte~) $1
(byte~) $2 ← (byte) i#2 + (byte) 1
(byte) i#1 ← (byte~) $2
(boolean~) $3 ← (byte) i#1 < (byte) 10
if((boolean~) $3) goto @1
to:@end
@end: scope:[] from @1
Alias (byte) i#2 = (byte~) $0
Alias (byte) i#1 = (byte~) $2 Alias (byte) i#1 = (byte~) $2
Succesful SSA optimization Pass2AliasElimination Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
(byte[16]) p#0 ← (word) 4352
(byte) i#0 ← (byte) 5
to:@1 to:@1
@1: scope:[] from @1 @begin @1: scope:[] from @1 @begin
(byte[16]) p#1 ← phi( @1/(byte[16]) p#1 @begin/(word) 4352 ) (byte[16]) p#1 ← phi( @1/(byte[16]) p#1 @begin/(byte[16]) p#0 )
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 ) (byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) i#0 )
(byte~) $1 ← (byte) i#2 + (byte) 4 (byte~) $0 ← (byte) 2 + (byte) i#2
(byte~) $1 ← (byte~) $0 + (byte) 2
*((byte[16]) p#1 + (byte) i#2) ← (byte~) $1 *((byte[16]) p#1 + (byte) i#2) ← (byte~) $1
(byte) i#1 ← (byte) i#2 + (byte) 1 (byte) i#1 ← (byte) i#2 + (byte) 1
(boolean~) $3 ← (byte) i#1 < (byte) 10 (boolean~) $3 ← (byte) i#1 < (byte) 10
@ -192,11 +155,14 @@ Self Phi Eliminated (byte[16]) p#1
Succesful SSA optimization Pass2SelfPhiElimination Succesful SSA optimization Pass2SelfPhiElimination
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
(byte[16]) p#0 ← (word) 4352
(byte) i#0 ← (byte) 5
to:@1 to:@1
@1: scope:[] from @1 @begin @1: scope:[] from @1 @begin
(byte[16]) p#1 ← phi( @begin/(word) 4352 ) (byte[16]) p#1 ← phi( @begin/(byte[16]) p#0 )
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 ) (byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) i#0 )
(byte~) $1 ← (byte) i#2 + (byte) 4 (byte~) $0 ← (byte) 2 + (byte) i#2
(byte~) $1 ← (byte~) $0 + (byte) 2
*((byte[16]) p#1 + (byte) i#2) ← (byte~) $1 *((byte[16]) p#1 + (byte) i#2) ← (byte~) $1
(byte) i#1 ← (byte) i#2 + (byte) 1 (byte) i#1 ← (byte) i#2 + (byte) 1
(boolean~) $3 ← (byte) i#1 < (byte) 10 (boolean~) $3 ← (byte) i#1 < (byte) 10
@ -208,26 +174,81 @@ Simple Condition (boolean~) $3 if((byte) i#1<(byte) 10) goto @1
Succesful SSA optimization Pass2ConditionalJumpSimplification Succesful SSA optimization Pass2ConditionalJumpSimplification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
(byte[16]) p#0 ← (word) 4352
(byte) i#0 ← (byte) 5
to:@1 to:@1
@1: scope:[] from @1 @begin @1: scope:[] from @1 @begin
(byte[16]) p#1 ← phi( @begin/(word) 4352 ) (byte[16]) p#1 ← phi( @begin/(byte[16]) p#0 )
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 ) (byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) i#0 )
(byte~) $1 ← (byte) i#2 + (byte) 4 (byte~) $0 ← (byte) 2 + (byte) i#2
(byte~) $1 ← (byte~) $0 + (byte) 2
*((byte[16]) p#1 + (byte) i#2) ← (byte~) $1 *((byte[16]) p#1 + (byte) i#2) ← (byte~) $1
(byte) i#1 ← (byte) i#2 + (byte) 1 (byte) i#1 ← (byte) i#2 + (byte) 1
if((byte) i#1<(byte) 10) goto @1 if((byte) i#1<(byte) 10) goto @1
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Constant (byte[16]) p#1 (word) 4352 Constant (const byte[16]) p#0 = 4352
Succesful SSA optimization Pass2ConstantPropagation Constant (const byte) i#0 = 5
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
to:@1 to:@1
@1: scope:[] from @1 @begin @1: scope:[] from @1 @begin
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 ) (byte[16]) p#1 ← phi( @begin/(const byte[16]) p#0 )
(byte~) $1 ← (byte) i#2 + (byte) 4 (byte) i#2 ← phi( @1/(byte) i#1 @begin/(const byte) i#0 )
*((word) 4352 + (byte) i#2) ← (byte~) $1 (byte~) $0 ← (byte) 2 + (byte) i#2
(byte~) $1 ← (byte~) $0 + (byte) 2
*((byte[16]) p#1 + (byte) i#2) ← (byte~) $1
(byte) i#1 ← (byte) i#2 + (byte) 1
if((byte) i#1<(byte) 10) goto @1
to:@end
@end: scope:[] from @1
Constant (const byte[16]) p#1 = p#0
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@1: scope:[] from @1 @begin
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(const byte) i#0 )
(byte~) $0 ← (byte) 2 + (byte) i#2
(byte~) $1 ← (byte~) $0 + (byte) 2
*((const byte[16]) p#1 + (byte) i#2) ← (byte~) $1
(byte) i#1 ← (byte) i#2 + (byte) 1
if((byte) i#1<(byte) 10) goto @1
to:@end
@end: scope:[] from @1
Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Consolidated constant in assignment $1
Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Succesful SSA optimization Pass2ConstantAdditionElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@1: scope:[] from @1 @begin
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(const byte) i#0 )
(byte~) $0 ← (byte) i#2
(byte~) $1 ← (byte~) $0 + (byte) 2+(byte) 2
*((const byte[16]) p#1 + (byte) i#2) ← (byte~) $1
(byte) i#1 ← (byte) i#2 + (byte) 1
if((byte) i#1<(byte) 10) goto @1
to:@end
@end: scope:[] from @1
Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Alias (byte) i#2 = (byte~) $0
Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@1: scope:[] from @1 @begin
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(const byte) i#0 )
(byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2
*((const byte[16]) p#1 + (byte) i#2) ← (byte~) $1
(byte) i#1 ← (byte) i#2 + (byte) 1 (byte) i#1 ← (byte) i#2 + (byte) 1
if((byte) i#1<(byte) 10) goto @1 if((byte) i#1<(byte) 10) goto @1
to:@end to:@end
@ -239,6 +260,21 @@ Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Multiple usages for variable. Not optimizing sub-constant (byte) i#2 Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Multiple usages for variable. Not optimizing sub-constant (byte) i#2 Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Multiple usages for variable. Not optimizing sub-constant (byte) i#2 Multiple usages for variable. Not optimizing sub-constant (byte) i#2
Constant inlined p#1 = (const byte[16]) p#0
Constant inlined i#0 = (byte) 5
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@1: scope:[] from @1 @begin
(byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 )
(byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2
*((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1
(byte) i#1 ← (byte) i#2 + (byte) 1
if((byte) i#1<(byte) 10) goto @1
to:@end
@end: scope:[] from @1
FINAL SYMBOL TABLE FINAL SYMBOL TABLE
(byte~) $1 (byte~) $1
(label) @1 (label) @1
@ -248,6 +284,7 @@ FINAL SYMBOL TABLE
(byte) i#1 (byte) i#1
(byte) i#2 (byte) i#2
(byte[16]) p (byte[16]) p
(const byte[16]) p#0 = (word) 4352
Block Sequence Planned @begin @1 @end Block Sequence Planned @begin @1 @end
Added new block during phi lifting @3(between @1 and @1) Added new block during phi lifting @3(between @1 and @1)
@ -257,8 +294,8 @@ CONTROL FLOW GRAPH - PHI LIFTED
to:@1 to:@1
@1: scope:[] from @3 @begin @1: scope:[] from @3 @begin
(byte) i#2 ← phi( @3/(byte~) i#3 @begin/(byte) 5 ) (byte) i#2 ← phi( @3/(byte~) i#3 @begin/(byte) 5 )
(byte~) $1 ← (byte) i#2 + (byte) 4 (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2
*((word) 4352 + (byte) i#2) ← (byte~) $1 *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1
(byte) i#1 ← (byte) i#2 + (byte) 1 (byte) i#1 ← (byte) i#2 + (byte) 1
if((byte) i#1<(byte) 10) goto @3 if((byte) i#1<(byte) 10) goto @3
to:@end to:@end
@ -276,8 +313,8 @@ CONTROL FLOW GRAPH - LIVE RANGES FOUND
to:@1 to:@1
@1: scope:[] from @3 @begin @1: scope:[] from @3 @begin
[0] (byte) i#2 ← phi( @3/(byte~) i#3 @begin/(byte) 5 ) [ i#2 ] [0] (byte) i#2 ← phi( @3/(byte~) i#3 @begin/(byte) 5 ) [ i#2 ]
[1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ]
[2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] [2] *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1 [ i#2 ]
[3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ]
[4] if((byte) i#1<(byte) 10) goto @3 [ i#1 ] [4] if((byte) i#1<(byte) 10) goto @3 [ i#1 ]
to:@end to:@end
@ -298,8 +335,8 @@ CONTROL FLOW GRAPH - PHI MEM COALESCED
to:@1 to:@1
@1: scope:[] from @1 @begin @1: scope:[] from @1 @begin
[0] (byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 ) [ i#2 ] [0] (byte) i#2 ← phi( @1/(byte) i#1 @begin/(byte) 5 ) [ i#2 ]
[1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ]
[2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] [2] *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1 [ i#2 ]
[3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ]
[4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ]
to:@end to:@end
@ -337,7 +374,8 @@ Complete equivalence classes
Allocated zp ZP_BYTE:2 [ i#2 i#1 ] Allocated zp ZP_BYTE:2 [ i#2 i#1 ]
Allocated zp ZP_BYTE:3 [ $1 ] Allocated zp ZP_BYTE:3 [ $1 ]
INITIAL ASM INITIAL ASM
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const p = $1100
.label _1 = 3 .label _1 = 3
.label i = 2 .label i = 2
//SEG1 @begin //SEG1 @begin
@ -354,15 +392,15 @@ b1_from_b1:
jmp b1 jmp b1
//SEG6 @1 //SEG6 @1
b1: b1:
//SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- zpby1=zpby2_plus_coby1 //SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ] -- zpby1=zpby2_plus_coby1
lda i lda i
clc clc
adc #$4 adc #$2+$2
sta _1 sta _1
//SEG8 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_zpby1=zpby2 //SEG8 [2] *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_zpby1=zpby2
lda _1 lda _1
ldx i ldx i
sta $1100,x sta p,x
//SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1 //SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1
inc i inc i
//SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1 //SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1
@ -373,9 +411,9 @@ b1:
//SEG11 @end //SEG11 @end
bend: bend:
Statement [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] always clobbers reg byte a Statement [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ] always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ i#2 i#1 ] Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ i#2 i#1 ]
Statement [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] always clobbers reg byte a Statement [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ] always clobbers reg byte a
REGISTER UPLIFT POTENTIAL REGISTERS REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp ZP_BYTE:2 [ i#2 i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , Potential registers zp ZP_BYTE:2 [ i#2 i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:3 [ $1 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , Potential registers zp ZP_BYTE:3 [ $1 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y ,
@ -388,7 +426,8 @@ Removing instruction jmp b1
Removing instruction jmp bend Removing instruction jmp bend
Succesful ASM optimization Pass5NextJumpElimination Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const p = $1100
//SEG1 @begin //SEG1 @begin
bbegin: bbegin:
//SEG2 [0] phi from @begin to @1 //SEG2 [0] phi from @begin to @1
@ -401,12 +440,12 @@ b1_from_b1:
//SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy //SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG6 @1 //SEG6 @1
b1: b1:
//SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- aby=xby_plus_coby1 //SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ] -- aby=xby_plus_coby1
txa txa
clc clc
adc #$4 adc #$2+$2
//SEG8 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby //SEG8 [2] *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby
sta $1100,x sta p,x
//SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1 //SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1
inx inx
//SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1 //SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1
@ -420,7 +459,8 @@ Removing instruction b1_from_bbegin:
Removing instruction b1_from_b1: Removing instruction b1_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const p = $1100
//SEG1 @begin //SEG1 @begin
bbegin: bbegin:
//SEG2 [0] phi from @begin to @1 //SEG2 [0] phi from @begin to @1
@ -431,12 +471,12 @@ bbegin:
//SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy //SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG6 @1 //SEG6 @1
b1: b1:
//SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- aby=xby_plus_coby1 //SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ] -- aby=xby_plus_coby1
txa txa
clc clc
adc #$4 adc #$2+$2
//SEG8 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby //SEG8 [2] *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby
sta $1100,x sta p,x
//SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1 //SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1
inx inx
//SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1 //SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1
@ -449,7 +489,8 @@ Removing instruction bbegin:
Removing instruction bend: Removing instruction bend:
Succesful ASM optimization Pass5UnusedLabelElimination Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const p = $1100
//SEG1 @begin //SEG1 @begin
//SEG2 [0] phi from @begin to @1 //SEG2 [0] phi from @begin to @1
//SEG3 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1 //SEG3 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1
@ -459,12 +500,12 @@ ASSEMBLER
//SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy //SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG6 @1 //SEG6 @1
b1: b1:
//SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- aby=xby_plus_coby1 //SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ] -- aby=xby_plus_coby1
txa txa
clc clc
adc #$4 adc #$2+$2
//SEG8 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby //SEG8 [2] *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby
sta $1100,x sta p,x
//SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1 //SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1
inx inx
//SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1 //SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1
@ -475,7 +516,8 @@ b1:
Removing instruction jmp b1 Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const p = $1100
//SEG1 @begin //SEG1 @begin
//SEG2 [0] phi from @begin to @1 //SEG2 [0] phi from @begin to @1
//SEG3 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1 //SEG3 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1
@ -484,12 +526,12 @@ ASSEMBLER
//SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy //SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG6 @1 //SEG6 @1
b1: b1:
//SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- aby=xby_plus_coby1 //SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ] -- aby=xby_plus_coby1
txa txa
clc clc
adc #$4 adc #$2+$2
//SEG8 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby //SEG8 [2] *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby
sta $1100,x sta p,x
//SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1 //SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1
inx inx
//SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1 //SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1
@ -506,12 +548,14 @@ FINAL SYMBOL TABLE
(byte) i#1 reg byte x 16.5 (byte) i#1 reg byte x 16.5
(byte) i#2 reg byte x 14.666666666666666 (byte) i#2 reg byte x 14.666666666666666
(byte[16]) p (byte[16]) p
(const byte[16]) p#0 = (word) 4352
reg byte x [ i#2 i#1 ] reg byte x [ i#2 i#1 ]
reg byte a [ $1 ] reg byte a [ $1 ]
FINAL CODE FINAL CODE
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const p = $1100
//SEG1 @begin //SEG1 @begin
//SEG2 [0] phi from @begin to @1 //SEG2 [0] phi from @begin to @1
//SEG3 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1 //SEG3 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1
@ -520,12 +564,12 @@ FINAL CODE
//SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy //SEG5 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG6 @1 //SEG6 @1
b1: b1:
//SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- aby=xby_plus_coby1 //SEG7 [1] (byte~) $1 ← (byte) i#2 + (byte) 2+(byte) 2 [ i#2 $1 ] -- aby=xby_plus_coby1
txa txa
clc clc
adc #$4 adc #$2+$2
//SEG8 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby //SEG8 [2] *((const byte[16]) p#0 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby
sta $1100,x sta p,x
//SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1 //SEG9 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1
inx inx
//SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1 //SEG10 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1

View File

@ -6,6 +6,7 @@
(byte) i#1 reg byte x 16.5 (byte) i#1 reg byte x 16.5
(byte) i#2 reg byte x 14.666666666666666 (byte) i#2 reg byte x 14.666666666666666
(byte[16]) p (byte[16]) p
(const byte[16]) p#0 = (word) 4352
reg byte x [ i#2 i#1 ] reg byte x [ i#2 i#1 ]
reg byte a [ $1 ] reg byte a [ $1 ]

View File

@ -1,3 +1,4 @@
.const SCREEN = $400
.label cnt3 = 2 .label cnt3 = 2
jsr main jsr main
main: { main: {
@ -6,10 +7,10 @@ main: {
ldy #$0 ldy #$0
ldx #$0 ldx #$0
jsr inccnt jsr inccnt
sta $400 sta SCREEN+$0
inx inx
jsr inccnt jsr inccnt
sta $401 sta SCREEN+$1
rts rts
} }
inccnt: { inccnt: {

View File

@ -8,13 +8,13 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
[3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ]
[4] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] [4] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ]
[5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ]
[6] call inccnt param-assignment [ inccnt::return#0 ] [6] call inccnt param-assignment [ inccnt::return#0 ]
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
[7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ] [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ]
[8] *((word) 1025) ← (byte~) main::$1 [ ] [8] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1 [ ]
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
[9] return [ ] [9] return [ ]

View File

@ -431,128 +431,48 @@ INITIAL SSA SYMBOL TABLE
(label) main::@2 (label) main::@2
(label) main::@return (label) main::@return
Constant (byte) cnt#0 (byte) 0
Constant (byte) cnt2#0 (byte) 0
Constant (byte) cnt3#0 (byte) 0
Constant (byte[256]) SCREEN#0 (word) 1024
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@3
@3: scope:[] from @begin
(byte) cnt3#7 ← phi( @begin/(byte) cnt3#4 )
(byte) cnt2#7 ← phi( @begin/(byte) cnt2#4 )
(byte) cnt#8 ← phi( @begin/(byte) cnt#5 )
(byte) cnt#1 ← (byte) cnt#8
(byte) cnt2#1 ← (byte) cnt2#7
(byte) cnt3#1 ← (byte) cnt3#7
to:@end
main: scope:[main] from @begin
(byte[256]) SCREEN#3 ← phi( @begin/(word) 1024 )
(byte) cnt3#13 ← phi( @begin/(byte) 0 )
(byte) cnt2#13 ← phi( @begin/(byte) 0 )
(byte) cnt#14 ← phi( @begin/(byte) 0 )
call inccnt param-assignment
(byte) inccnt::return#0 ← (byte) inccnt::return#3
to:main::@1
main::@1: scope:[main] from main
(byte[256]) SCREEN#1 ← phi( main/(byte[256]) SCREEN#3 )
(byte) cnt3#8 ← phi( main/(byte) cnt3#6 )
(byte) cnt2#8 ← phi( main/(byte) cnt2#6 )
(byte) cnt#9 ← phi( main/(byte) cnt#7 )
(byte) inccnt::return#4 ← phi( main/(byte) inccnt::return#0 )
(byte~) main::$0 ← (byte) inccnt::return#4
(byte) cnt#2 ← (byte) cnt#9
(byte) cnt2#2 ← (byte) cnt2#8
(byte) cnt3#2 ← (byte) cnt3#8
*((byte[256]) SCREEN#1 + (byte) 0) ← (byte~) main::$0
(byte) cnt#3 ← ++ (byte) cnt#2
call inccnt param-assignment
(byte) inccnt::return#1 ← (byte) inccnt::return#3
to:main::@2
main::@2: scope:[main] from main::@1
(byte[256]) SCREEN#2 ← phi( main::@1/(byte[256]) SCREEN#1 )
(byte) cnt3#9 ← phi( main::@1/(byte) cnt3#6 )
(byte) cnt2#9 ← phi( main::@1/(byte) cnt2#6 )
(byte) cnt#10 ← phi( main::@1/(byte) cnt#7 )
(byte) inccnt::return#5 ← phi( main::@1/(byte) inccnt::return#1 )
(byte~) main::$1 ← (byte) inccnt::return#5
(byte) cnt#4 ← (byte) cnt#10
(byte) cnt2#3 ← (byte) cnt2#9
(byte) cnt3#3 ← (byte) cnt3#9
*((byte[256]) SCREEN#2 + (byte) 1) ← (byte~) main::$1
to:main::@return
main::@return: scope:[main] from main::@2
(byte) cnt3#10 ← phi( main::@2/(byte) cnt3#3 )
(byte) cnt2#10 ← phi( main::@2/(byte) cnt2#3 )
(byte) cnt#11 ← phi( main::@2/(byte) cnt#4 )
(byte) cnt#5 ← (byte) cnt#11
(byte) cnt2#4 ← (byte) cnt2#10
(byte) cnt3#4 ← (byte) cnt3#10
return
to:@return
inccnt: scope:[inccnt] from main main::@1
(byte) cnt3#11 ← phi( main/(byte) cnt3#13 main::@1/(byte) cnt3#2 )
(byte) cnt2#11 ← phi( main/(byte) cnt2#13 main::@1/(byte) cnt2#2 )
(byte) cnt#12 ← phi( main/(byte) cnt#14 main::@1/(byte) cnt#3 )
(byte) cnt#6 ← ++ (byte) cnt#12
(byte) cnt2#5 ← ++ (byte) cnt2#11
(byte) cnt3#5 ← ++ (byte) cnt3#11
(byte) inccnt::return#2 ← (byte) cnt#6
to:inccnt::@return
inccnt::@return: scope:[inccnt] from inccnt
(byte) cnt3#12 ← phi( inccnt/(byte) cnt3#5 )
(byte) cnt2#12 ← phi( inccnt/(byte) cnt2#5 )
(byte) cnt#13 ← phi( inccnt/(byte) cnt#6 )
(byte) inccnt::return#6 ← phi( inccnt/(byte) inccnt::return#2 )
(byte) inccnt::return#3 ← (byte) inccnt::return#6
(byte) cnt#7 ← (byte) cnt#13
(byte) cnt2#6 ← (byte) cnt2#12
(byte) cnt3#6 ← (byte) cnt3#12
return
to:@return
@end: scope:[] from @3
Not aliassing across scopes: main::$0 inccnt::return#4 Not aliassing across scopes: main::$0 inccnt::return#4
Not aliassing across scopes: main::$1 inccnt::return#5 Not aliassing across scopes: main::$1 inccnt::return#5
Not aliassing across scopes: inccnt::return#2 cnt#6 Not aliassing across scopes: inccnt::return#2 cnt#6
Alias (byte) cnt#1 = (byte) cnt#8 (byte) cnt#5 (byte) cnt#9 (byte) cnt#7 (byte) cnt#2 (byte) cnt#10 (byte) cnt#4 (byte) cnt#11 (byte) cnt#13 (byte) cnt#6 Alias (byte) cnt#1 = (byte) cnt#8 (byte) cnt#5 (byte) cnt#9 (byte) cnt#7 (byte) cnt#2 (byte) cnt#10 (byte) cnt#4 (byte) cnt#11 (byte) cnt#13 (byte) cnt#6
Alias (byte) cnt2#1 = (byte) cnt2#7 (byte) cnt2#4 (byte) cnt2#8 (byte) cnt2#6 (byte) cnt2#2 (byte) cnt2#9 (byte) cnt2#3 (byte) cnt2#10 (byte) cnt2#12 (byte) cnt2#5 Alias (byte) cnt2#1 = (byte) cnt2#7 (byte) cnt2#4 (byte) cnt2#8 (byte) cnt2#6 (byte) cnt2#2 (byte) cnt2#9 (byte) cnt2#3 (byte) cnt2#10 (byte) cnt2#12 (byte) cnt2#5
Alias (byte) cnt3#1 = (byte) cnt3#7 (byte) cnt3#4 (byte) cnt3#8 (byte) cnt3#6 (byte) cnt3#2 (byte) cnt3#9 (byte) cnt3#3 (byte) cnt3#10 (byte) cnt3#12 (byte) cnt3#5 Alias (byte) cnt3#1 = (byte) cnt3#7 (byte) cnt3#4 (byte) cnt3#8 (byte) cnt3#6 (byte) cnt3#2 (byte) cnt3#9 (byte) cnt3#3 (byte) cnt3#10 (byte) cnt3#12 (byte) cnt3#5
Alias (byte) cnt#0 = (byte) cnt#14
Alias (byte) cnt2#0 = (byte) cnt2#13
Alias (byte) cnt3#0 = (byte) cnt3#13
Alias (byte[256]) SCREEN#0 = (byte[256]) SCREEN#3 (byte[256]) SCREEN#1 (byte[256]) SCREEN#2
Alias (byte) inccnt::return#0 = (byte) inccnt::return#3 (byte) inccnt::return#4 (byte) inccnt::return#1 (byte) inccnt::return#5 (byte) inccnt::return#6 (byte) inccnt::return#2 Alias (byte) inccnt::return#0 = (byte) inccnt::return#3 (byte) inccnt::return#4 (byte) inccnt::return#1 (byte) inccnt::return#5 (byte) inccnt::return#6 (byte) inccnt::return#2
Alias (byte[256]) SCREEN#1 = (byte[256]) SCREEN#3 (byte[256]) SCREEN#2
Succesful SSA optimization Pass2AliasElimination Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
(byte) cnt#0 ← (byte) 0
(byte) cnt2#0 ← (byte) 0
(byte) cnt3#0 ← (byte) 0
(byte[256]) SCREEN#0 ← (word) 1024
call main param-assignment call main param-assignment
to:@3 to:@3
@3: scope:[] from @begin @3: scope:[] from @begin
to:@end to:@end
main: scope:[main] from @begin main: scope:[main] from @begin
(byte[256]) SCREEN#1 ← phi( @begin/(word) 1024 )
(byte) cnt3#13 ← phi( @begin/(byte) 0 )
(byte) cnt2#13 ← phi( @begin/(byte) 0 )
(byte) cnt#14 ← phi( @begin/(byte) 0 )
call inccnt param-assignment call inccnt param-assignment
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
(byte~) main::$0 ← (byte) inccnt::return#0 (byte~) main::$0 ← (byte) inccnt::return#0
*((byte[256]) SCREEN#1 + (byte) 0) ← (byte~) main::$0 *((byte[256]) SCREEN#0 + (byte) 0) ← (byte~) main::$0
(byte) cnt#3 ← ++ (byte) cnt#1 (byte) cnt#3 ← ++ (byte) cnt#1
call inccnt param-assignment call inccnt param-assignment
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte~) main::$1 ← (byte) inccnt::return#0 (byte~) main::$1 ← (byte) inccnt::return#0
*((byte[256]) SCREEN#1 + (byte) 1) ← (byte~) main::$1 *((byte[256]) SCREEN#0 + (byte) 1) ← (byte~) main::$1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
inccnt: scope:[inccnt] from main main::@1 inccnt: scope:[inccnt] from main main::@1
(byte) cnt3#11 ← phi( main/(byte) cnt3#13 main::@1/(byte) cnt3#1 ) (byte) cnt3#11 ← phi( main/(byte) cnt3#0 main::@1/(byte) cnt3#1 )
(byte) cnt2#11 ← phi( main/(byte) cnt2#13 main::@1/(byte) cnt2#1 ) (byte) cnt2#11 ← phi( main/(byte) cnt2#0 main::@1/(byte) cnt2#1 )
(byte) cnt#12 ← phi( main/(byte) cnt#14 main::@1/(byte) cnt#3 ) (byte) cnt#12 ← phi( main/(byte) cnt#0 main::@1/(byte) cnt#3 )
(byte) cnt#1 ← ++ (byte) cnt#12 (byte) cnt#1 ← ++ (byte) cnt#12
(byte) cnt2#1 ← ++ (byte) cnt2#11 (byte) cnt2#1 ← ++ (byte) cnt2#11
(byte) cnt3#1 ← ++ (byte) cnt3#11 (byte) cnt3#1 ← ++ (byte) cnt3#11
@ -563,11 +483,14 @@ inccnt::@return: scope:[inccnt] from inccnt
to:@return to:@return
@end: scope:[] from @3 @end: scope:[] from @3
Redundant Phi (byte) cnt#14 (byte) 0 Not aliassing across scopes: main::$0 inccnt::return#0
Redundant Phi (byte) cnt2#13 (byte) 0 Not aliassing across scopes: main::$1 inccnt::return#0
Redundant Phi (byte) cnt3#13 (byte) 0 Not aliassing across scopes: inccnt::return#0 cnt#1
Redundant Phi (byte[256]) SCREEN#1 (word) 1024 Constant (const byte) cnt#0 = 0
Succesful SSA optimization Pass2RedundantPhiElimination Constant (const byte) cnt2#0 = 0
Constant (const byte) cnt3#0 = 0
Constant (const byte[256]) SCREEN#0 = 1024
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -579,21 +502,60 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
(byte~) main::$0 ← (byte) inccnt::return#0 (byte~) main::$0 ← (byte) inccnt::return#0
*((word) 1024 + (byte) 0) ← (byte~) main::$0 *((const byte[256]) SCREEN#0 + (byte) 0) ← (byte~) main::$0
(byte) cnt#3 ← ++ (byte) cnt#1 (byte) cnt#3 ← ++ (byte) cnt#1
call inccnt param-assignment call inccnt param-assignment
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte~) main::$1 ← (byte) inccnt::return#0 (byte~) main::$1 ← (byte) inccnt::return#0
*((word) 1024 + (byte) 1) ← (byte~) main::$1 *((const byte[256]) SCREEN#0 + (byte) 1) ← (byte~) main::$1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
inccnt: scope:[inccnt] from main main::@1 inccnt: scope:[inccnt] from main main::@1
(byte) cnt3#11 ← phi( main/(byte) 0 main::@1/(byte) cnt3#1 ) (byte) cnt3#11 ← phi( main/(const byte) cnt3#0 main::@1/(byte) cnt3#1 )
(byte) cnt2#11 ← phi( main/(byte) 0 main::@1/(byte) cnt2#1 ) (byte) cnt2#11 ← phi( main/(const byte) cnt2#0 main::@1/(byte) cnt2#1 )
(byte) cnt#12 ← phi( main/(byte) 0 main::@1/(byte) cnt#3 ) (byte) cnt#12 ← phi( main/(const byte) cnt#0 main::@1/(byte) cnt#3 )
(byte) cnt#1 ← ++ (byte) cnt#12
(byte) cnt2#1 ← ++ (byte) cnt2#11
(byte) cnt3#1 ← ++ (byte) cnt3#11
(byte) inccnt::return#0 ← (byte) cnt#1
to:inccnt::@return
inccnt::@return: scope:[inccnt] from inccnt
return
to:@return
@end: scope:[] from @3
Consolidated assigned array index constant in assignment *(SCREEN#0+0)
Consolidated assigned array index constant in assignment *(SCREEN#0+1)
Succesful SSA optimization Pass2ConstantAdditionElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@3
@3: scope:[] from @begin
to:@end
main: scope:[main] from @begin
call inccnt param-assignment
to:main::@1
main::@1: scope:[main] from main
(byte~) main::$0 ← (byte) inccnt::return#0
*((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0
(byte) cnt#3 ← ++ (byte) cnt#1
call inccnt param-assignment
to:main::@2
main::@2: scope:[main] from main::@1
(byte~) main::$1 ← (byte) inccnt::return#0
*((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
inccnt: scope:[inccnt] from main main::@1
(byte) cnt3#11 ← phi( main/(const byte) cnt3#0 main::@1/(byte) cnt3#1 )
(byte) cnt2#11 ← phi( main/(const byte) cnt2#0 main::@1/(byte) cnt2#1 )
(byte) cnt#12 ← phi( main/(const byte) cnt#0 main::@1/(byte) cnt#3 )
(byte) cnt#1 ← ++ (byte) cnt#12 (byte) cnt#1 ← ++ (byte) cnt#12
(byte) cnt2#1 ← ++ (byte) cnt2#11 (byte) cnt2#1 ← ++ (byte) cnt2#11
(byte) cnt3#1 ← ++ (byte) cnt3#11 (byte) cnt3#1 ← ++ (byte) cnt3#11
@ -615,21 +577,21 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
(byte~) main::$0 ← (byte) inccnt::return#0 (byte~) main::$0 ← (byte) inccnt::return#0
*((word) 1024 + (byte) 0) ← (byte~) main::$0 *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0
(byte) cnt#3 ← ++ (byte) cnt#1 (byte) cnt#3 ← ++ (byte) cnt#1
call inccnt param-assignment call inccnt param-assignment
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte~) main::$1 ← (byte) inccnt::return#0 (byte~) main::$1 ← (byte) inccnt::return#0
*((word) 1024 + (byte) 1) ← (byte~) main::$1 *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
inccnt: scope:[inccnt] from main main::@1 inccnt: scope:[inccnt] from main main::@1
(byte) cnt3#11 ← phi( main/(byte) 0 main::@1/(byte) cnt3#1 ) (byte) cnt3#11 ← phi( main/(const byte) cnt3#0 main::@1/(byte) cnt3#1 )
(byte) cnt2#11 ← phi( main/(byte) 0 main::@1/(byte) cnt2#1 ) (byte) cnt2#11 ← phi( main/(const byte) cnt2#0 main::@1/(byte) cnt2#1 )
(byte) cnt#12 ← phi( main/(byte) 0 main::@1/(byte) cnt#3 ) (byte) cnt#12 ← phi( main/(const byte) cnt#0 main::@1/(byte) cnt#3 )
(byte) cnt#1 ← ++ (byte) cnt#12 (byte) cnt#1 ← ++ (byte) cnt#12
(byte) cnt2#1 ← ++ (byte) cnt2#11 (byte) cnt2#1 ← ++ (byte) cnt2#11
(byte) cnt3#1 ← ++ (byte) cnt3#11 (byte) cnt3#1 ← ++ (byte) cnt3#11
@ -640,9 +602,16 @@ inccnt::@return: scope:[inccnt] from inccnt
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Consolidated assigned array index constant in assignment *(1024) Not aliassing across scopes: main::$0 inccnt::return#0
Consolidated assigned array index constant in assignment *(1025) Not aliassing across scopes: main::$1 inccnt::return#0
Succesful SSA optimization Pass2ConstantAdditionElimination Not aliassing across scopes: inccnt::return#0 cnt#1
Not aliassing across scopes: main::$0 inccnt::return#0
Not aliassing across scopes: main::$1 inccnt::return#0
Not aliassing across scopes: inccnt::return#0 cnt#1
Constant inlined cnt#0 = (byte) 0
Constant inlined cnt3#0 = (byte) 0
Constant inlined cnt2#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -652,13 +621,13 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
(byte~) main::$0 ← (byte) inccnt::return#0 (byte~) main::$0 ← (byte) inccnt::return#0
*((word) 1024) ← (byte~) main::$0 *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0
(byte) cnt#3 ← ++ (byte) cnt#1 (byte) cnt#3 ← ++ (byte) cnt#1
call inccnt param-assignment call inccnt param-assignment
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte~) main::$1 ← (byte) inccnt::return#0 (byte~) main::$1 ← (byte) inccnt::return#0
*((word) 1025) ← (byte~) main::$1 *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
@ -677,16 +646,11 @@ inccnt::@return: scope:[inccnt] from inccnt
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Not aliassing across scopes: main::$0 inccnt::return#0
Not aliassing across scopes: main::$1 inccnt::return#0
Not aliassing across scopes: inccnt::return#0 cnt#1
Not aliassing across scopes: main::$0 inccnt::return#0
Not aliassing across scopes: main::$1 inccnt::return#0
Not aliassing across scopes: inccnt::return#0 cnt#1
FINAL SYMBOL TABLE FINAL SYMBOL TABLE
(label) @begin (label) @begin
(label) @end (label) @end
(byte[256]) SCREEN (byte[256]) SCREEN
(const byte[256]) SCREEN#0 = (word) 1024
(byte) cnt (byte) cnt
(byte) cnt#1 (byte) cnt#1
(byte) cnt#12 (byte) cnt#12
@ -720,7 +684,7 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
(byte~) main::$0 ← (byte) inccnt::return#0 (byte~) main::$0 ← (byte) inccnt::return#0
*((word) 1024) ← (byte~) main::$0 *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0
(byte) cnt#3 ← ++ (byte) cnt#1 (byte) cnt#3 ← ++ (byte) cnt#1
(byte~) cnt#15 ← (byte) cnt#3 (byte~) cnt#15 ← (byte) cnt#3
(byte~) cnt2#14 ← (byte) cnt2#1 (byte~) cnt2#14 ← (byte) cnt2#1
@ -729,7 +693,7 @@ main::@1: scope:[main] from main
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte~) main::$1 ← (byte) inccnt::return#0 (byte~) main::$1 ← (byte) inccnt::return#0
*((word) 1025) ← (byte~) main::$1 *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
@ -772,7 +736,7 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
[3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ]
[4] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] [4] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ]
[5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ]
[6] (byte~) cnt#15 ← (byte) cnt#3 [ cnt#15 cnt2#1 cnt3#1 ] [6] (byte~) cnt#15 ← (byte) cnt#3 [ cnt#15 cnt2#1 cnt3#1 ]
[7] (byte~) cnt2#14 ← (byte) cnt2#1 [ cnt#15 cnt2#14 cnt3#1 ] [7] (byte~) cnt2#14 ← (byte) cnt2#1 [ cnt#15 cnt2#14 cnt3#1 ]
@ -781,7 +745,7 @@ main::@1: scope:[main] from main
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
[10] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ] [10] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ]
[11] *((word) 1025) ← (byte~) main::$1 [ ] [11] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1 [ ]
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
[12] return [ ] [12] return [ ]
@ -825,13 +789,13 @@ main: scope:[main] from @begin
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
[3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ]
[4] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] [4] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ]
[5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ]
[6] call inccnt param-assignment [ inccnt::return#0 ] [6] call inccnt param-assignment [ inccnt::return#0 ]
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
[7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ] [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ]
[8] *((word) 1025) ← (byte~) main::$1 [ ] [8] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1 [ ]
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
[9] return [ ] [9] return [ ]
@ -910,7 +874,8 @@ Allocated zp ZP_BYTE:6 [ main::$1 ]
Allocated zp ZP_BYTE:7 [ cnt#1 ] Allocated zp ZP_BYTE:7 [ cnt#1 ]
Allocated zp ZP_BYTE:8 [ inccnt::return#0 ] Allocated zp ZP_BYTE:8 [ inccnt::return#0 ]
INITIAL ASM INITIAL ASM
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
.label cnt = 7 .label cnt = 7
.label cnt2 = 3 .label cnt2 = 3
.label cnt3 = 4 .label cnt3 = 4
@ -948,9 +913,9 @@ main: {
//SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] -- zpby1=zpby2 //SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] -- zpby1=zpby2
lda inccnt.return lda inccnt.return
sta _0 sta _0
//SEG13 [4] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=zpby1 //SEG13 [4] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=zpby1
lda _0 lda _0
sta $400 sta SCREEN+$0
//SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- zpby1=_inc_zpby2 //SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- zpby1=_inc_zpby2
lda cnt lda cnt
sta cnt_3 sta cnt_3
@ -968,9 +933,9 @@ main: {
//SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ] -- zpby1=zpby2 //SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ] -- zpby1=zpby2
lda inccnt.return lda inccnt.return
sta _1 sta _1
//SEG22 [8] *((word) 1025) ← (byte~) main::$1 [ ] -- _star_cowo1=zpby1 //SEG22 [8] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1 [ ] -- _star_cowo1=zpby1
lda _1 lda _1
sta $401 sta SCREEN+$1
jmp breturn jmp breturn
//SEG23 main::@return //SEG23 main::@return
breturn: breturn:
@ -1025,7 +990,8 @@ Removing instruction jmp breturn
Removing instruction jmp breturn Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
.label cnt3 = 2 .label cnt3 = 2
//SEG1 @begin //SEG1 @begin
bbegin: bbegin:
@ -1052,8 +1018,8 @@ main: {
b1: b1:
//SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] //SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ]
// (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a // (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a
//SEG13 [4] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=aby //SEG13 [4] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=aby
sta $400 sta SCREEN+$0
//SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- xby=_inc_xby //SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- xby=_inc_xby
inx inx
//SEG15 [6] call inccnt param-assignment [ inccnt::return#0 ] //SEG15 [6] call inccnt param-assignment [ inccnt::return#0 ]
@ -1067,8 +1033,8 @@ main: {
b2: b2:
//SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ] //SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ]
// (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a // (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a
//SEG22 [8] *((word) 1025) ← (byte~) main::$1 [ ] -- _star_cowo1=aby //SEG22 [8] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1 [ ] -- _star_cowo1=aby
sta $401 sta SCREEN+$1
//SEG23 main::@return //SEG23 main::@return
breturn: breturn:
//SEG24 [9] return [ ] //SEG24 [9] return [ ]
@ -1093,7 +1059,8 @@ inccnt: {
Removing instruction main_from_bbegin: Removing instruction main_from_bbegin:
Succesful ASM optimization Pass5RedundantLabelElimination Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
.label cnt3 = 2 .label cnt3 = 2
//SEG1 @begin //SEG1 @begin
bbegin: bbegin:
@ -1119,8 +1086,8 @@ main: {
b1: b1:
//SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] //SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ]
// (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a // (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a
//SEG13 [4] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=aby //SEG13 [4] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=aby
sta $400 sta SCREEN+$0
//SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- xby=_inc_xby //SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- xby=_inc_xby
inx inx
//SEG15 [6] call inccnt param-assignment [ inccnt::return#0 ] //SEG15 [6] call inccnt param-assignment [ inccnt::return#0 ]
@ -1134,8 +1101,8 @@ main: {
b2: b2:
//SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ] //SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ]
// (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a // (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a
//SEG22 [8] *((word) 1025) ← (byte~) main::$1 [ ] -- _star_cowo1=aby //SEG22 [8] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1 [ ] -- _star_cowo1=aby
sta $401 sta SCREEN+$1
//SEG23 main::@return //SEG23 main::@return
breturn: breturn:
//SEG24 [9] return [ ] //SEG24 [9] return [ ]
@ -1167,7 +1134,8 @@ Removing instruction breturn:
Removing instruction breturn: Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
.label cnt3 = 2 .label cnt3 = 2
//SEG1 @begin //SEG1 @begin
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
@ -1189,8 +1157,8 @@ main: {
//SEG11 main::@1 //SEG11 main::@1
//SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] //SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ]
// (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a // (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a
//SEG13 [4] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=aby //SEG13 [4] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=aby
sta $400 sta SCREEN+$0
//SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- xby=_inc_xby //SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- xby=_inc_xby
inx inx
//SEG15 [6] call inccnt param-assignment [ inccnt::return#0 ] //SEG15 [6] call inccnt param-assignment [ inccnt::return#0 ]
@ -1202,8 +1170,8 @@ main: {
//SEG20 main::@2 //SEG20 main::@2
//SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ] //SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ]
// (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a // (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a
//SEG22 [8] *((word) 1025) ← (byte~) main::$1 [ ] -- _star_cowo1=aby //SEG22 [8] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1 [ ] -- _star_cowo1=aby
sta $401 sta SCREEN+$1
//SEG23 main::@return //SEG23 main::@return
//SEG24 [9] return [ ] //SEG24 [9] return [ ]
rts rts
@ -1227,6 +1195,7 @@ FINAL SYMBOL TABLE
(label) @begin (label) @begin
(label) @end (label) @end
(byte[256]) SCREEN (byte[256]) SCREEN
(const byte[256]) SCREEN#0 = (word) 1024
(byte) cnt (byte) cnt
(byte) cnt#1 reg byte x 0.75 (byte) cnt#1 reg byte x 0.75
(byte) cnt#12 reg byte x 4.0 (byte) cnt#12 reg byte x 4.0
@ -1257,7 +1226,8 @@ reg byte x [ cnt#1 ]
reg byte a [ inccnt::return#0 ] reg byte a [ inccnt::return#0 ]
FINAL CODE FINAL CODE
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
.label cnt3 = 2 .label cnt3 = 2
//SEG1 @begin //SEG1 @begin
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
@ -1279,8 +1249,8 @@ main: {
//SEG11 main::@1 //SEG11 main::@1
//SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] //SEG12 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ]
// (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a // (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a
//SEG13 [4] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=aby //SEG13 [4] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte~) main::$0 [ cnt#1 cnt2#1 cnt3#1 ] -- _star_cowo1=aby
sta $400 sta SCREEN+$0
//SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- xby=_inc_xby //SEG14 [5] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 cnt3#1 ] -- xby=_inc_xby
inx inx
//SEG15 [6] call inccnt param-assignment [ inccnt::return#0 ] //SEG15 [6] call inccnt param-assignment [ inccnt::return#0 ]
@ -1292,8 +1262,8 @@ main: {
//SEG20 main::@2 //SEG20 main::@2
//SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ] //SEG21 [7] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ]
// (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a // (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a
//SEG22 [8] *((word) 1025) ← (byte~) main::$1 [ ] -- _star_cowo1=aby //SEG22 [8] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte~) main::$1 [ ] -- _star_cowo1=aby
sta $401 sta SCREEN+$1
//SEG23 main::@return //SEG23 main::@return
//SEG24 [9] return [ ] //SEG24 [9] return [ ]
rts rts

View File

@ -1,6 +1,7 @@
(label) @begin (label) @begin
(label) @end (label) @end
(byte[256]) SCREEN (byte[256]) SCREEN
(const byte[256]) SCREEN#0 = (word) 1024
(byte) cnt (byte) cnt
(byte) cnt#1 reg byte x 0.75 (byte) cnt#1 reg byte x 0.75
(byte) cnt#12 reg byte x 4.0 (byte) cnt#12 reg byte x 4.0

View File

@ -1,12 +1,13 @@
.const SCREEN = $400
jsr main jsr main
main: { main: {
ldx #$0 ldx #$0
jsr inccnt jsr inccnt
stx $400 stx SCREEN+$0
inx inx
jsr inccnt jsr inccnt
inx inx
stx $401 stx SCREEN+$1
rts rts
} }
inccnt: { inccnt: {

View File

@ -7,13 +7,13 @@ main: scope:[main] from @begin
[2] call inccnt param-assignment [ cnt#10 ] [2] call inccnt param-assignment [ cnt#10 ]
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
[3] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] [3] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10 [ cnt#10 ]
[4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ]
[5] call inccnt param-assignment [ cnt#10 ] [5] call inccnt param-assignment [ cnt#10 ]
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
[6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ]
[7] *((word) 1025) ← (byte) cnt#1 [ ] [7] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1 [ ]
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
[8] return [ ] [8] return [ ]

View File

@ -274,82 +274,36 @@ INITIAL SSA SYMBOL TABLE
(label) main::@2 (label) main::@2
(label) main::@return (label) main::@return
Constant (byte) cnt#0 (byte) 0
Constant (byte[256]) SCREEN#0 (word) 1024
Succesful SSA optimization Pass2ConstantPropagation
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@3
@3: scope:[] from @begin
(byte) cnt#9 ← phi( @begin/(byte) cnt#6 )
(byte) cnt#1 ← (byte) cnt#9
to:@end
main: scope:[main] from @begin
(byte[256]) SCREEN#3 ← phi( @begin/(word) 1024 )
(byte) cnt#15 ← phi( @begin/(byte) 0 )
call inccnt param-assignment
to:main::@1
main::@1: scope:[main] from main
(byte[256]) SCREEN#1 ← phi( main/(byte[256]) SCREEN#3 )
(byte) cnt#10 ← phi( main/(byte) cnt#8 )
(byte) cnt#2 ← (byte) cnt#10
*((byte[256]) SCREEN#1 + (byte) 0) ← (byte) cnt#2
(byte) cnt#3 ← ++ (byte) cnt#2
call inccnt param-assignment
to:main::@2
main::@2: scope:[main] from main::@1
(byte[256]) SCREEN#2 ← phi( main::@1/(byte[256]) SCREEN#1 )
(byte) cnt#11 ← phi( main::@1/(byte) cnt#8 )
(byte) cnt#4 ← (byte) cnt#11
(byte) cnt#5 ← ++ (byte) cnt#4
*((byte[256]) SCREEN#2 + (byte) 1) ← (byte) cnt#5
to:main::@return
main::@return: scope:[main] from main::@2
(byte) cnt#12 ← phi( main::@2/(byte) cnt#5 )
(byte) cnt#6 ← (byte) cnt#12
return
to:@return
inccnt: scope:[inccnt] from main main::@1
(byte) cnt#13 ← phi( main/(byte) cnt#15 main::@1/(byte) cnt#3 )
(byte) cnt#7 ← ++ (byte) cnt#13
to:inccnt::@return
inccnt::@return: scope:[inccnt] from inccnt
(byte) cnt#14 ← phi( inccnt/(byte) cnt#7 )
(byte) cnt#8 ← (byte) cnt#14
return
to:@return
@end: scope:[] from @3
Alias (byte) cnt#1 = (byte) cnt#9 (byte) cnt#6 (byte) cnt#12 (byte) cnt#5 Alias (byte) cnt#1 = (byte) cnt#9 (byte) cnt#6 (byte) cnt#12 (byte) cnt#5
Alias (byte) cnt#0 = (byte) cnt#15
Alias (byte[256]) SCREEN#0 = (byte[256]) SCREEN#3 (byte[256]) SCREEN#1 (byte[256]) SCREEN#2
Alias (byte) cnt#10 = (byte) cnt#8 (byte) cnt#2 (byte) cnt#11 (byte) cnt#4 (byte) cnt#14 (byte) cnt#7 Alias (byte) cnt#10 = (byte) cnt#8 (byte) cnt#2 (byte) cnt#11 (byte) cnt#4 (byte) cnt#14 (byte) cnt#7
Alias (byte[256]) SCREEN#1 = (byte[256]) SCREEN#3 (byte[256]) SCREEN#2
Succesful SSA optimization Pass2AliasElimination Succesful SSA optimization Pass2AliasElimination
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
(byte) cnt#0 ← (byte) 0
(byte[256]) SCREEN#0 ← (word) 1024
call main param-assignment call main param-assignment
to:@3 to:@3
@3: scope:[] from @begin @3: scope:[] from @begin
to:@end to:@end
main: scope:[main] from @begin main: scope:[main] from @begin
(byte[256]) SCREEN#1 ← phi( @begin/(word) 1024 )
(byte) cnt#15 ← phi( @begin/(byte) 0 )
call inccnt param-assignment call inccnt param-assignment
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
*((byte[256]) SCREEN#1 + (byte) 0) ← (byte) cnt#10 *((byte[256]) SCREEN#0 + (byte) 0) ← (byte) cnt#10
(byte) cnt#3 ← ++ (byte) cnt#10 (byte) cnt#3 ← ++ (byte) cnt#10
call inccnt param-assignment call inccnt param-assignment
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte) cnt#1 ← ++ (byte) cnt#10 (byte) cnt#1 ← ++ (byte) cnt#10
*((byte[256]) SCREEN#1 + (byte) 1) ← (byte) cnt#1 *((byte[256]) SCREEN#0 + (byte) 1) ← (byte) cnt#1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
inccnt: scope:[inccnt] from main main::@1 inccnt: scope:[inccnt] from main main::@1
(byte) cnt#13 ← phi( main/(byte) cnt#15 main::@1/(byte) cnt#3 ) (byte) cnt#13 ← phi( main/(byte) cnt#0 main::@1/(byte) cnt#3 )
(byte) cnt#10 ← ++ (byte) cnt#13 (byte) cnt#10 ← ++ (byte) cnt#13
to:inccnt::@return to:inccnt::@return
inccnt::@return: scope:[inccnt] from inccnt inccnt::@return: scope:[inccnt] from inccnt
@ -357,9 +311,9 @@ inccnt::@return: scope:[inccnt] from inccnt
to:@return to:@return
@end: scope:[] from @3 @end: scope:[] from @3
Redundant Phi (byte) cnt#15 (byte) 0 Constant (const byte) cnt#0 = 0
Redundant Phi (byte[256]) SCREEN#1 (word) 1024 Constant (const byte[256]) SCREEN#0 = 1024
Succesful SSA optimization Pass2RedundantPhiElimination Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -370,19 +324,52 @@ main: scope:[main] from @begin
call inccnt param-assignment call inccnt param-assignment
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
*((word) 1024 + (byte) 0) ← (byte) cnt#10 *((const byte[256]) SCREEN#0 + (byte) 0) ← (byte) cnt#10
(byte) cnt#3 ← ++ (byte) cnt#10 (byte) cnt#3 ← ++ (byte) cnt#10
call inccnt param-assignment call inccnt param-assignment
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte) cnt#1 ← ++ (byte) cnt#10 (byte) cnt#1 ← ++ (byte) cnt#10
*((word) 1024 + (byte) 1) ← (byte) cnt#1 *((const byte[256]) SCREEN#0 + (byte) 1) ← (byte) cnt#1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
inccnt: scope:[inccnt] from main main::@1 inccnt: scope:[inccnt] from main main::@1
(byte) cnt#13 ← phi( main/(byte) 0 main::@1/(byte) cnt#3 ) (byte) cnt#13 ← phi( main/(const byte) cnt#0 main::@1/(byte) cnt#3 )
(byte) cnt#10 ← ++ (byte) cnt#13
to:inccnt::@return
inccnt::@return: scope:[inccnt] from inccnt
return
to:@return
@end: scope:[] from @3
Consolidated assigned array index constant in assignment *(SCREEN#0+0)
Consolidated assigned array index constant in assignment *(SCREEN#0+1)
Succesful SSA optimization Pass2ConstantAdditionElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
call main param-assignment
to:@3
@3: scope:[] from @begin
to:@end
main: scope:[main] from @begin
call inccnt param-assignment
to:main::@1
main::@1: scope:[main] from main
*((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10
(byte) cnt#3 ← ++ (byte) cnt#10
call inccnt param-assignment
to:main::@2
main::@2: scope:[main] from main::@1
(byte) cnt#1 ← ++ (byte) cnt#10
*((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
inccnt: scope:[inccnt] from main main::@1
(byte) cnt#13 ← phi( main/(const byte) cnt#0 main::@1/(byte) cnt#3 )
(byte) cnt#10 ← ++ (byte) cnt#13 (byte) cnt#10 ← ++ (byte) cnt#13
to:inccnt::@return to:inccnt::@return
inccnt::@return: scope:[inccnt] from inccnt inccnt::@return: scope:[inccnt] from inccnt
@ -400,19 +387,19 @@ main: scope:[main] from @begin
call inccnt param-assignment call inccnt param-assignment
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
*((word) 1024 + (byte) 0) ← (byte) cnt#10 *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10
(byte) cnt#3 ← ++ (byte) cnt#10 (byte) cnt#3 ← ++ (byte) cnt#10
call inccnt param-assignment call inccnt param-assignment
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte) cnt#1 ← ++ (byte) cnt#10 (byte) cnt#1 ← ++ (byte) cnt#10
*((word) 1024 + (byte) 1) ← (byte) cnt#1 *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
to:@return to:@return
inccnt: scope:[inccnt] from main main::@1 inccnt: scope:[inccnt] from main main::@1
(byte) cnt#13 ← phi( main/(byte) 0 main::@1/(byte) cnt#3 ) (byte) cnt#13 ← phi( main/(const byte) cnt#0 main::@1/(byte) cnt#3 )
(byte) cnt#10 ← ++ (byte) cnt#13 (byte) cnt#10 ← ++ (byte) cnt#13
to:inccnt::@return to:inccnt::@return
inccnt::@return: scope:[inccnt] from inccnt inccnt::@return: scope:[inccnt] from inccnt
@ -420,9 +407,8 @@ inccnt::@return: scope:[inccnt] from inccnt
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Consolidated assigned array index constant in assignment *(1024) Constant inlined cnt#0 = (byte) 0
Consolidated assigned array index constant in assignment *(1025) Succesful SSA optimization Pass2ConstantInlining
Succesful SSA optimization Pass2ConstantAdditionElimination
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -431,13 +417,13 @@ main: scope:[main] from @begin
call inccnt param-assignment call inccnt param-assignment
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
*((word) 1024) ← (byte) cnt#10 *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10
(byte) cnt#3 ← ++ (byte) cnt#10 (byte) cnt#3 ← ++ (byte) cnt#10
call inccnt param-assignment call inccnt param-assignment
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte) cnt#1 ← ++ (byte) cnt#10 (byte) cnt#1 ← ++ (byte) cnt#10
*((word) 1025) ← (byte) cnt#1 *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
@ -455,6 +441,7 @@ FINAL SYMBOL TABLE
(label) @begin (label) @begin
(label) @end (label) @end
(byte[256]) SCREEN (byte[256]) SCREEN
(const byte[256]) SCREEN#0 = (word) 1024
(byte) cnt (byte) cnt
(byte) cnt#1 (byte) cnt#1
(byte) cnt#10 (byte) cnt#10
@ -478,14 +465,14 @@ main: scope:[main] from @begin
call inccnt param-assignment call inccnt param-assignment
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
*((word) 1024) ← (byte) cnt#10 *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10
(byte) cnt#3 ← ++ (byte) cnt#10 (byte) cnt#3 ← ++ (byte) cnt#10
(byte~) cnt#16 ← (byte) cnt#3 (byte~) cnt#16 ← (byte) cnt#3
call inccnt param-assignment call inccnt param-assignment
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte) cnt#1 ← ++ (byte) cnt#10 (byte) cnt#1 ← ++ (byte) cnt#10
*((word) 1025) ← (byte) cnt#1 *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
return return
@ -516,14 +503,14 @@ main: scope:[main] from @begin
[2] call inccnt param-assignment [ cnt#10 ] [2] call inccnt param-assignment [ cnt#10 ]
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
[3] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] [3] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10 [ cnt#10 ]
[4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ]
[5] (byte~) cnt#16 ← (byte) cnt#3 [ cnt#16 ] [5] (byte~) cnt#16 ← (byte) cnt#3 [ cnt#16 ]
[6] call inccnt param-assignment [ cnt#10 ] [6] call inccnt param-assignment [ cnt#10 ]
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
[7] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] [7] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ]
[8] *((word) 1025) ← (byte) cnt#1 [ ] [8] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1 [ ]
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
[9] return [ ] [9] return [ ]
@ -554,13 +541,13 @@ main: scope:[main] from @begin
[2] call inccnt param-assignment [ cnt#10 ] [2] call inccnt param-assignment [ cnt#10 ]
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@1: scope:[main] from main
[3] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] [3] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10 [ cnt#10 ]
[4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ]
[5] call inccnt param-assignment [ cnt#10 ] [5] call inccnt param-assignment [ cnt#10 ]
to:main::@2 to:main::@2
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
[6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ]
[7] *((word) 1025) ← (byte) cnt#1 [ ] [7] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1 [ ]
to:main::@return to:main::@return
main::@return: scope:[main] from main::@2 main::@return: scope:[main] from main::@2
[8] return [ ] [8] return [ ]
@ -613,7 +600,8 @@ Allocated zp ZP_BYTE:2 [ cnt#13 cnt#3 ]
Allocated zp ZP_BYTE:3 [ cnt#1 ] Allocated zp ZP_BYTE:3 [ cnt#1 ]
Allocated zp ZP_BYTE:4 [ cnt#10 ] Allocated zp ZP_BYTE:4 [ cnt#10 ]
INITIAL ASM INITIAL ASM
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
.label cnt = 3 .label cnt = 3
.label cnt_3 = 2 .label cnt_3 = 2
.label cnt_10 = 4 .label cnt_10 = 4
@ -639,9 +627,9 @@ main: {
jmp b1 jmp b1
//SEG9 main::@1 //SEG9 main::@1
b1: b1:
//SEG10 [3] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=zpby1 //SEG10 [3] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=zpby1
lda cnt_10 lda cnt_10
sta $400 sta SCREEN+$0
//SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- zpby1=_inc_zpby2 //SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- zpby1=_inc_zpby2
lda cnt_10 lda cnt_10
sta cnt_3 sta cnt_3
@ -658,9 +646,9 @@ main: {
lda cnt_10 lda cnt_10
sta cnt sta cnt
inc cnt inc cnt
//SEG17 [7] *((word) 1025) ← (byte) cnt#1 [ ] -- _star_cowo1=zpby1 //SEG17 [7] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1 [ ] -- _star_cowo1=zpby1
lda cnt lda cnt
sta $401 sta SCREEN+$1
jmp breturn jmp breturn
//SEG18 main::@return //SEG18 main::@return
breturn: breturn:
@ -700,7 +688,8 @@ Removing instruction jmp breturn
Removing instruction jmp breturn Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin //SEG1 @begin
bbegin: bbegin:
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
@ -719,8 +708,8 @@ main: {
jsr inccnt jsr inccnt
//SEG9 main::@1 //SEG9 main::@1
b1: b1:
//SEG10 [3] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby //SEG10 [3] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby
stx $400 stx SCREEN+$0
//SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby //SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby
inx inx
//SEG12 [5] call inccnt param-assignment [ cnt#10 ] //SEG12 [5] call inccnt param-assignment [ cnt#10 ]
@ -732,8 +721,8 @@ main: {
b2: b2:
//SEG16 [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby //SEG16 [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby
inx inx
//SEG17 [7] *((word) 1025) ← (byte) cnt#1 [ ] -- _star_cowo1=xby //SEG17 [7] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1 [ ] -- _star_cowo1=xby
stx $401 stx SCREEN+$1
//SEG18 main::@return //SEG18 main::@return
breturn: breturn:
//SEG19 [8] return [ ] //SEG19 [8] return [ ]
@ -752,7 +741,8 @@ inccnt: {
Removing instruction main_from_bbegin: Removing instruction main_from_bbegin:
Succesful ASM optimization Pass5RedundantLabelElimination Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin //SEG1 @begin
bbegin: bbegin:
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
@ -770,8 +760,8 @@ main: {
jsr inccnt jsr inccnt
//SEG9 main::@1 //SEG9 main::@1
b1: b1:
//SEG10 [3] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby //SEG10 [3] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby
stx $400 stx SCREEN+$0
//SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby //SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby
inx inx
//SEG12 [5] call inccnt param-assignment [ cnt#10 ] //SEG12 [5] call inccnt param-assignment [ cnt#10 ]
@ -783,8 +773,8 @@ main: {
b2: b2:
//SEG16 [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby //SEG16 [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby
inx inx
//SEG17 [7] *((word) 1025) ← (byte) cnt#1 [ ] -- _star_cowo1=xby //SEG17 [7] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1 [ ] -- _star_cowo1=xby
stx $401 stx SCREEN+$1
//SEG18 main::@return //SEG18 main::@return
breturn: breturn:
//SEG19 [8] return [ ] //SEG19 [8] return [ ]
@ -810,7 +800,8 @@ Removing instruction breturn:
Removing instruction breturn: Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER ASSEMBLER
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin //SEG1 @begin
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main //SEG3 [1] phi from @begin to main
@ -824,8 +815,8 @@ main: {
ldx #$0 ldx #$0
jsr inccnt jsr inccnt
//SEG9 main::@1 //SEG9 main::@1
//SEG10 [3] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby //SEG10 [3] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby
stx $400 stx SCREEN+$0
//SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby //SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby
inx inx
//SEG12 [5] call inccnt param-assignment [ cnt#10 ] //SEG12 [5] call inccnt param-assignment [ cnt#10 ]
@ -835,8 +826,8 @@ main: {
//SEG15 main::@2 //SEG15 main::@2
//SEG16 [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby //SEG16 [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby
inx inx
//SEG17 [7] *((word) 1025) ← (byte) cnt#1 [ ] -- _star_cowo1=xby //SEG17 [7] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1 [ ] -- _star_cowo1=xby
stx $401 stx SCREEN+$1
//SEG18 main::@return //SEG18 main::@return
//SEG19 [8] return [ ] //SEG19 [8] return [ ]
rts rts
@ -854,6 +845,7 @@ FINAL SYMBOL TABLE
(label) @begin (label) @begin
(label) @end (label) @end
(byte[256]) SCREEN (byte[256]) SCREEN
(const byte[256]) SCREEN#0 = (word) 1024
(byte) cnt (byte) cnt
(byte) cnt#1 reg byte x 4.0 (byte) cnt#1 reg byte x 4.0
(byte) cnt#10 reg byte x 1.6 (byte) cnt#10 reg byte x 1.6
@ -871,7 +863,8 @@ reg byte x [ cnt#1 ]
reg byte x [ cnt#10 ] reg byte x [ cnt#10 ]
FINAL CODE FINAL CODE
//SEG0 Global ZP labels //SEG0 Global Constants & labels
.const SCREEN = $400
//SEG1 @begin //SEG1 @begin
//SEG2 [0] call main param-assignment [ ] //SEG2 [0] call main param-assignment [ ]
//SEG3 [1] phi from @begin to main //SEG3 [1] phi from @begin to main
@ -885,8 +878,8 @@ main: {
ldx #$0 ldx #$0
jsr inccnt jsr inccnt
//SEG9 main::@1 //SEG9 main::@1
//SEG10 [3] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby //SEG10 [3] *((const byte[256]) SCREEN#0+(byte) 0) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby
stx $400 stx SCREEN+$0
//SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby //SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby
inx inx
//SEG12 [5] call inccnt param-assignment [ cnt#10 ] //SEG12 [5] call inccnt param-assignment [ cnt#10 ]
@ -896,8 +889,8 @@ main: {
//SEG15 main::@2 //SEG15 main::@2
//SEG16 [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby //SEG16 [6] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby
inx inx
//SEG17 [7] *((word) 1025) ← (byte) cnt#1 [ ] -- _star_cowo1=xby //SEG17 [7] *((const byte[256]) SCREEN#0+(byte) 1) ← (byte) cnt#1 [ ] -- _star_cowo1=xby
stx $401 stx SCREEN+$1
//SEG18 main::@return //SEG18 main::@return
//SEG19 [8] return [ ] //SEG19 [8] return [ ]
rts rts

View File

@ -1,6 +1,7 @@
(label) @begin (label) @begin
(label) @end (label) @end
(byte[256]) SCREEN (byte[256]) SCREEN
(const byte[256]) SCREEN#0 = (word) 1024
(byte) cnt (byte) cnt
(byte) cnt#1 reg byte x 4.0 (byte) cnt#1 reg byte x 4.0
(byte) cnt#10 reg byte x 1.6 (byte) cnt#10 reg byte x 1.6

View File

@ -7,6 +7,7 @@ main: {
rts rts
} }
lvaluevar: { lvaluevar: {
.const b = $4
.label screen = 2 .label screen = 2
lda #<$400 lda #<$400
sta screen sta screen
@ -19,7 +20,7 @@ lvaluevar: {
rts rts
b2: b2:
ldy #$0 ldy #$0
lda #$4 lda #b
sta (screen),y sta (screen),y
inc screen inc screen
bne !+ bne !+
@ -50,23 +51,25 @@ rvaluevar: {
jmp b1 jmp b1
} }
rvalue: { rvalue: {
lda $400 .const SCREEN = $400
lda $401 lda SCREEN
lda SCREEN+$1
ldx #$2 ldx #$2
b1: b1:
cpx #$a cpx #$a
bcc b2 bcc b2
rts rts
b2: b2:
lda $400,x lda SCREEN,x
inx inx
jmp b1 jmp b1
} }
lvalue: { lvalue: {
.const SCREEN = $400
lda #$1 lda #$1
sta $400 sta SCREEN
lda #$2 lda #$2
sta $401 sta SCREEN+$1
ldx #$2 ldx #$2
b1: b1:
cpx #$a cpx #$a
@ -74,7 +77,7 @@ lvalue: {
rts rts
b2: b2:
lda #$3 lda #$3
sta $400,x sta SCREEN,x
inx inx
jmp b1 jmp b1
} }

View File

@ -30,7 +30,7 @@ lvaluevar::@return: scope:[lvaluevar] from lvaluevar::@1
[10] return [ ] [10] return [ ]
to:@return to:@return
lvaluevar::@2: scope:[lvaluevar] from lvaluevar::@1 lvaluevar::@2: scope:[lvaluevar] from lvaluevar::@1
[11] *((byte*) lvaluevar::screen#2) ← (byte) 4 [ lvaluevar::i#2 lvaluevar::screen#2 ] [11] *((byte*) lvaluevar::screen#2) ← (const byte) lvaluevar::b#0 [ lvaluevar::i#2 lvaluevar::screen#2 ]
[12] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::i#2 lvaluevar::screen#1 ] [12] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::i#2 lvaluevar::screen#1 ]
[13] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ] [13] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ]
to:lvaluevar::@1 to:lvaluevar::@1
@ -51,8 +51,8 @@ rvaluevar::@2: scope:[rvaluevar] from rvaluevar::@1
[20] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] [20] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ]
to:rvaluevar::@1 to:rvaluevar::@1
rvalue: scope:[rvalue] from main::@1 rvalue: scope:[rvalue] from main::@1
[21] (byte) rvalue::b#0 ← * (word) 1024 [ ] [21] (byte) rvalue::b#0 ← * (const byte[1024]) rvalue::SCREEN#0 [ ]
[22] (byte) rvalue::b#1 ← * (word) 1025 [ ] [22] (byte) rvalue::b#1 ← * (const byte[1024]) rvalue::SCREEN#0+(byte) 1 [ ]
to:rvalue::@1 to:rvalue::@1
rvalue::@1: scope:[rvalue] from rvalue rvalue::@2 rvalue::@1: scope:[rvalue] from rvalue rvalue::@2
[23] (byte) rvalue::i#2 ← phi( rvalue/(byte) 2 rvalue::@2/(byte) rvalue::i#1 ) [ rvalue::i#2 ] [23] (byte) rvalue::i#2 ← phi( rvalue/(byte) 2 rvalue::@2/(byte) rvalue::i#1 ) [ rvalue::i#2 ]
@ -62,12 +62,12 @@ rvalue::@return: scope:[rvalue] from rvalue::@1
[25] return [ ] [25] return [ ]
to:@return to:@return
rvalue::@2: scope:[rvalue] from rvalue::@1 rvalue::@2: scope:[rvalue] from rvalue::@1
[26] (byte) rvalue::b#2 ← (word) 1024 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] [26] (byte) rvalue::b#2 ← (const byte[1024]) rvalue::SCREEN#0 *idx (byte) rvalue::i#2 [ rvalue::i#2 ]
[27] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] [27] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ]
to:rvalue::@1 to:rvalue::@1
lvalue: scope:[lvalue] from main lvalue: scope:[lvalue] from main
[28] *((word) 1024) ← (byte) 1 [ ] [28] *((const byte[1024]) lvalue::SCREEN#0) ← (byte) 1 [ ]
[29] *((word) 1025) ← (byte) 2 [ ] [29] *((const byte[1024]) lvalue::SCREEN#0+(byte) 1) ← (byte) 2 [ ]
to:lvalue::@1 to:lvalue::@1
lvalue::@1: scope:[lvalue] from lvalue lvalue::@2 lvalue::@1: scope:[lvalue] from lvalue lvalue::@2
[30] (byte) lvalue::i#2 ← phi( lvalue/(byte) 2 lvalue::@2/(byte) lvalue::i#1 ) [ lvalue::i#2 ] [30] (byte) lvalue::i#2 ← phi( lvalue/(byte) 2 lvalue::@2/(byte) lvalue::i#1 ) [ lvalue::i#2 ]
@ -77,6 +77,6 @@ lvalue::@return: scope:[lvalue] from lvalue::@1
[32] return [ ] [32] return [ ]
to:@return to:@return
lvalue::@2: scope:[lvalue] from lvalue::@1 lvalue::@2: scope:[lvalue] from lvalue::@1
[33] *((word) 1024 + (byte) lvalue::i#2) ← (byte) 3 [ lvalue::i#2 ] [33] *((const byte[1024]) lvalue::SCREEN#0 + (byte) lvalue::i#2) ← (byte) 3 [ lvalue::i#2 ]
[34] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] [34] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ]
to:lvalue::@1 to:lvalue::@1

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
(label) lvalue::@2 (label) lvalue::@2
(label) lvalue::@return (label) lvalue::@return
(byte[1024]) lvalue::SCREEN (byte[1024]) lvalue::SCREEN
(const byte[1024]) lvalue::SCREEN#0 = (word) 1024
(byte) lvalue::i (byte) lvalue::i
(byte) lvalue::i#1 reg byte x 22.0 (byte) lvalue::i#1 reg byte x 22.0
(byte) lvalue::i#2 reg byte x 14.666666666666666 (byte) lvalue::i#2 reg byte x 14.666666666666666
@ -13,6 +14,7 @@
(label) lvaluevar::@2 (label) lvaluevar::@2
(label) lvaluevar::@return (label) lvaluevar::@return
(byte) lvaluevar::b (byte) lvaluevar::b
(const byte) lvaluevar::b#0 = (byte) 4
(byte) lvaluevar::i (byte) lvaluevar::i
(byte) lvaluevar::i#1 reg byte x 22.0 (byte) lvaluevar::i#1 reg byte x 22.0
(byte) lvaluevar::i#2 reg byte x 8.25 (byte) lvaluevar::i#2 reg byte x 8.25
@ -29,6 +31,7 @@
(label) rvalue::@2 (label) rvalue::@2
(label) rvalue::@return (label) rvalue::@return
(byte[1024]) rvalue::SCREEN (byte[1024]) rvalue::SCREEN
(const byte[1024]) rvalue::SCREEN#0 = (word) 1024
(byte) rvalue::b (byte) rvalue::b
(byte) rvalue::b#0 reg byte a 20.0 (byte) rvalue::b#0 reg byte a 20.0
(byte) rvalue::b#1 reg byte a 20.0 (byte) rvalue::b#1 reg byte a 20.0

View File

@ -319,8 +319,8 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte[1024]) main::SCREEN#0 Constant (const byte[1024]) main::SCREEN#0 = 1024
Constant (const byte) main::i#0 Constant (const byte) main::i#0 = 2
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -342,8 +342,8 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Redundant Phi (byte[1024]) main::SCREEN#1 (const byte[1024]) main::SCREEN#0 Constant (const byte[1024]) main::SCREEN#1 = main::SCREEN#0
Succesful SSA optimization Pass2RedundantPhiElimination Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -355,7 +355,7 @@ main::@1: scope:[main] from main main::@2
if((byte) main::i#2<(byte) 10) goto main::@2 if((byte) main::i#2<(byte) 10) goto main::@2
to:main::@return to:main::@return
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte) main::b#0 ← (const byte[1024]) main::SCREEN#0 *idx (byte) main::i#2 (byte) main::b#0 ← (const byte[1024]) main::SCREEN#1 *idx (byte) main::i#2
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@1 to:main::@1
main::@return: scope:[main] from main::@1 main::@return: scope:[main] from main::@1
@ -363,6 +363,9 @@ main::@return: scope:[main] from main::@1
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Constant inlined main::SCREEN#1 = (const byte[1024]) main::SCREEN#0
Constant inlined main::i#0 = (byte) 2 Constant inlined main::i#0 = (byte) 2
Succesful SSA optimization Pass2ConstantInlining Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH CONTROL FLOW GRAPH

View File

@ -316,12 +316,15 @@ sum::@return: scope:[sum] from sum
to:@return to:@return
@end: scope:[] from @4 @end: scope:[] from @4
Constant (const byte) sum::a#0 Not aliassing across scopes: s1#0 sum::return#0
Constant (const byte) sum::b#0 Not aliassing across scopes: s2#0 sum::return#0
Constant (const byte) sum::a#1 Not aliassing across scopes: s3#0 sum::return#0
Constant (const byte) sum::b#1 Constant (const byte) sum::a#0 = 1
Constant (const byte) sum::a#2 Constant (const byte) sum::b#0 = 2
Constant (const byte) sum::b#2 Constant (const byte) sum::a#1 = 3
Constant (const byte) sum::b#1 = 4
Constant (const byte) sum::a#2 = 9
Constant (const byte) sum::b#2 = 13
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from

View File

@ -139,7 +139,7 @@ main::@return: scope:[main] from main
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte*) SCREEN#0 Constant (const byte*) SCREEN#0 = 1024
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from

View File

@ -1,3 +1,9 @@
.const SCREEN = $400
.const COLORS = $d800
.const FILL = $e6
.const XPOS = $1000
.const YPOS = $1100
.const COLS = $1200
.label numpoints = 8 .label numpoints = 8
jsr main jsr main
main: { main: {
@ -41,64 +47,64 @@ main: {
rts rts
} }
animate: { animate: {
lda $1000 lda XPOS+$0
clc clc
adc #$1 adc #$1
sta $1000 sta XPOS+$0
lda $1000 lda XPOS+$0
cmp #$28 cmp #$28
bne b1 bne b1
lda #$0 lda #$0
sta $1000 sta XPOS+$0
b1: b1:
lda $1100 lda YPOS+$0
clc clc
adc #$1 adc #$1
sta $1100 sta YPOS+$0
lda $1100 lda YPOS+$0
cmp #$19 cmp #$19
bne b2 bne b2
lda #$0 lda #$0
sta $1100 sta YPOS+$0
b2: b2:
ldx $1001 ldx XPOS+$1
dex dex
stx $1001 stx XPOS+$1
lda $1001 lda XPOS+$1
cmp #$ff cmp #$ff
bne b3 bne b3
lda #$28 lda #$28
sta $1001 sta XPOS+$1
b3: b3:
lda $1102 lda YPOS+$2
clc clc
adc #$1 adc #$1
sta $1102 sta YPOS+$2
lda $1102 lda YPOS+$2
cmp #$19 cmp #$19
bne b4 bne b4
lda #$0 lda #$0
sta $1102 sta YPOS+$2
b4: b4:
ldx $1103 ldx YPOS+$3
dex dex
stx $1103 stx YPOS+$3
lda $1103 lda YPOS+$3
cmp #$ff cmp #$ff
bne breturn bne breturn
lda #$19 lda #$19
sta $1103 sta YPOS+$3
lda $1003 lda XPOS+$3
clc clc
adc #$7 adc #$7
sta $1003 sta XPOS+$3
lda $1003 lda XPOS+$3
cmp #$28 cmp #$28
bcc breturn bcc breturn
lda $1003 lda XPOS+$3
sec sec
sbc #$28 sbc #$28
sta $1003 sta XPOS+$3
breturn: breturn:
rts rts
} }
@ -106,9 +112,9 @@ render: {
.label x = 5 .label x = 5
.label colline = 3 .label colline = 3
.label y = 2 .label y = 2
lda #<$d800 lda #<COLORS
sta colline sta colline
lda #>$d800 lda #>COLORS
sta colline+$1 sta colline+$1
lda #$0 lda #$0
sta y sta y
@ -153,9 +159,9 @@ findcol: {
sta mindiff sta mindiff
ldx #$0 ldx #$0
b1: b1:
lda $1000,x lda XPOS,x
sta xp sta xp
lda $1100,x lda YPOS,x
sta yp sta yp
lda x lda x
cmp xp cmp xp
@ -186,7 +192,7 @@ findcol: {
b7: b7:
cmp mindiff cmp mindiff
bcs b21 bcs b21
ldy $1200,x ldy COLS,x
b8: b8:
inx inx
cpx numpoints cpx numpoints
@ -214,24 +220,24 @@ findcol: {
} }
initscreen: { initscreen: {
.label screen = 3 .label screen = 3
lda #<$400 lda #<SCREEN
sta screen sta screen
lda #>$400 lda #>SCREEN
sta screen+$1 sta screen+$1
b1: b1:
ldy #$0 ldy #$0
lda #$e6 lda #FILL
sta (screen),y sta (screen),y
inc screen inc screen
bne !+ bne !+
inc screen+$1 inc screen+$1
!: !:
lda screen+$1 lda screen+$1
cmp #>$7e8 cmp #>SCREEN+$3e8
bcc b1 bcc b1
bne !+ bne !+
lda screen lda screen
cmp #<$7e8 cmp #<SCREEN+$3e8
bcc b1 bcc b1
!: !:
rts rts
@ -239,13 +245,13 @@ initscreen: {
addpoint: { addpoint: {
.label c = 2 .label c = 2
ldx numpoints ldx numpoints
sta $1000,x sta XPOS,x
tya tya
ldy numpoints ldy numpoints
sta $1100,y sta YPOS,y
lda c lda c
ldx numpoints ldx numpoints
sta $1200,x sta COLS,x
inc numpoints inc numpoints
rts rts
} }

View File

@ -37,64 +37,64 @@ main::@return: scope:[main] from main::@11
[12] return [ ] [12] return [ ]
to:@return to:@return
animate: scope:[animate] from main::@10 animate: scope:[animate] from main::@10
[13] (byte~) animate::$0 ← * (word) 4096 [ animate::$0 ] [13] (byte~) animate::$0 ← * (const byte[256]) XPOS#0+(byte) 0 [ animate::$0 ]
[14] (byte~) animate::$1 ← (byte~) animate::$0 + (byte) 1 [ animate::$1 ] [14] (byte~) animate::$1 ← (byte~) animate::$0 + (byte) 1 [ animate::$1 ]
[15] *((word) 4096) ← (byte~) animate::$1 [ ] [15] *((const byte[256]) XPOS#0+(byte) 0) ← (byte~) animate::$1 [ ]
[16] (byte~) animate::$2 ← * (word) 4096 [ animate::$2 ] [16] (byte~) animate::$2 ← * (const byte[256]) XPOS#0+(byte) 0 [ animate::$2 ]
[17] if((byte~) animate::$2!=(byte) 40) goto animate::@1 [ ] [17] if((byte~) animate::$2!=(byte) 40) goto animate::@1 [ ]
to:animate::@7 to:animate::@7
animate::@7: scope:[animate] from animate animate::@7: scope:[animate] from animate
[18] *((word) 4096) ← (byte) 0 [ ] [18] *((const byte[256]) XPOS#0+(byte) 0) ← (byte) 0 [ ]
to:animate::@1 to:animate::@1
animate::@1: scope:[animate] from animate animate::@7 animate::@1: scope:[animate] from animate animate::@7
[19] (byte~) animate::$5 ← * (word) 4352 [ animate::$5 ] [19] (byte~) animate::$5 ← * (const byte[256]) YPOS#0+(byte) 0 [ animate::$5 ]
[20] (byte~) animate::$6 ← (byte~) animate::$5 + (byte) 1 [ animate::$6 ] [20] (byte~) animate::$6 ← (byte~) animate::$5 + (byte) 1 [ animate::$6 ]
[21] *((word) 4352) ← (byte~) animate::$6 [ ] [21] *((const byte[256]) YPOS#0+(byte) 0) ← (byte~) animate::$6 [ ]
[22] (byte~) animate::$7 ← * (word) 4352 [ animate::$7 ] [22] (byte~) animate::$7 ← * (const byte[256]) YPOS#0+(byte) 0 [ animate::$7 ]
[23] if((byte~) animate::$7!=(byte) 25) goto animate::@2 [ ] [23] if((byte~) animate::$7!=(byte) 25) goto animate::@2 [ ]
to:animate::@8 to:animate::@8
animate::@8: scope:[animate] from animate::@1 animate::@8: scope:[animate] from animate::@1
[24] *((word) 4352) ← (byte) 0 [ ] [24] *((const byte[256]) YPOS#0+(byte) 0) ← (byte) 0 [ ]
to:animate::@2 to:animate::@2
animate::@2: scope:[animate] from animate::@1 animate::@8 animate::@2: scope:[animate] from animate::@1 animate::@8
[25] (byte~) animate::$10 ← * (word) 4097 [ animate::$10 ] [25] (byte~) animate::$10 ← * (const byte[256]) XPOS#0+(byte) 1 [ animate::$10 ]
[26] (byte~) animate::$11 ← (byte~) animate::$10 - (byte) 1 [ animate::$11 ] [26] (byte~) animate::$11 ← (byte~) animate::$10 - (byte) 1 [ animate::$11 ]
[27] *((word) 4097) ← (byte~) animate::$11 [ ] [27] *((const byte[256]) XPOS#0+(byte) 1) ← (byte~) animate::$11 [ ]
[28] (byte~) animate::$12 ← * (word) 4097 [ animate::$12 ] [28] (byte~) animate::$12 ← * (const byte[256]) XPOS#0+(byte) 1 [ animate::$12 ]
[29] if((byte~) animate::$12!=(byte) 255) goto animate::@3 [ ] [29] if((byte~) animate::$12!=(byte) 255) goto animate::@3 [ ]
to:animate::@9 to:animate::@9
animate::@9: scope:[animate] from animate::@2 animate::@9: scope:[animate] from animate::@2
[30] *((word) 4097) ← (byte) 40 [ ] [30] *((const byte[256]) XPOS#0+(byte) 1) ← (byte) 40 [ ]
to:animate::@3 to:animate::@3
animate::@3: scope:[animate] from animate::@2 animate::@9 animate::@3: scope:[animate] from animate::@2 animate::@9
[31] (byte~) animate::$15 ← * (word) 4354 [ animate::$15 ] [31] (byte~) animate::$15 ← * (const byte[256]) YPOS#0+(byte) 2 [ animate::$15 ]
[32] (byte~) animate::$16 ← (byte~) animate::$15 + (byte) 1 [ animate::$16 ] [32] (byte~) animate::$16 ← (byte~) animate::$15 + (byte) 1 [ animate::$16 ]
[33] *((word) 4354) ← (byte~) animate::$16 [ ] [33] *((const byte[256]) YPOS#0+(byte) 2) ← (byte~) animate::$16 [ ]
[34] (byte~) animate::$17 ← * (word) 4354 [ animate::$17 ] [34] (byte~) animate::$17 ← * (const byte[256]) YPOS#0+(byte) 2 [ animate::$17 ]
[35] if((byte~) animate::$17!=(byte) 25) goto animate::@4 [ ] [35] if((byte~) animate::$17!=(byte) 25) goto animate::@4 [ ]
to:animate::@10 to:animate::@10
animate::@10: scope:[animate] from animate::@3 animate::@10: scope:[animate] from animate::@3
[36] *((word) 4354) ← (byte) 0 [ ] [36] *((const byte[256]) YPOS#0+(byte) 2) ← (byte) 0 [ ]
to:animate::@4 to:animate::@4
animate::@4: scope:[animate] from animate::@10 animate::@3 animate::@4: scope:[animate] from animate::@10 animate::@3
[37] (byte~) animate::$20 ← * (word) 4355 [ animate::$20 ] [37] (byte~) animate::$20 ← * (const byte[256]) YPOS#0+(byte) 3 [ animate::$20 ]
[38] (byte~) animate::$21 ← (byte~) animate::$20 - (byte) 1 [ animate::$21 ] [38] (byte~) animate::$21 ← (byte~) animate::$20 - (byte) 1 [ animate::$21 ]
[39] *((word) 4355) ← (byte~) animate::$21 [ ] [39] *((const byte[256]) YPOS#0+(byte) 3) ← (byte~) animate::$21 [ ]
[40] (byte~) animate::$22 ← * (word) 4355 [ animate::$22 ] [40] (byte~) animate::$22 ← * (const byte[256]) YPOS#0+(byte) 3 [ animate::$22 ]
[41] if((byte~) animate::$22!=(byte) 255) goto animate::@return [ ] [41] if((byte~) animate::$22!=(byte) 255) goto animate::@return [ ]
to:animate::@11 to:animate::@11
animate::@11: scope:[animate] from animate::@4 animate::@11: scope:[animate] from animate::@4
[42] *((word) 4355) ← (byte) 25 [ ] [42] *((const byte[256]) YPOS#0+(byte) 3) ← (byte) 25 [ ]
[43] (byte~) animate::$25 ← * (word) 4099 [ animate::$25 ] [43] (byte~) animate::$25 ← * (const byte[256]) XPOS#0+(byte) 3 [ animate::$25 ]
[44] (byte~) animate::$26 ← (byte~) animate::$25 + (byte) 7 [ animate::$26 ] [44] (byte~) animate::$26 ← (byte~) animate::$25 + (byte) 7 [ animate::$26 ]
[45] *((word) 4099) ← (byte~) animate::$26 [ ] [45] *((const byte[256]) XPOS#0+(byte) 3) ← (byte~) animate::$26 [ ]
[46] (byte~) animate::$27 ← * (word) 4099 [ animate::$27 ] [46] (byte~) animate::$27 ← * (const byte[256]) XPOS#0+(byte) 3 [ animate::$27 ]
[47] if((byte~) animate::$27<(byte) 40) goto animate::@return [ ] [47] if((byte~) animate::$27<(byte) 40) goto animate::@return [ ]
to:animate::@12 to:animate::@12
animate::@12: scope:[animate] from animate::@11 animate::@12: scope:[animate] from animate::@11
[48] (byte~) animate::$30 ← * (word) 4099 [ animate::$30 ] [48] (byte~) animate::$30 ← * (const byte[256]) XPOS#0+(byte) 3 [ animate::$30 ]
[49] (byte~) animate::$31 ← (byte~) animate::$30 - (byte) 40 [ animate::$31 ] [49] (byte~) animate::$31 ← (byte~) animate::$30 - (byte) 40 [ animate::$31 ]
[50] *((word) 4099) ← (byte~) animate::$31 [ ] [50] *((const byte[256]) XPOS#0+(byte) 3) ← (byte~) animate::$31 [ ]
to:animate::@return to:animate::@return
animate::@return: scope:[animate] from animate::@11 animate::@12 animate::@4 animate::@return: scope:[animate] from animate::@11 animate::@12 animate::@4
[51] return [ ] [51] return [ ]
@ -103,7 +103,7 @@ render: scope:[render] from main::@1
[52] phi() [ numpoints#1 ] [52] phi() [ numpoints#1 ]
to:render::@1 to:render::@1
render::@1: scope:[render] from render render::@3 render::@1: scope:[render] from render render::@3
[53] (byte*) render::colline#2 ← phi( render/(word) 55296 render::@3/(byte*) render::colline#1 ) [ render::y#2 render::colline#2 numpoints#1 ] [53] (byte*) render::colline#2 ← phi( render/(const byte*) COLORS#0 render::@3/(byte*) render::colline#1 ) [ render::y#2 render::colline#2 numpoints#1 ]
[53] (byte) render::y#2 ← phi( render/(byte) 0 render::@3/(byte) render::y#1 ) [ render::y#2 render::colline#2 numpoints#1 ] [53] (byte) render::y#2 ← phi( render/(byte) 0 render::@3/(byte) render::y#1 ) [ render::y#2 render::colline#2 numpoints#1 ]
to:render::@2 to:render::@2
render::@2: scope:[render] from render::@1 render::@5 render::@2: scope:[render] from render::@1 render::@5
@ -133,8 +133,8 @@ findcol::@1: scope:[findcol] from findcol findcol::@19
[67] (byte) findcol::mincol#11 ← phi( findcol/(byte) 0 findcol::@19/(byte) findcol::mincol#2 ) [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 numpoints#1 ] [67] (byte) findcol::mincol#11 ← phi( findcol/(byte) 0 findcol::@19/(byte) findcol::mincol#2 ) [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 numpoints#1 ]
[67] (byte) findcol::mindiff#10 ← phi( findcol/(byte) 255 findcol::@19/(byte~) findcol::mindiff#13 ) [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 numpoints#1 ] [67] (byte) findcol::mindiff#10 ← phi( findcol/(byte) 255 findcol::@19/(byte~) findcol::mindiff#13 ) [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 numpoints#1 ]
[67] (byte) findcol::i#12 ← phi( findcol/(byte) 0 findcol::@19/(byte) findcol::i#1 ) [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 numpoints#1 ] [67] (byte) findcol::i#12 ← phi( findcol/(byte) 0 findcol::@19/(byte) findcol::i#1 ) [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 numpoints#1 ]
[68] (byte) findcol::xp#0 ← (word) 4096 *idx (byte) findcol::i#12 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 findcol::xp#0 numpoints#1 ] [68] (byte) findcol::xp#0 ← (const byte[256]) XPOS#0 *idx (byte) findcol::i#12 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 findcol::xp#0 numpoints#1 ]
[69] (byte) findcol::yp#0 ← (word) 4352 *idx (byte) findcol::i#12 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 findcol::xp#0 findcol::yp#0 numpoints#1 ] [69] (byte) findcol::yp#0 ← (const byte[256]) YPOS#0 *idx (byte) findcol::i#12 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 findcol::xp#0 findcol::yp#0 numpoints#1 ]
[70] if((byte) findcol::x#0!=(byte) findcol::xp#0) goto findcol::@2 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 findcol::xp#0 findcol::yp#0 numpoints#1 ] [70] if((byte) findcol::x#0!=(byte) findcol::xp#0) goto findcol::@2 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 findcol::xp#0 findcol::yp#0 numpoints#1 ]
to:findcol::@9 to:findcol::@9
findcol::@9: scope:[findcol] from findcol::@1 findcol::@9: scope:[findcol] from findcol::@1
@ -163,7 +163,7 @@ findcol::@7: scope:[findcol] from findcol::@14 findcol::@6
[81] if((byte) findcol::diff#6>=(byte) findcol::mindiff#10) goto findcol::@21 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 findcol::diff#6 numpoints#1 ] [81] if((byte) findcol::diff#6>=(byte) findcol::mindiff#10) goto findcol::@21 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mindiff#10 findcol::mincol#11 findcol::diff#6 numpoints#1 ]
to:findcol::@16 to:findcol::@16
findcol::@16: scope:[findcol] from findcol::@7 findcol::@16: scope:[findcol] from findcol::@7
[82] (byte) findcol::mincol#1 ← (word) 4608 *idx (byte) findcol::i#12 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::diff#6 findcol::mincol#1 numpoints#1 ] [82] (byte) findcol::mincol#1 ← (const byte[256]) COLS#0 *idx (byte) findcol::i#12 [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::diff#6 findcol::mincol#1 numpoints#1 ]
to:findcol::@8 to:findcol::@8
findcol::@8: scope:[findcol] from findcol::@16 findcol::@21 findcol::@8: scope:[findcol] from findcol::@16 findcol::@21
[83] (byte) findcol::mindiff#11 ← phi( findcol::@16/(byte) findcol::diff#6 findcol::@21/(byte~) findcol::mindiff#14 ) [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mincol#2 findcol::mindiff#11 numpoints#1 ] [83] (byte) findcol::mindiff#11 ← phi( findcol::@16/(byte) findcol::diff#6 findcol::@21/(byte~) findcol::mindiff#14 ) [ findcol::x#0 findcol::y#0 findcol::i#12 findcol::mincol#2 findcol::mindiff#11 numpoints#1 ]
@ -188,10 +188,10 @@ initscreen: scope:[initscreen] from main::@8
[91] phi() [ ] [91] phi() [ ]
to:initscreen::@1 to:initscreen::@1
initscreen::@1: scope:[initscreen] from initscreen initscreen::@1 initscreen::@1: scope:[initscreen] from initscreen initscreen::@1
[92] (byte*) initscreen::screen#2 ← phi( initscreen/(word) 1024 initscreen::@1/(byte*) initscreen::screen#1 ) [ initscreen::screen#2 ] [92] (byte*) initscreen::screen#2 ← phi( initscreen/(const byte*) SCREEN#0 initscreen::@1/(byte*) initscreen::screen#1 ) [ initscreen::screen#2 ]
[93] *((byte*) initscreen::screen#2) ← (byte) 230 [ initscreen::screen#2 ] [93] *((byte*) initscreen::screen#2) ← (const byte) FILL#0 [ initscreen::screen#2 ]
[94] (byte*) initscreen::screen#1 ← ++ (byte*) initscreen::screen#2 [ initscreen::screen#1 ] [94] (byte*) initscreen::screen#1 ← ++ (byte*) initscreen::screen#2 [ initscreen::screen#1 ]
[95] if((byte*) initscreen::screen#1<(word) 2024) goto initscreen::@1 [ initscreen::screen#1 ] [95] if((byte*) initscreen::screen#1<(const byte*) SCREEN#0+(word) 1000) goto initscreen::@1 [ initscreen::screen#1 ]
to:initscreen::@return to:initscreen::@return
initscreen::@return: scope:[initscreen] from initscreen::@1 initscreen::@return: scope:[initscreen] from initscreen::@1
[96] return [ ] [96] return [ ]
@ -201,9 +201,9 @@ addpoint: scope:[addpoint] from main main::@3 main::@4 main::@5 main::@6 main::
[97] (byte) addpoint::y#6 ← phi( main/(byte) 5 main::@3/(byte) 8 main::@4/(byte) 14 main::@5/(byte) 2 main::@6/(byte) 17 main::@7/(byte) 22 ) [ addpoint::x#6 numpoints#19 addpoint::y#6 addpoint::c#6 ] [97] (byte) addpoint::y#6 ← phi( main/(byte) 5 main::@3/(byte) 8 main::@4/(byte) 14 main::@5/(byte) 2 main::@6/(byte) 17 main::@7/(byte) 22 ) [ addpoint::x#6 numpoints#19 addpoint::y#6 addpoint::c#6 ]
[97] (byte) numpoints#19 ← phi( main/(byte) 0 main::@3/(byte) numpoints#1 main::@4/(byte) numpoints#1 main::@5/(byte) numpoints#1 main::@6/(byte) numpoints#1 main::@7/(byte) numpoints#1 ) [ addpoint::x#6 numpoints#19 addpoint::y#6 addpoint::c#6 ] [97] (byte) numpoints#19 ← phi( main/(byte) 0 main::@3/(byte) numpoints#1 main::@4/(byte) numpoints#1 main::@5/(byte) numpoints#1 main::@6/(byte) numpoints#1 main::@7/(byte) numpoints#1 ) [ addpoint::x#6 numpoints#19 addpoint::y#6 addpoint::c#6 ]
[97] (byte) addpoint::x#6 ← phi( main/(byte) 5 main::@3/(byte) 15 main::@4/(byte) 6 main::@5/(byte) 34 main::@6/(byte) 21 main::@7/(byte) 31 ) [ addpoint::x#6 numpoints#19 addpoint::y#6 addpoint::c#6 ] [97] (byte) addpoint::x#6 ← phi( main/(byte) 5 main::@3/(byte) 15 main::@4/(byte) 6 main::@5/(byte) 34 main::@6/(byte) 21 main::@7/(byte) 31 ) [ addpoint::x#6 numpoints#19 addpoint::y#6 addpoint::c#6 ]
[98] *((word) 4096 + (byte) numpoints#19) ← (byte) addpoint::x#6 [ numpoints#19 addpoint::y#6 addpoint::c#6 ] [98] *((const byte[256]) XPOS#0 + (byte) numpoints#19) ← (byte) addpoint::x#6 [ numpoints#19 addpoint::y#6 addpoint::c#6 ]
[99] *((word) 4352 + (byte) numpoints#19) ← (byte) addpoint::y#6 [ numpoints#19 addpoint::c#6 ] [99] *((const byte[256]) YPOS#0 + (byte) numpoints#19) ← (byte) addpoint::y#6 [ numpoints#19 addpoint::c#6 ]
[100] *((word) 4608 + (byte) numpoints#19) ← (byte) addpoint::c#6 [ numpoints#19 ] [100] *((const byte[256]) COLS#0 + (byte) numpoints#19) ← (byte) addpoint::c#6 [ numpoints#19 ]
[101] (byte) numpoints#1 ← ++ (byte) numpoints#19 [ numpoints#1 ] [101] (byte) numpoints#1 ← ++ (byte) numpoints#19 [ numpoints#1 ]
to:addpoint::@return to:addpoint::@return
addpoint::@return: scope:[addpoint] from addpoint addpoint::@return: scope:[addpoint] from addpoint

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,17 @@
(label) @begin (label) @begin
(label) @end (label) @end
(byte*) COLORS (byte*) COLORS
(const byte*) COLORS#0 = (word) 55296
(byte[256]) COLS (byte[256]) COLS
(const byte[256]) COLS#0 = (word) 4608
(byte) FILL (byte) FILL
(const byte) FILL#0 = (byte) 230
(byte*) SCREEN (byte*) SCREEN
(const byte*) SCREEN#0 = (word) 1024
(byte[256]) XPOS (byte[256]) XPOS
(const byte[256]) XPOS#0 = (word) 4096
(byte[256]) YPOS (byte[256]) YPOS
(const byte[256]) YPOS#0 = (word) 4352
(void()) addpoint((byte) addpoint::x , (byte) addpoint::y , (byte) addpoint::c) (void()) addpoint((byte) addpoint::x , (byte) addpoint::y , (byte) addpoint::c)
(label) addpoint::@return (label) addpoint::@return
(byte) addpoint::c (byte) addpoint::c

View File

@ -666,6 +666,14 @@ sum2::@return: scope:[sum2] from sum2
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Not aliassing across scopes: sum::a#0 main::i#2
Not aliassing across scopes: sum::b#0 main::$0
Not aliassing across scopes: sum::c#0 main::$1
Not aliassing across scopes: main::$2 sum::return#0
Not aliassing across scopes: sum2::a#0 main::i#2
Not aliassing across scopes: sum2::b#0 main::$3
Not aliassing across scopes: sum2::c#0 main::$4
Not aliassing across scopes: main::$5 sum2::return#0
Self Phi Eliminated (byte*) SCREEN#1 Self Phi Eliminated (byte*) SCREEN#1
Self Phi Eliminated (byte*) SCREEN2#1 Self Phi Eliminated (byte*) SCREEN2#1
Succesful SSA optimization Pass2SelfPhiElimination Succesful SSA optimization Pass2SelfPhiElimination
@ -782,9 +790,9 @@ sum2::@return: scope:[sum2] from sum2
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Constant (const byte*) SCREEN#0 Constant (const byte*) SCREEN#0 = 1024
Constant (const byte*) SCREEN2#0 Constant (const byte*) SCREEN2#0 = 1024+40
Constant (const byte) main::i#0 Constant (const byte) main::i#0 = 0
Succesful SSA optimization Pass2ConstantIdentification Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
@ -838,17 +846,9 @@ sum2::@return: scope:[sum2] from sum2
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Not aliassing across scopes: sum::a#0 main::i#2 Constant (const byte*) SCREEN#1 = SCREEN#0
Not aliassing across scopes: sum::b#0 main::$0 Constant (const byte*) SCREEN2#1 = SCREEN2#0
Not aliassing across scopes: sum::c#0 main::$1 Succesful SSA optimization Pass2ConstantIdentification
Not aliassing across scopes: main::$2 sum::return#0
Not aliassing across scopes: sum2::a#0 main::i#2
Not aliassing across scopes: sum2::b#0 main::$3
Not aliassing across scopes: sum2::c#0 main::$4
Not aliassing across scopes: main::$5 sum2::return#0
Redundant Phi (byte*) SCREEN#1 (const byte*) SCREEN#0
Redundant Phi (byte*) SCREEN2#1 (const byte*) SCREEN2#0
Succesful SSA optimization Pass2RedundantPhiElimination
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
call main param-assignment call main param-assignment
@ -866,7 +866,7 @@ main::@1: scope:[main] from main main::@4
to:main::@3 to:main::@3
main::@3: scope:[main] from main::@1 main::@3: scope:[main] from main::@1
(byte~) main::$2 ← (byte) sum::return#0 (byte~) main::$2 ← (byte) sum::return#0
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 *((const byte*) SCREEN#1 + (byte) main::i#2) ← (byte~) main::$2
(byte~) main::$3 ← (byte) main::i#2 + (byte) 1 (byte~) main::$3 ← (byte) main::i#2 + (byte) 1
(byte~) main::$4 ← (byte) main::i#2 + (byte) 2 (byte~) main::$4 ← (byte) main::i#2 + (byte) 2
(byte) sum2::a#0 ← (byte) main::i#2 (byte) sum2::a#0 ← (byte) main::i#2
@ -876,7 +876,7 @@ main::@3: scope:[main] from main::@1
to:main::@4 to:main::@4
main::@4: scope:[main] from main::@3 main::@4: scope:[main] from main::@3
(byte~) main::$5 ← (byte) sum2::return#0 (byte~) main::$5 ← (byte) sum2::return#0
*((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 *((const byte*) SCREEN2#1 + (byte) main::i#2) ← (byte~) main::$5
(byte) main::i#1 ← ++ (byte) main::i#2 (byte) main::i#1 ← ++ (byte) main::i#2
if((byte) main::i#1!=(byte) 11) goto main::@1 if((byte) main::i#1!=(byte) 11) goto main::@1
to:main::@return to:main::@return
@ -899,6 +899,12 @@ sum2::@return: scope:[sum2] from sum2
to:@return to:@return
@end: scope:[] from @begin @end: scope:[] from @begin
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Not aliassing across scopes: sum::a#0 main::i#2 Not aliassing across scopes: sum::a#0 main::i#2
Not aliassing across scopes: sum::b#0 main::$0 Not aliassing across scopes: sum::b#0 main::$0
Not aliassing across scopes: sum::c#0 main::$1 Not aliassing across scopes: sum::c#0 main::$1
@ -907,6 +913,14 @@ Not aliassing across scopes: sum2::a#0 main::i#2
Not aliassing across scopes: sum2::b#0 main::$3 Not aliassing across scopes: sum2::b#0 main::$3
Not aliassing across scopes: sum2::c#0 main::$4 Not aliassing across scopes: sum2::c#0 main::$4
Not aliassing across scopes: main::$5 sum2::return#0 Not aliassing across scopes: main::$5 sum2::return#0
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Constant inlined SCREEN#1 = (const byte*) SCREEN#0
Constant inlined SCREEN2#1 = (const byte*) SCREEN2#0
Constant inlined main::i#0 = (byte) 0 Constant inlined main::i#0 = (byte) 0
Succesful SSA optimization Pass2ConstantInlining Succesful SSA optimization Pass2ConstantInlining
CONTROL FLOW GRAPH CONTROL FLOW GRAPH