From 2819d3c58a28e5174a7bdafa6fe238ffb204c547 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Tue, 25 Jul 2017 00:17:56 +0200 Subject: [PATCH] Added pass1 optimization removing empty blocks. --- src/dk/camelot64/kickc/CompileLog.java | 2 +- src/dk/camelot64/kickc/Compiler.java | 8 +- .../camelot64/kickc/icl/ControlFlowGraph.java | 4 + .../passes/Pass1EliminateEmptyBlocks.java | 55 + src/dk/camelot64/kickc/test/TestIclJson.java | 4 +- src/dk/camelot64/kickc/test/ref/bresenham.cfg | 4 +- src/dk/camelot64/kickc/test/ref/bresenham.log | 940 +++++-------- src/dk/camelot64/kickc/test/ref/bresenham.sym | 2 +- .../camelot64/kickc/test/ref/flipper-rex2.asm | 16 +- .../camelot64/kickc/test/ref/flipper-rex2.cfg | 10 +- .../camelot64/kickc/test/ref/flipper-rex2.log | 1246 ++++++++++------- .../camelot64/kickc/test/ref/flipper-rex2.sym | 1 - src/dk/camelot64/kickc/test/ref/loopmin.cfg | 4 +- src/dk/camelot64/kickc/test/ref/loopmin.log | 324 ++--- src/dk/camelot64/kickc/test/ref/loopmin.sym | 2 +- src/dk/camelot64/kickc/test/ref/minus.log | 46 +- src/dk/camelot64/kickc/test/ref/summin.log | 153 +- 17 files changed, 1254 insertions(+), 1567 deletions(-) create mode 100644 src/dk/camelot64/kickc/passes/Pass1EliminateEmptyBlocks.java diff --git a/src/dk/camelot64/kickc/CompileLog.java b/src/dk/camelot64/kickc/CompileLog.java index 02a112573..770a7f37e 100644 --- a/src/dk/camelot64/kickc/CompileLog.java +++ b/src/dk/camelot64/kickc/CompileLog.java @@ -12,7 +12,7 @@ public class CompileLog { public void append(String msg) { log.append(msg); log.append("\n"); - //System.out.printf(msg+"\n"); + System.out.printf(msg+"\n"); } public StringBuilder getLog() { diff --git a/src/dk/camelot64/kickc/Compiler.java b/src/dk/camelot64/kickc/Compiler.java index acffbbc25..5a9cb74f1 100644 --- a/src/dk/camelot64/kickc/Compiler.java +++ b/src/dk/camelot64/kickc/Compiler.java @@ -150,7 +150,13 @@ public class Compiler { log.append("INITIAL CONTROL FLOW GRAPH"); log.append(program.getGraph().toString(program.getScope())); - Pass1ProcedureCallParameters pass1ProcedureCallParameters = + Pass1EliminateEmptyBlocks pass1EliminateEmptyBlocks = new Pass1EliminateEmptyBlocks(program, log); + boolean blockEliminated = pass1EliminateEmptyBlocks.eliminate(); + if(blockEliminated) { + log.append(program.getGraph().toString(program.getScope())); + } + + Pass1ProcedureCallParameters pass1ProcedureCallParameters = new Pass1ProcedureCallParameters(program); program.setGraph(pass1ProcedureCallParameters.generate()); log.append("CONTROL FLOW GRAPH WITH ASSIGNMENT CALL"); diff --git a/src/dk/camelot64/kickc/icl/ControlFlowGraph.java b/src/dk/camelot64/kickc/icl/ControlFlowGraph.java index 43c4b3b33..56ae8d697 100644 --- a/src/dk/camelot64/kickc/icl/ControlFlowGraph.java +++ b/src/dk/camelot64/kickc/icl/ControlFlowGraph.java @@ -43,6 +43,10 @@ public class ControlFlowGraph { return blocks.values(); } + public void remove(LabelRef label) { + blocks.remove(label); + } + /** Get the assignment of the passed variable. * * @param variable The variable to find the assignment for diff --git a/src/dk/camelot64/kickc/passes/Pass1EliminateEmptyBlocks.java b/src/dk/camelot64/kickc/passes/Pass1EliminateEmptyBlocks.java new file mode 100644 index 000000000..b393f6383 --- /dev/null +++ b/src/dk/camelot64/kickc/passes/Pass1EliminateEmptyBlocks.java @@ -0,0 +1,55 @@ +package dk.camelot64.kickc.passes; + +import dk.camelot64.kickc.CompileLog; +import dk.camelot64.kickc.icl.*; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Eliminate empty blocks in pass 1 (before creating SSA) + */ +public class Pass1EliminateEmptyBlocks { + + private Program program; + private CompileLog log; + + public Pass1EliminateEmptyBlocks(Program program, CompileLog log) { + this.program = program; + this.log = log; + } + + public boolean eliminate() { + ControlFlowGraph graph = program.getGraph(); + Collection blocks = graph.getAllBlocks(); + List removeList = new ArrayList<>(); + for (ControlFlowBlock block : blocks) { + if(block.getLabel().getFullName().equals("@END")) { + continue; + } + if (block.getStatements().isEmpty()) { + List predecessors = graph.getPredecessors(block); + boolean remove = true; + for (ControlFlowBlock predecessor : predecessors) { + if(predecessor.getDefaultSuccessor().equals(block.getLabel())) { + predecessor.setDefaultSuccessor(block.getDefaultSuccessor()); + } else { + remove = false; + } + } + if (remove) { + removeList.add(block.getLabel()); + } + } + } + for (LabelRef labelRef : removeList) { + graph.remove(labelRef); + Label label = program.getScope().getLabel(labelRef); + label.getScope().remove(label); + log.append("Removing empty block "+labelRef); + } + return removeList.size()>0; + } + +} diff --git a/src/dk/camelot64/kickc/test/TestIclJson.java b/src/dk/camelot64/kickc/test/TestIclJson.java index ee88ebffb..1038309b9 100644 --- a/src/dk/camelot64/kickc/test/TestIclJson.java +++ b/src/dk/camelot64/kickc/test/TestIclJson.java @@ -91,7 +91,7 @@ public class TestIclJson extends TestCase { CompileLog log = new CompileLog(); KickCParser.FileContext file = compiler.pass0ParseInput(new ANTLRInputStream(minProgram), log); Program program = compiler.pass1GenerateSSA(file, log); - String json = "{\"scope\":{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"s1\":{\"@type\":\"variable_unversioned\",\"name\":\"s1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"s2\":{\"@type\":\"variable_unversioned\",\"name\":\"s2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"$1\":{\"@type\":\"variable_intermediate\",\"name\":\"$1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"sum\":{\"@type\":\"procedure\",\"name\":\"sum\",\"parameterNames\":[\"a\",\"b\"],\"symbols\":{\"@return\":{\"@type\":\"label\",\"name\":\"@return\",\"intermediate\":false},\"return\":{\"@type\":\"variable_unversioned\",\"name\":\"return\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":8,\"inferredType\":false},\"a\":{\"@type\":\"variable_unversioned\",\"name\":\"a\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":3,\"inferredType\":false},\"b\":{\"@type\":\"variable_unversioned\",\"name\":\"b\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":3,\"inferredType\":false},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"@1\":{\"@type\":\"label\",\"name\":\"@1\",\"intermediate\":true},\"a#0\":{\"@type\":\"variable_versioned\",\"name\":\"a#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#0\":{\"@type\":\"variable_versioned\",\"name\":\"b#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#0\":{\"@type\":\"variable_versioned\",\"name\":\"return#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"a#1\":{\"@type\":\"variable_versioned\",\"name\":\"a#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#1\":{\"@type\":\"variable_versioned\",\"name\":\"b#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#1\":{\"@type\":\"variable_versioned\",\"name\":\"return#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#2\":{\"@type\":\"variable_versioned\",\"name\":\"return#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#3\":{\"@type\":\"variable_versioned\",\"name\":\"return#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#4\":{\"@type\":\"variable_versioned\",\"name\":\"return#4\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#5\":{\"@type\":\"variable_versioned\",\"name\":\"return#5\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"a#2\":{\"@type\":\"variable_versioned\",\"name\":\"a#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#2\":{\"@type\":\"variable_versioned\",\"name\":\"b#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#6\":{\"@type\":\"variable_versioned\",\"name\":\"return#6\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#7\":{\"@type\":\"variable_versioned\",\"name\":\"return#7\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false}},\"intermediateVarCount\":1,\"intermediateLabelCount\":2,\"returnType\":{\"@type\":\"basic\",\"typeName\":\"byte\"}},\"@BEGIN\":{\"@type\":\"label\",\"name\":\"@BEGIN\",\"intermediate\":false},\"@END\":{\"@type\":\"label\",\"name\":\"@END\",\"intermediate\":false},\"@1\":{\"@type\":\"label\",\"name\":\"@1\",\"intermediate\":true},\"@2\":{\"@type\":\"label\",\"name\":\"@2\",\"intermediate\":true},\"@3\":{\"@type\":\"label\",\"name\":\"@3\",\"intermediate\":true},\"s1#0\":{\"@type\":\"variable_versioned\",\"name\":\"s1#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"s1\",\"inferredType\":false},\"s2#0\":{\"@type\":\"variable_versioned\",\"name\":\"s2#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"s2\",\"inferredType\":false}},\"intermediateVarCount\":2,\"intermediateLabelCount\":4,\"allocation\":null},\"graph\":{\"blocks\":{\"@BEGIN\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"statements\":[{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":1}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":2}},{\"@type\":\"call\",\"lValue\":null,\"procedureName\":\"sum\",\"procedure\":{\"@type\":\"procref\",\"fullName\":\"sum\"},\"parameters\":null,\"parametersByAssignment\":true},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"conditionalSuccessor\":null,\"callSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"}},\"@2\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#4\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#0\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#4\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"s1#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$0\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":9}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":13}},{\"@type\":\"call\",\"lValue\":null,\"procedureName\":\"sum\",\"procedure\":{\"@type\":\"procref\",\"fullName\":\"sum\"},\"parameters\":null,\"parametersByAssignment\":true},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"conditionalSuccessor\":null,\"callSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"}},\"@3\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#5\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#1\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#5\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"s2#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$1\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::a#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#0\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::b#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#0\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::$0\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"sum::a#2\"},\"operator\":{\"operator\":\"+\"},\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::b#2\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#2\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::$0\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum::@return\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#6\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#2\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"sum::@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#7\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#6\"}},{\"@type\":\"return\",\"value\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@RETURN\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum::@1\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum::@1\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#7\"},\"values\":[]}]}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@1\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"statements\":[],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@END\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"statements\":[],\"defaultSuccessor\":null,\"conditionalSuccessor\":null,\"callSuccessor\":null}},\"firstBlockRef\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"sequence\":null}}"; + String json = "{\"scope\":{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"s1\":{\"@type\":\"variable_unversioned\",\"name\":\"s1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"s2\":{\"@type\":\"variable_unversioned\",\"name\":\"s2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":1,\"inferredType\":false},\"$1\":{\"@type\":\"variable_intermediate\",\"name\":\"$1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"sum\":{\"@type\":\"procedure\",\"name\":\"sum\",\"parameterNames\":[\"a\",\"b\"],\"symbols\":{\"@return\":{\"@type\":\"label\",\"name\":\"@return\",\"intermediate\":false},\"return\":{\"@type\":\"variable_unversioned\",\"name\":\"return\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":7,\"inferredType\":false},\"a\":{\"@type\":\"variable_unversioned\",\"name\":\"a\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":3,\"inferredType\":false},\"b\":{\"@type\":\"variable_unversioned\",\"name\":\"b\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":3,\"inferredType\":false},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"a#0\":{\"@type\":\"variable_versioned\",\"name\":\"a#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#0\":{\"@type\":\"variable_versioned\",\"name\":\"b#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#0\":{\"@type\":\"variable_versioned\",\"name\":\"return#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"a#1\":{\"@type\":\"variable_versioned\",\"name\":\"a#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#1\":{\"@type\":\"variable_versioned\",\"name\":\"b#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#1\":{\"@type\":\"variable_versioned\",\"name\":\"return#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#2\":{\"@type\":\"variable_versioned\",\"name\":\"return#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#3\":{\"@type\":\"variable_versioned\",\"name\":\"return#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#4\":{\"@type\":\"variable_versioned\",\"name\":\"return#4\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"return#5\":{\"@type\":\"variable_versioned\",\"name\":\"return#5\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false},\"a#2\":{\"@type\":\"variable_versioned\",\"name\":\"a#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"a\",\"inferredType\":false},\"b#2\":{\"@type\":\"variable_versioned\",\"name\":\"b#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"b\",\"inferredType\":false},\"return#6\":{\"@type\":\"variable_versioned\",\"name\":\"return#6\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"return\",\"inferredType\":false}},\"intermediateVarCount\":1,\"intermediateLabelCount\":2,\"returnType\":{\"@type\":\"basic\",\"typeName\":\"byte\"}},\"@BEGIN\":{\"@type\":\"label\",\"name\":\"@BEGIN\",\"intermediate\":false},\"@END\":{\"@type\":\"label\",\"name\":\"@END\",\"intermediate\":false},\"@2\":{\"@type\":\"label\",\"name\":\"@2\",\"intermediate\":true},\"@3\":{\"@type\":\"label\",\"name\":\"@3\",\"intermediate\":true},\"s1#0\":{\"@type\":\"variable_versioned\",\"name\":\"s1#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"s1\",\"inferredType\":false},\"s2#0\":{\"@type\":\"variable_versioned\",\"name\":\"s2#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"s2\",\"inferredType\":false}},\"intermediateVarCount\":2,\"intermediateLabelCount\":4,\"allocation\":null},\"graph\":{\"blocks\":{\"@BEGIN\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"statements\":[{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":1}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":2}},{\"@type\":\"call\",\"lValue\":null,\"procedureName\":\"sum\",\"procedure\":{\"@type\":\"procref\",\"fullName\":\"sum\"},\"parameters\":null,\"parametersByAssignment\":true},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"conditionalSuccessor\":null,\"callSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"}},\"@2\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#4\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#0\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#4\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"s1#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$0\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":9}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":13}},{\"@type\":\"call\",\"lValue\":null,\"procedureName\":\"sum\",\"procedure\":{\"@type\":\"procref\",\"fullName\":\"sum\"},\"parameters\":null,\"parametersByAssignment\":true},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"conditionalSuccessor\":null,\"callSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"}},\"@3\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#5\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#1\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#5\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"s2#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$1\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::a#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::a#0\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::b#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::b#0\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::$0\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"sum::a#2\"},\"operator\":{\"operator\":\"+\"},\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::b#2\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#2\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::$0\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"sum::@return\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"sum::@return\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"sum::return#6\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"sum\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#2\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"sum::return#6\"}},{\"@type\":\"return\",\"value\":{\"@type\":\"varref\",\"fullName\":\"sum::return#3\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@RETURN\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@END\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"statements\":[],\"defaultSuccessor\":null,\"conditionalSuccessor\":null,\"callSuccessor\":null}},\"firstBlockRef\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"sequence\":null}}"; assertJsonSerialization(program, json, Program.class); } @@ -102,7 +102,7 @@ public class TestIclJson extends TestCase { CompileLog log = new CompileLog(); KickCParser.FileContext file = compiler.pass0ParseInput(new ANTLRInputStream(minProgram), log); Program program = compiler.pass1GenerateSSA(file, log); - String json = "{\"scope\":{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"n1\":{\"@type\":\"variable_unversioned\",\"name\":\"n1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":5,\"inferredType\":false},\"n2\":{\"@type\":\"variable_unversioned\",\"name\":\"n2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":5,\"inferredType\":false},\"i\":{\"@type\":\"variable_unversioned\",\"name\":\"i\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":5,\"inferredType\":false},\"fib\":{\"@type\":\"variable_unversioned\",\"name\":\"fib\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":2,\"inferredType\":false},\"@1\":{\"@type\":\"label\",\"name\":\"@1\",\"intermediate\":true},\"@2\":{\"@type\":\"label\",\"name\":\"@2\",\"intermediate\":true},\"@3\":{\"@type\":\"label\",\"name\":\"@3\",\"intermediate\":true},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"boolean\"},\"inferredType\":true},\"$1\":{\"@type\":\"variable_intermediate\",\"name\":\"$1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"$2\":{\"@type\":\"variable_intermediate\",\"name\":\"$2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"@BEGIN\":{\"@type\":\"label\",\"name\":\"@BEGIN\",\"intermediate\":false},\"@END\":{\"@type\":\"label\",\"name\":\"@END\",\"intermediate\":false},\"@4\":{\"@type\":\"label\",\"name\":\"@4\",\"intermediate\":true},\"@5\":{\"@type\":\"label\",\"name\":\"@5\",\"intermediate\":true},\"@6\":{\"@type\":\"label\",\"name\":\"@6\",\"intermediate\":true},\"n1#0\":{\"@type\":\"variable_versioned\",\"name\":\"n1#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#0\":{\"@type\":\"variable_versioned\",\"name\":\"n2#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#0\":{\"@type\":\"variable_versioned\",\"name\":\"i#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"fib#0\":{\"@type\":\"variable_versioned\",\"name\":\"fib#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"fib\",\"inferredType\":false},\"fib#1\":{\"@type\":\"variable_versioned\",\"name\":\"fib#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"fib\",\"inferredType\":false},\"n1#1\":{\"@type\":\"variable_versioned\",\"name\":\"n1#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#1\":{\"@type\":\"variable_versioned\",\"name\":\"n2#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#1\":{\"@type\":\"variable_versioned\",\"name\":\"i#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"i#2\":{\"@type\":\"variable_versioned\",\"name\":\"i#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"n1#2\":{\"@type\":\"variable_versioned\",\"name\":\"n1#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#2\":{\"@type\":\"variable_versioned\",\"name\":\"n2#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#3\":{\"@type\":\"variable_versioned\",\"name\":\"i#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"n1#3\":{\"@type\":\"variable_versioned\",\"name\":\"n1#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n1#4\":{\"@type\":\"variable_versioned\",\"name\":\"n1#4\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#3\":{\"@type\":\"variable_versioned\",\"name\":\"n2#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"n2#4\":{\"@type\":\"variable_versioned\",\"name\":\"n2#4\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#4\":{\"@type\":\"variable_versioned\",\"name\":\"i#4\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false}},\"intermediateVarCount\":3,\"intermediateLabelCount\":7,\"allocation\":null},\"graph\":{\"blocks\":{\"@BEGIN\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"statements\":[{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n1#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":0}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n2#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":1}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"i#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":12}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"fib#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":0}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@1\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"i#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#0\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n1#3\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#0\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n2#3\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#0\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"i#2\"},\"operator\":{\"operator\":\">\"},\"rValue2\":{\"@type\":\"integer\",\"number\":0}},{\"@type\":\"cond\",\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"destination\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rvalue1\":null,\"rvalue2\":{\"@type\":\"varref\",\"fullName\":\"$0\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@4\"},\"conditionalSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"callSuccessor\":null},\"@2\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n1#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#3\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@5\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#4\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n2#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#3\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@5\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#4\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"i#3\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#2\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@5\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#4\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$1\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"n1#2\"},\"operator\":{\"operator\":\"+\"},\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"n2#2\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"fib#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$1\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n1#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"n2#2\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n2#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"fib#1\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$2\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"i#3\"},\"operator\":{\"operator\":\"-\"},\"rValue2\":{\"@type\":\"integer\",\"number\":1}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"i#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$2\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@4\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@4\"},\"statements\":[],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@3\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"statements\":[],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@5\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@5\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n1#4\"},\"values\":[]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n2#4\"},\"values\":[]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"i#4\"},\"values\":[]}]}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@6\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@6\"},\"statements\":[],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@3\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@END\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"statements\":[],\"defaultSuccessor\":null,\"conditionalSuccessor\":null,\"callSuccessor\":null}},\"firstBlockRef\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"sequence\":null}}"; + String json = "{\"scope\":{\"@type\":\"program\",\"name\":\"\",\"symbols\":{\"n1\":{\"@type\":\"variable_unversioned\",\"name\":\"n1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":4,\"inferredType\":false},\"n2\":{\"@type\":\"variable_unversioned\",\"name\":\"n2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":4,\"inferredType\":false},\"i\":{\"@type\":\"variable_unversioned\",\"name\":\"i\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":4,\"inferredType\":false},\"fib\":{\"@type\":\"variable_unversioned\",\"name\":\"fib\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"nextVersionNumber\":2,\"inferredType\":false},\"@1\":{\"@type\":\"label\",\"name\":\"@1\",\"intermediate\":true},\"@2\":{\"@type\":\"label\",\"name\":\"@2\",\"intermediate\":true},\"$0\":{\"@type\":\"variable_intermediate\",\"name\":\"$0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"boolean\"},\"inferredType\":true},\"$1\":{\"@type\":\"variable_intermediate\",\"name\":\"$1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"$2\":{\"@type\":\"variable_intermediate\",\"name\":\"$2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"inferredType\":true},\"@BEGIN\":{\"@type\":\"label\",\"name\":\"@BEGIN\",\"intermediate\":false},\"@END\":{\"@type\":\"label\",\"name\":\"@END\",\"intermediate\":false},\"n1#0\":{\"@type\":\"variable_versioned\",\"name\":\"n1#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#0\":{\"@type\":\"variable_versioned\",\"name\":\"n2#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#0\":{\"@type\":\"variable_versioned\",\"name\":\"i#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"fib#0\":{\"@type\":\"variable_versioned\",\"name\":\"fib#0\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"fib\",\"inferredType\":false},\"fib#1\":{\"@type\":\"variable_versioned\",\"name\":\"fib#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"fib\",\"inferredType\":false},\"n1#1\":{\"@type\":\"variable_versioned\",\"name\":\"n1#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#1\":{\"@type\":\"variable_versioned\",\"name\":\"n2#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#1\":{\"@type\":\"variable_versioned\",\"name\":\"i#1\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"i#2\":{\"@type\":\"variable_versioned\",\"name\":\"i#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"n1#2\":{\"@type\":\"variable_versioned\",\"name\":\"n1#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#2\":{\"@type\":\"variable_versioned\",\"name\":\"n2#2\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false},\"i#3\":{\"@type\":\"variable_versioned\",\"name\":\"i#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"i\",\"inferredType\":false},\"n1#3\":{\"@type\":\"variable_versioned\",\"name\":\"n1#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n1\",\"inferredType\":false},\"n2#3\":{\"@type\":\"variable_versioned\",\"name\":\"n2#3\",\"type\":{\"@type\":\"basic\",\"typeName\":\"byte\"},\"versionOfName\":\"n2\",\"inferredType\":false}},\"intermediateVarCount\":3,\"intermediateLabelCount\":7,\"allocation\":null},\"graph\":{\"blocks\":{\"@BEGIN\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"statements\":[{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n1#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":0}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n2#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":1}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"i#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":12}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"fib#0\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"integer\",\"number\":0}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@1\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"i#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#0\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n1#3\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#0\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n2#3\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#1\"}},{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#0\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"i#2\"},\"operator\":{\"operator\":\">\"},\"rValue2\":{\"@type\":\"integer\",\"number\":0}},{\"@type\":\"cond\",\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$0\"},\"destination\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"rvalue1\":null,\"rvalue2\":{\"@type\":\"varref\",\"fullName\":\"$0\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"conditionalSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"callSuccessor\":null},\"@2\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@2\"},\"statements\":[{\"@type\":\"phiblock\",\"phiVariables\":[{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n1#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n1#3\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"n2#2\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"n2#3\"}}]},{\"variable\":{\"@type\":\"varref\",\"fullName\":\"i#3\"},\"values\":[{\"predecessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"rValue\":{\"@type\":\"varref\",\"fullName\":\"i#2\"}}]}]},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$1\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"n1#2\"},\"operator\":{\"operator\":\"+\"},\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"n2#2\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"fib#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$1\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n1#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"n2#2\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"n2#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"fib#1\"}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"$2\"},\"rValue1\":{\"@type\":\"varref\",\"fullName\":\"i#3\"},\"operator\":{\"operator\":\"-\"},\"rValue2\":{\"@type\":\"integer\",\"number\":1}},{\"@type\":\"assign\",\"lValue\":{\"@type\":\"varref\",\"fullName\":\"i#1\"},\"rValue1\":null,\"operator\":null,\"rValue2\":{\"@type\":\"varref\",\"fullName\":\"$2\"}}],\"defaultSuccessor\":{\"@type\":\"labelref\",\"fullName\":\"@1\"},\"conditionalSuccessor\":null,\"callSuccessor\":null},\"@END\":{\"label\":{\"@type\":\"labelref\",\"fullName\":\"@END\"},\"statements\":[],\"defaultSuccessor\":null,\"conditionalSuccessor\":null,\"callSuccessor\":null}},\"firstBlockRef\":{\"@type\":\"labelref\",\"fullName\":\"@BEGIN\"},\"sequence\":null}}"; assertJsonSerialization(program, json, Program.class); } diff --git a/src/dk/camelot64/kickc/test/ref/bresenham.cfg b/src/dk/camelot64/kickc/test/ref/bresenham.cfg index 076c424ba..bcf651b28 100644 --- a/src/dk/camelot64/kickc/test/ref/bresenham.cfg +++ b/src/dk/camelot64/kickc/test/ref/bresenham.cfg @@ -1,7 +1,7 @@ @BEGIN: from to:@1 @1: from @3 @BEGIN - (byte) y#2 ← phi( @3/(byte) y#5 @BEGIN/(byte) 0 ) + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) 0 ) (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) 12 ) (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) 0 ) (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(word) 1024 ) @@ -17,7 +17,7 @@ (byte) e#2 ← (byte) e#1 - (byte) 39 to:@3 @3: from @1 @2 - (byte) y#5 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) if((byte) x#1<(byte) 40) goto @1 diff --git a/src/dk/camelot64/kickc/test/ref/bresenham.log b/src/dk/camelot64/kickc/test/ref/bresenham.log index 6e37784e4..1a1382b09 100644 --- a/src/dk/camelot64/kickc/test/ref/bresenham.log +++ b/src/dk/camelot64/kickc/test/ref/bresenham.log @@ -149,6 +149,55 @@ INITIAL CONTROL FLOW GRAPH to:@END @END: from @6 +Removing empty block @4 +Removing empty block @5 +Removing empty block @6 +@BEGIN: from + (byte) STAR ← (byte) 81 + (byte[1000]) SCREEN ← (word) 1024 + (byte) x0 ← (byte) 0 + (byte) y0 ← (byte) 0 + (byte) x1 ← (byte) 39 + (byte) y1 ← (byte) 24 + (byte~) $0 ← (byte) x1 - (byte) x0 + (byte) xd ← (byte~) $0 + (byte~) $1 ← (byte) y1 - (byte) y0 + (byte) yd ← (byte~) $1 + (byte) x ← (byte) x0 + (byte) y ← (byte) y0 + (byte~) $2 ← (byte) yd / (byte) 2 + (byte) e ← (byte~) $2 + (byte~) $3 ← (byte) y * (byte) 40 + (byte*~) $4 ← (byte[1000]) SCREEN + (byte~) $3 + (byte*~) $5 ← (byte*~) $4 + (byte) x + (byte*) cursor ← (byte*~) $5 + to:@1 +@1: from @3 @BEGIN + *((byte*) cursor) ← (byte) STAR + (byte~) $6 ← (byte) x + (byte) 1 + (byte) x ← (byte~) $6 + (byte*~) $7 ← (byte*) cursor + (byte) 1 + (byte*) cursor ← (byte*~) $7 + (byte~) $8 ← (byte) e + (byte) yd + (byte) e ← (byte~) $8 + (boolean~) $9 ← (byte) xd < (byte) e + if((boolean~) $9) goto @2 + to:@3 +@2: from @1 + (byte~) $10 ← (byte) y + (byte) 1 + (byte) y ← (byte~) $10 + (byte*~) $11 ← (byte*) cursor + (byte) 40 + (byte*) cursor ← (byte*~) $11 + (byte~) $12 ← (byte) e - (byte) xd + (byte) e ← (byte~) $12 + to:@3 +@3: from @1 @2 + (byte~) $13 ← (byte) x1 + (byte) 1 + (boolean~) $14 ← (byte) x < (byte~) $13 + if((boolean~) $14) goto @1 + to:@END +@END: from @3 + CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @BEGIN: from (byte) STAR ← (byte) 81 @@ -180,8 +229,8 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL (byte) e ← (byte~) $8 (boolean~) $9 ← (byte) xd < (byte) e if((boolean~) $9) goto @2 - to:@4 -@2: from @1 @5 + to:@3 +@2: from @1 (byte~) $10 ← (byte) y + (byte) 1 (byte) y ← (byte~) $10 (byte*~) $11 ← (byte*) cursor + (byte) 40 @@ -189,23 +238,16 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL (byte~) $12 ← (byte) e - (byte) xd (byte) e ← (byte~) $12 to:@3 -@4: from @1 - to:@3 -@3: from @2 @4 +@3: from @1 @2 (byte~) $13 ← (byte) x1 + (byte) 1 (boolean~) $14 ← (byte) x < (byte~) $13 if((boolean~) $14) goto @1 - to:@6 -@5: from - to:@2 -@6: from @3 to:@END -@END: from @6 +@END: from @3 Completing Phi functions... Completing Phi functions... Completing Phi functions... -Completing Phi functions... CONTROL FLOW GRAPH SSA @BEGIN: from (byte) STAR#0 ← (byte) 81 @@ -228,8 +270,8 @@ CONTROL FLOW GRAPH SSA (byte*) cursor#0 ← (byte*~) $5 to:@1 @1: from @3 @BEGIN - (byte) x1#4 ← phi( @3/(byte) x1#1 @BEGIN/(byte) x1#0 ) - (byte) y#3 ← phi( @3/(byte) y#5 @BEGIN/(byte) y#0 ) + (byte) x1#2 ← phi( @3/(byte) x1#1 @BEGIN/(byte) x1#0 ) + (byte) y#3 ← phi( @3/(byte) y#4 @BEGIN/(byte) y#0 ) (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) xd#0 ) (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) yd#0 ) (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) @@ -245,16 +287,16 @@ CONTROL FLOW GRAPH SSA (byte) e#1 ← (byte~) $8 (boolean~) $9 ← (byte) xd#1 < (byte) e#1 if((boolean~) $9) goto @2 - to:@4 -@2: from @1 @5 - (byte) yd#3 ← phi( @1/(byte) yd#1 @5/(byte) yd#5 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 @5/(byte) STAR#5 ) - (byte) x#4 ← phi( @1/(byte) x#1 @5/(byte) x#6 ) - (byte) x1#2 ← phi( @1/(byte) x1#4 @5/(byte) x1#5 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 @5/(byte) xd#4 ) - (byte) e#4 ← phi( @1/(byte) e#1 @5/(byte) e#6 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 @5/(byte*) cursor#6 ) - (byte) y#2 ← phi( @1/(byte) y#3 @5/(byte) y#4 ) + to:@3 +@2: from @1 + (byte) yd#3 ← phi( @1/(byte) yd#1 ) + (byte) STAR#3 ← phi( @1/(byte) STAR#1 ) + (byte) x#4 ← phi( @1/(byte) x#1 ) + (byte) x1#3 ← phi( @1/(byte) x1#2 ) + (byte) xd#2 ← phi( @1/(byte) xd#1 ) + (byte) e#4 ← phi( @1/(byte) e#1 ) + (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 ) + (byte) y#2 ← phi( @1/(byte) y#3 ) (byte~) $10 ← (byte) y#2 + (byte) 1 (byte) y#1 ← (byte~) $10 (byte*~) $11 ← (byte*) cursor#4 + (byte) 40 @@ -262,42 +304,20 @@ CONTROL FLOW GRAPH SSA (byte~) $12 ← (byte) e#4 - (byte) xd#2 (byte) e#2 ← (byte~) $12 to:@3 -@4: from @1 - (byte) y#6 ← phi( @1/(byte) y#3 ) - (byte) xd#5 ← phi( @1/(byte) xd#1 ) - (byte) yd#4 ← phi( @1/(byte) yd#1 ) - (byte) e#7 ← phi( @1/(byte) e#1 ) - (byte*) cursor#7 ← phi( @1/(byte*) cursor#1 ) - (byte) STAR#4 ← phi( @1/(byte) STAR#1 ) - (byte) x#5 ← phi( @1/(byte) x#1 ) - (byte) x1#3 ← phi( @1/(byte) x1#4 ) - to:@3 -@3: from @2 @4 - (byte) y#5 ← phi( @2/(byte) y#1 @4/(byte) y#6 ) - (byte) xd#3 ← phi( @2/(byte) xd#2 @4/(byte) xd#5 ) - (byte) yd#2 ← phi( @2/(byte) yd#3 @4/(byte) yd#4 ) - (byte) e#5 ← phi( @2/(byte) e#2 @4/(byte) e#7 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @4/(byte*) cursor#7 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#3 @4/(byte) STAR#4 ) - (byte) x#3 ← phi( @2/(byte) x#4 @4/(byte) x#5 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @4/(byte) x1#3 ) +@3: from @1 @2 + (byte) y#4 ← phi( @1/(byte) y#3 @2/(byte) y#1 ) + (byte) xd#3 ← phi( @1/(byte) xd#1 @2/(byte) xd#2 ) + (byte) yd#2 ← phi( @1/(byte) yd#1 @2/(byte) yd#3 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) + (byte) STAR#2 ← phi( @1/(byte) STAR#1 @2/(byte) STAR#3 ) + (byte) x#3 ← phi( @1/(byte) x#1 @2/(byte) x#4 ) + (byte) x1#1 ← phi( @1/(byte) x1#2 @2/(byte) x1#3 ) (byte~) $13 ← (byte) x1#1 + (byte) 1 (boolean~) $14 ← (byte) x#3 < (byte~) $13 if((boolean~) $14) goto @1 - to:@6 -@5: from - (byte) yd#5 ← phi( ) - (byte) STAR#5 ← phi( ) - (byte) x#6 ← phi( ) - (byte) x1#5 ← phi( ) - (byte) xd#4 ← phi( ) - (byte) e#6 ← phi( ) - (byte*) cursor#6 ← phi( ) - (byte) y#4 ← phi( ) - to:@2 -@6: from @3 to:@END -@END: from @6 +@END: from @3 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @BEGIN: from @@ -321,8 +341,8 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN (byte*) cursor#0 ← (byte*~) $5 to:@1 @1: from @3 @BEGIN - (byte) x1#4 ← phi( @3/(byte) x1#1 @BEGIN/(byte) x1#0 ) - (byte) y#3 ← phi( @3/(byte) y#5 @BEGIN/(byte) y#0 ) + (byte) x1#2 ← phi( @3/(byte) x1#1 @BEGIN/(byte) x1#0 ) + (byte) y#3 ← phi( @3/(byte) y#4 @BEGIN/(byte) y#0 ) (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) xd#0 ) (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) yd#0 ) (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) @@ -338,16 +358,16 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN (byte) e#1 ← (byte~) $8 (boolean~) $9 ← (byte) xd#1 < (byte) e#1 if((boolean~) $9) goto @2 - to:@4 -@2: from @1 @5 - (byte) yd#3 ← phi( @1/(byte) yd#1 @5/(byte) yd#5 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 @5/(byte) STAR#5 ) - (byte) x#4 ← phi( @1/(byte) x#1 @5/(byte) x#6 ) - (byte) x1#2 ← phi( @1/(byte) x1#4 @5/(byte) x1#5 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 @5/(byte) xd#4 ) - (byte) e#4 ← phi( @1/(byte) e#1 @5/(byte) e#6 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 @5/(byte*) cursor#6 ) - (byte) y#2 ← phi( @1/(byte) y#3 @5/(byte) y#4 ) + to:@3 +@2: from @1 + (byte) yd#3 ← phi( @1/(byte) yd#1 ) + (byte) STAR#3 ← phi( @1/(byte) STAR#1 ) + (byte) x#4 ← phi( @1/(byte) x#1 ) + (byte) x1#3 ← phi( @1/(byte) x1#2 ) + (byte) xd#2 ← phi( @1/(byte) xd#1 ) + (byte) e#4 ← phi( @1/(byte) e#1 ) + (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 ) + (byte) y#2 ← phi( @1/(byte) y#3 ) (byte~) $10 ← (byte) y#2 + (byte) 1 (byte) y#1 ← (byte~) $10 (byte*~) $11 ← (byte*) cursor#4 + (byte) 40 @@ -355,134 +375,19 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN (byte~) $12 ← (byte) e#4 - (byte) xd#2 (byte) e#2 ← (byte~) $12 to:@3 -@4: from @1 - (byte) y#6 ← phi( @1/(byte) y#3 ) - (byte) xd#5 ← phi( @1/(byte) xd#1 ) - (byte) yd#4 ← phi( @1/(byte) yd#1 ) - (byte) e#7 ← phi( @1/(byte) e#1 ) - (byte*) cursor#7 ← phi( @1/(byte*) cursor#1 ) - (byte) STAR#4 ← phi( @1/(byte) STAR#1 ) - (byte) x#5 ← phi( @1/(byte) x#1 ) - (byte) x1#3 ← phi( @1/(byte) x1#4 ) - to:@3 -@3: from @2 @4 - (byte) y#5 ← phi( @2/(byte) y#1 @4/(byte) y#6 ) - (byte) xd#3 ← phi( @2/(byte) xd#2 @4/(byte) xd#5 ) - (byte) yd#2 ← phi( @2/(byte) yd#3 @4/(byte) yd#4 ) - (byte) e#5 ← phi( @2/(byte) e#2 @4/(byte) e#7 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @4/(byte*) cursor#7 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#3 @4/(byte) STAR#4 ) - (byte) x#3 ← phi( @2/(byte) x#4 @4/(byte) x#5 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @4/(byte) x1#3 ) - (byte~) $13 ← (byte) x1#1 + (byte) 1 - (boolean~) $14 ← (byte) x#3 < (byte~) $13 - if((boolean~) $14) goto @1 - to:@6 -@5: from - (byte) yd#5 ← phi( ) - (byte) STAR#5 ← phi( ) - (byte) x#6 ← phi( ) - (byte) x1#5 ← phi( ) - (byte) xd#4 ← phi( ) - (byte) e#6 ← phi( ) - (byte*) cursor#6 ← phi( ) - (byte) y#4 ← phi( ) - to:@2 -@6: from @3 - to:@END -@END: from @6 - -Culled Empty Block (label) @6 -Succesful SSA optimization Pass2CullEmptyBlocks -CONTROL FLOW GRAPH -@BEGIN: from - (byte) STAR#0 ← (byte) 81 - (byte[1000]) SCREEN#0 ← (word) 1024 - (byte) x0#0 ← (byte) 0 - (byte) y0#0 ← (byte) 0 - (byte) x1#0 ← (byte) 39 - (byte) y1#0 ← (byte) 24 - (byte~) $0 ← (byte) x1#0 - (byte) x0#0 - (byte) xd#0 ← (byte~) $0 - (byte~) $1 ← (byte) y1#0 - (byte) y0#0 - (byte) yd#0 ← (byte~) $1 - (byte) x#0 ← (byte) x0#0 - (byte) y#0 ← (byte) y0#0 - (byte~) $2 ← (byte) yd#0 / (byte) 2 - (byte) e#0 ← (byte~) $2 - (byte~) $3 ← (byte) y#0 * (byte) 40 - (byte*~) $4 ← (byte[1000]) SCREEN#0 + (byte~) $3 - (byte*~) $5 ← (byte*~) $4 + (byte) x#0 - (byte*) cursor#0 ← (byte*~) $5 - to:@1 -@1: from @3 @BEGIN - (byte) x1#4 ← phi( @3/(byte) x1#1 @BEGIN/(byte) x1#0 ) - (byte) y#3 ← phi( @3/(byte) y#5 @BEGIN/(byte) y#0 ) - (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) xd#0 ) - (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) yd#0 ) - (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) - (byte) x#2 ← phi( @3/(byte) x#3 @BEGIN/(byte) x#0 ) - (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @3/(byte) STAR#2 @BEGIN/(byte) STAR#0 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte~) $6 ← (byte) x#2 + (byte) 1 - (byte) x#1 ← (byte~) $6 - (byte*~) $7 ← (byte*) cursor#3 + (byte) 1 - (byte*) cursor#1 ← (byte*~) $7 - (byte~) $8 ← (byte) e#3 + (byte) yd#1 - (byte) e#1 ← (byte~) $8 - (boolean~) $9 ← (byte) xd#1 < (byte) e#1 - if((boolean~) $9) goto @2 - to:@4 -@2: from @1 @5 - (byte) yd#3 ← phi( @1/(byte) yd#1 @5/(byte) yd#5 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 @5/(byte) STAR#5 ) - (byte) x#4 ← phi( @1/(byte) x#1 @5/(byte) x#6 ) - (byte) x1#2 ← phi( @1/(byte) x1#4 @5/(byte) x1#5 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 @5/(byte) xd#4 ) - (byte) e#4 ← phi( @1/(byte) e#1 @5/(byte) e#6 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 @5/(byte*) cursor#6 ) - (byte) y#2 ← phi( @1/(byte) y#3 @5/(byte) y#4 ) - (byte~) $10 ← (byte) y#2 + (byte) 1 - (byte) y#1 ← (byte~) $10 - (byte*~) $11 ← (byte*) cursor#4 + (byte) 40 - (byte*) cursor#2 ← (byte*~) $11 - (byte~) $12 ← (byte) e#4 - (byte) xd#2 - (byte) e#2 ← (byte~) $12 - to:@3 -@4: from @1 - (byte) y#6 ← phi( @1/(byte) y#3 ) - (byte) xd#5 ← phi( @1/(byte) xd#1 ) - (byte) yd#4 ← phi( @1/(byte) yd#1 ) - (byte) e#7 ← phi( @1/(byte) e#1 ) - (byte*) cursor#7 ← phi( @1/(byte*) cursor#1 ) - (byte) STAR#4 ← phi( @1/(byte) STAR#1 ) - (byte) x#5 ← phi( @1/(byte) x#1 ) - (byte) x1#3 ← phi( @1/(byte) x1#4 ) - to:@3 -@3: from @2 @4 - (byte) y#5 ← phi( @2/(byte) y#1 @4/(byte) y#6 ) - (byte) xd#3 ← phi( @2/(byte) xd#2 @4/(byte) xd#5 ) - (byte) yd#2 ← phi( @2/(byte) yd#3 @4/(byte) yd#4 ) - (byte) e#5 ← phi( @2/(byte) e#2 @4/(byte) e#7 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @4/(byte*) cursor#7 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#3 @4/(byte) STAR#4 ) - (byte) x#3 ← phi( @2/(byte) x#4 @4/(byte) x#5 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @4/(byte) x1#3 ) +@3: from @1 @2 + (byte) y#4 ← phi( @1/(byte) y#3 @2/(byte) y#1 ) + (byte) xd#3 ← phi( @1/(byte) xd#1 @2/(byte) xd#2 ) + (byte) yd#2 ← phi( @1/(byte) yd#1 @2/(byte) yd#3 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) + (byte) STAR#2 ← phi( @1/(byte) STAR#1 @2/(byte) STAR#3 ) + (byte) x#3 ← phi( @1/(byte) x#1 @2/(byte) x#4 ) + (byte) x1#1 ← phi( @1/(byte) x1#2 @2/(byte) x1#3 ) (byte~) $13 ← (byte) x1#1 + (byte) 1 (boolean~) $14 ← (byte) x#3 < (byte~) $13 if((boolean~) $14) goto @1 to:@END -@5: from - (byte) yd#5 ← phi( ) - (byte) STAR#5 ← phi( ) - (byte) x#6 ← phi( ) - (byte) x1#5 ← phi( ) - (byte) xd#4 ← phi( ) - (byte) e#6 ← phi( ) - (byte*) cursor#6 ← phi( ) - (byte) y#4 ← phi( ) - to:@2 @END: from @3 Constant (byte) STAR#0 (byte) 81 @@ -508,8 +413,8 @@ CONTROL FLOW GRAPH (byte*) cursor#0 ← (byte*~) $5 to:@1 @1: from @3 @BEGIN - (byte) x1#4 ← phi( @3/(byte) x1#1 @BEGIN/(byte) 39 ) - (byte) y#3 ← phi( @3/(byte) y#5 @BEGIN/(byte) y#0 ) + (byte) x1#2 ← phi( @3/(byte) x1#1 @BEGIN/(byte) 39 ) + (byte) y#3 ← phi( @3/(byte) y#4 @BEGIN/(byte) y#0 ) (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) xd#0 ) (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) yd#0 ) (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) @@ -525,16 +430,16 @@ CONTROL FLOW GRAPH (byte) e#1 ← (byte~) $8 (boolean~) $9 ← (byte) xd#1 < (byte) e#1 if((boolean~) $9) goto @2 - to:@4 -@2: from @1 @5 - (byte) yd#3 ← phi( @1/(byte) yd#1 @5/(byte) yd#5 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 @5/(byte) STAR#5 ) - (byte) x#4 ← phi( @1/(byte) x#1 @5/(byte) x#6 ) - (byte) x1#2 ← phi( @1/(byte) x1#4 @5/(byte) x1#5 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 @5/(byte) xd#4 ) - (byte) e#4 ← phi( @1/(byte) e#1 @5/(byte) e#6 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 @5/(byte*) cursor#6 ) - (byte) y#2 ← phi( @1/(byte) y#3 @5/(byte) y#4 ) + to:@3 +@2: from @1 + (byte) yd#3 ← phi( @1/(byte) yd#1 ) + (byte) STAR#3 ← phi( @1/(byte) STAR#1 ) + (byte) x#4 ← phi( @1/(byte) x#1 ) + (byte) x1#3 ← phi( @1/(byte) x1#2 ) + (byte) xd#2 ← phi( @1/(byte) xd#1 ) + (byte) e#4 ← phi( @1/(byte) e#1 ) + (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 ) + (byte) y#2 ← phi( @1/(byte) y#3 ) (byte~) $10 ← (byte) y#2 + (byte) 1 (byte) y#1 ← (byte~) $10 (byte*~) $11 ← (byte*) cursor#4 + (byte) 40 @@ -542,39 +447,19 @@ CONTROL FLOW GRAPH (byte~) $12 ← (byte) e#4 - (byte) xd#2 (byte) e#2 ← (byte~) $12 to:@3 -@4: from @1 - (byte) y#6 ← phi( @1/(byte) y#3 ) - (byte) xd#5 ← phi( @1/(byte) xd#1 ) - (byte) yd#4 ← phi( @1/(byte) yd#1 ) - (byte) e#7 ← phi( @1/(byte) e#1 ) - (byte*) cursor#7 ← phi( @1/(byte*) cursor#1 ) - (byte) STAR#4 ← phi( @1/(byte) STAR#1 ) - (byte) x#5 ← phi( @1/(byte) x#1 ) - (byte) x1#3 ← phi( @1/(byte) x1#4 ) - to:@3 -@3: from @2 @4 - (byte) y#5 ← phi( @2/(byte) y#1 @4/(byte) y#6 ) - (byte) xd#3 ← phi( @2/(byte) xd#2 @4/(byte) xd#5 ) - (byte) yd#2 ← phi( @2/(byte) yd#3 @4/(byte) yd#4 ) - (byte) e#5 ← phi( @2/(byte) e#2 @4/(byte) e#7 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @4/(byte*) cursor#7 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#3 @4/(byte) STAR#4 ) - (byte) x#3 ← phi( @2/(byte) x#4 @4/(byte) x#5 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @4/(byte) x1#3 ) +@3: from @1 @2 + (byte) y#4 ← phi( @1/(byte) y#3 @2/(byte) y#1 ) + (byte) xd#3 ← phi( @1/(byte) xd#1 @2/(byte) xd#2 ) + (byte) yd#2 ← phi( @1/(byte) yd#1 @2/(byte) yd#3 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) + (byte) STAR#2 ← phi( @1/(byte) STAR#1 @2/(byte) STAR#3 ) + (byte) x#3 ← phi( @1/(byte) x#1 @2/(byte) x#4 ) + (byte) x1#1 ← phi( @1/(byte) x1#2 @2/(byte) x1#3 ) (byte~) $13 ← (byte) x1#1 + (byte) 1 (boolean~) $14 ← (byte) x#3 < (byte~) $13 if((boolean~) $14) goto @1 to:@END -@5: from - (byte) yd#5 ← phi( ) - (byte) STAR#5 ← phi( ) - (byte) x#6 ← phi( ) - (byte) x1#5 ← phi( ) - (byte) xd#4 ← phi( ) - (byte) e#6 ← phi( ) - (byte*) cursor#6 ← phi( ) - (byte) y#4 ← phi( ) - to:@2 @END: from @3 Multiple usages for variable. Not optimizing sub-constant (byte) x1#1 @@ -582,17 +467,17 @@ Alias (byte) xd#0 = (byte~) $0 Alias (byte) yd#0 = (byte~) $1 Alias (byte) e#0 = (byte~) $2 Alias (byte*) cursor#0 = (byte*~) $5 -Alias (byte) x#1 = (byte~) $6 (byte) x#5 -Alias (byte*) cursor#1 = (byte*~) $7 (byte*) cursor#7 -Alias (byte) e#1 = (byte~) $8 (byte) e#7 +Alias (byte) x#1 = (byte~) $6 (byte) x#4 +Alias (byte*) cursor#1 = (byte*~) $7 (byte*) cursor#4 +Alias (byte) e#1 = (byte~) $8 (byte) e#4 +Alias (byte) y#2 = (byte) y#3 +Alias (byte) xd#1 = (byte) xd#2 +Alias (byte) x1#2 = (byte) x1#3 +Alias (byte) STAR#1 = (byte) STAR#3 +Alias (byte) yd#1 = (byte) yd#3 Alias (byte) y#1 = (byte~) $10 Alias (byte*) cursor#2 = (byte*~) $11 Alias (byte) e#2 = (byte~) $12 -Alias (byte) x1#3 = (byte) x1#4 -Alias (byte) STAR#1 = (byte) STAR#4 -Alias (byte) yd#1 = (byte) yd#4 -Alias (byte) xd#1 = (byte) xd#5 -Alias (byte) y#3 = (byte) y#6 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @BEGIN: from @@ -606,8 +491,8 @@ CONTROL FLOW GRAPH (byte*) cursor#0 ← (byte*~) $4 + (byte) x#0 to:@1 @1: from @3 @BEGIN - (byte) x1#3 ← phi( @3/(byte) x1#1 @BEGIN/(byte) 39 ) - (byte) y#3 ← phi( @3/(byte) y#5 @BEGIN/(byte) y#0 ) + (byte) x1#2 ← phi( @3/(byte) x1#1 @BEGIN/(byte) 39 ) + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) y#0 ) (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) xd#0 ) (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) yd#0 ) (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) @@ -620,55 +505,32 @@ CONTROL FLOW GRAPH (byte) e#1 ← (byte) e#3 + (byte) yd#1 (boolean~) $9 ← (byte) xd#1 < (byte) e#1 if((boolean~) $9) goto @2 - to:@4 -@2: from @1 @5 - (byte) yd#3 ← phi( @1/(byte) yd#1 @5/(byte) yd#5 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 @5/(byte) STAR#5 ) - (byte) x#4 ← phi( @1/(byte) x#1 @5/(byte) x#6 ) - (byte) x1#2 ← phi( @1/(byte) x1#3 @5/(byte) x1#5 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 @5/(byte) xd#4 ) - (byte) e#4 ← phi( @1/(byte) e#1 @5/(byte) e#6 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 @5/(byte*) cursor#6 ) - (byte) y#2 ← phi( @1/(byte) y#3 @5/(byte) y#4 ) + to:@3 +@2: from @1 (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#4 + (byte) 40 - (byte) e#2 ← (byte) e#4 - (byte) xd#2 + (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 + (byte) e#2 ← (byte) e#1 - (byte) xd#1 to:@3 -@4: from @1 - to:@3 -@3: from @2 @4 - (byte) y#5 ← phi( @2/(byte) y#1 @4/(byte) y#3 ) - (byte) xd#3 ← phi( @2/(byte) xd#2 @4/(byte) xd#1 ) - (byte) yd#2 ← phi( @2/(byte) yd#3 @4/(byte) yd#1 ) - (byte) e#5 ← phi( @2/(byte) e#2 @4/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @4/(byte*) cursor#1 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#3 @4/(byte) STAR#1 ) - (byte) x#3 ← phi( @2/(byte) x#4 @4/(byte) x#1 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @4/(byte) x1#3 ) +@3: from @1 @2 + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) xd#3 ← phi( @1/(byte) xd#1 @2/(byte) xd#1 ) + (byte) yd#2 ← phi( @1/(byte) yd#1 @2/(byte) yd#1 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) + (byte) STAR#2 ← phi( @1/(byte) STAR#1 @2/(byte) STAR#1 ) + (byte) x#3 ← phi( @1/(byte) x#1 @2/(byte) x#1 ) + (byte) x1#1 ← phi( @1/(byte) x1#2 @2/(byte) x1#2 ) (byte~) $13 ← (byte) x1#1 + (byte) 1 (boolean~) $14 ← (byte) x#3 < (byte~) $13 if((boolean~) $14) goto @1 to:@END -@5: from - (byte) yd#5 ← phi( ) - (byte) STAR#5 ← phi( ) - (byte) x#6 ← phi( ) - (byte) x1#5 ← phi( ) - (byte) xd#4 ← phi( ) - (byte) e#6 ← phi( ) - (byte*) cursor#6 ← phi( ) - (byte) y#4 ← phi( ) - to:@2 @END: from @3 -Redundant Phi (byte) y#4 VOID -Redundant Phi (byte*) cursor#6 VOID -Redundant Phi (byte) e#6 VOID -Redundant Phi (byte) xd#4 VOID -Redundant Phi (byte) x1#5 VOID -Redundant Phi (byte) x#6 VOID -Redundant Phi (byte) STAR#5 VOID -Redundant Phi (byte) yd#5 VOID +Redundant Phi (byte) x1#1 (byte) x1#2 +Redundant Phi (byte) x#3 (byte) x#1 +Redundant Phi (byte) STAR#2 (byte) STAR#1 +Redundant Phi (byte) yd#2 (byte) yd#1 +Redundant Phi (byte) xd#3 (byte) xd#1 Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @BEGIN: from @@ -682,55 +544,85 @@ CONTROL FLOW GRAPH (byte*) cursor#0 ← (byte*~) $4 + (byte) x#0 to:@1 @1: from @3 @BEGIN - (byte) x1#3 ← phi( @3/(byte) x1#1 @BEGIN/(byte) 39 ) - (byte) y#3 ← phi( @3/(byte) y#5 @BEGIN/(byte) y#0 ) - (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) xd#0 ) - (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) yd#0 ) + (byte) x1#2 ← phi( @3/(byte) x1#2 @BEGIN/(byte) 39 ) + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) y#0 ) + (byte) xd#1 ← phi( @3/(byte) xd#1 @BEGIN/(byte) xd#0 ) + (byte) yd#1 ← phi( @3/(byte) yd#1 @BEGIN/(byte) yd#0 ) (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) - (byte) x#2 ← phi( @3/(byte) x#3 @BEGIN/(byte) x#0 ) + (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) x#0 ) (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @3/(byte) STAR#2 @BEGIN/(byte) 81 ) + (byte) STAR#1 ← phi( @3/(byte) STAR#1 @BEGIN/(byte) 81 ) *((byte*) cursor#3) ← (byte) STAR#1 (byte) x#1 ← (byte) x#2 + (byte) 1 (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 (byte) e#1 ← (byte) e#3 + (byte) yd#1 (boolean~) $9 ← (byte) xd#1 < (byte) e#1 if((boolean~) $9) goto @2 - to:@4 -@2: from @1 @5 - (byte) yd#3 ← phi( @1/(byte) yd#1 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 ) - (byte) x#4 ← phi( @1/(byte) x#1 ) - (byte) x1#2 ← phi( @1/(byte) x1#3 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 ) - (byte) e#4 ← phi( @1/(byte) e#1 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 ) - (byte) y#2 ← phi( @1/(byte) y#3 ) + to:@3 +@2: from @1 (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#4 + (byte) 40 - (byte) e#2 ← (byte) e#4 - (byte) xd#2 + (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 + (byte) e#2 ← (byte) e#1 - (byte) xd#1 to:@3 -@4: from @1 - to:@3 -@3: from @2 @4 - (byte) y#5 ← phi( @2/(byte) y#1 @4/(byte) y#3 ) - (byte) xd#3 ← phi( @2/(byte) xd#2 @4/(byte) xd#1 ) - (byte) yd#2 ← phi( @2/(byte) yd#3 @4/(byte) yd#1 ) - (byte) e#5 ← phi( @2/(byte) e#2 @4/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @4/(byte*) cursor#1 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#3 @4/(byte) STAR#1 ) - (byte) x#3 ← phi( @2/(byte) x#4 @4/(byte) x#1 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @4/(byte) x1#3 ) - (byte~) $13 ← (byte) x1#1 + (byte) 1 - (boolean~) $14 ← (byte) x#3 < (byte~) $13 +@3: from @1 @2 + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) + (byte~) $13 ← (byte) x1#2 + (byte) 1 + (boolean~) $14 ← (byte) x#1 < (byte~) $13 + if((boolean~) $14) goto @1 + to:@END +@END: from @3 + +Self Phi Eliminated (byte) STAR#1 +Self Phi Eliminated (byte) yd#1 +Self Phi Eliminated (byte) xd#1 +Self Phi Eliminated (byte) x1#2 +Succesful SSA optimization Pass2SelfPhiElimination +CONTROL FLOW GRAPH +@BEGIN: from + (byte) xd#0 ← (byte) 39 - (byte) 0 + (byte) yd#0 ← (byte) 24 - (byte) 0 + (byte) x#0 ← (byte) 0 + (byte) y#0 ← (byte) 0 + (byte) e#0 ← (byte) yd#0 / (byte) 2 + (byte~) $3 ← (byte) y#0 * (byte) 40 + (byte*~) $4 ← (word) 1024 + (byte~) $3 + (byte*) cursor#0 ← (byte*~) $4 + (byte) x#0 + to:@1 +@1: from @3 @BEGIN + (byte) x1#2 ← phi( @BEGIN/(byte) 39 ) + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) y#0 ) + (byte) xd#1 ← phi( @BEGIN/(byte) xd#0 ) + (byte) yd#1 ← phi( @BEGIN/(byte) yd#0 ) + (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) + (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) x#0 ) + (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) + (byte) STAR#1 ← phi( @BEGIN/(byte) 81 ) + *((byte*) cursor#3) ← (byte) STAR#1 + (byte) x#1 ← (byte) x#2 + (byte) 1 + (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 + (byte) e#1 ← (byte) e#3 + (byte) yd#1 + (boolean~) $9 ← (byte) xd#1 < (byte) e#1 + if((boolean~) $9) goto @2 + to:@3 +@2: from @1 + (byte) y#1 ← (byte) y#2 + (byte) 1 + (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 + (byte) e#2 ← (byte) e#1 - (byte) xd#1 + to:@3 +@3: from @1 @2 + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) + (byte~) $13 ← (byte) x1#2 + (byte) 1 + (boolean~) $14 ← (byte) x#1 < (byte~) $13 if((boolean~) $14) goto @1 to:@END -@5: from - to:@2 @END: from @3 Simple Condition (boolean~) $9 if((byte) xd#1<(byte) e#1) goto @2 -Simple Condition (boolean~) $14 if((byte) x#3<(byte~) $13) goto @1 +Simple Condition (boolean~) $14 if((byte) x#1<(byte~) $13) goto @1 Succesful SSA optimization Pass2ConditionalJumpSimplification CONTROL FLOW GRAPH @BEGIN: from @@ -743,274 +635,13 @@ CONTROL FLOW GRAPH (byte*~) $4 ← (word) 1024 + (byte~) $3 (byte*) cursor#0 ← (byte*~) $4 + (byte) x#0 to:@1 -@1: from @3 @BEGIN - (byte) x1#3 ← phi( @3/(byte) x1#1 @BEGIN/(byte) 39 ) - (byte) y#3 ← phi( @3/(byte) y#5 @BEGIN/(byte) y#0 ) - (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) xd#0 ) - (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) yd#0 ) - (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) - (byte) x#2 ← phi( @3/(byte) x#3 @BEGIN/(byte) x#0 ) - (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @3/(byte) STAR#2 @BEGIN/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - if((byte) xd#1<(byte) e#1) goto @2 - to:@4 -@2: from @1 @5 - (byte) yd#3 ← phi( @1/(byte) yd#1 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 ) - (byte) x#4 ← phi( @1/(byte) x#1 ) - (byte) x1#2 ← phi( @1/(byte) x1#3 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 ) - (byte) e#4 ← phi( @1/(byte) e#1 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 ) - (byte) y#2 ← phi( @1/(byte) y#3 ) - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#4 + (byte) 40 - (byte) e#2 ← (byte) e#4 - (byte) xd#2 - to:@3 -@4: from @1 - to:@3 -@3: from @2 @4 - (byte) y#5 ← phi( @2/(byte) y#1 @4/(byte) y#3 ) - (byte) xd#3 ← phi( @2/(byte) xd#2 @4/(byte) xd#1 ) - (byte) yd#2 ← phi( @2/(byte) yd#3 @4/(byte) yd#1 ) - (byte) e#5 ← phi( @2/(byte) e#2 @4/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @4/(byte*) cursor#1 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#3 @4/(byte) STAR#1 ) - (byte) x#3 ← phi( @2/(byte) x#4 @4/(byte) x#1 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @4/(byte) x1#3 ) - (byte~) $13 ← (byte) x1#1 + (byte) 1 - if((byte) x#3<(byte~) $13) goto @1 - to:@END -@5: from - to:@2 -@END: from @3 - -Culled Empty Block (label) @4 -Culled Empty Block (label) @5 -Succesful SSA optimization Pass2CullEmptyBlocks -CONTROL FLOW GRAPH -@BEGIN: from - (byte) xd#0 ← (byte) 39 - (byte) 0 - (byte) yd#0 ← (byte) 24 - (byte) 0 - (byte) x#0 ← (byte) 0 - (byte) y#0 ← (byte) 0 - (byte) e#0 ← (byte) yd#0 / (byte) 2 - (byte~) $3 ← (byte) y#0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) x#0 - to:@1 -@1: from @3 @BEGIN - (byte) x1#3 ← phi( @3/(byte) x1#1 @BEGIN/(byte) 39 ) - (byte) y#3 ← phi( @3/(byte) y#5 @BEGIN/(byte) y#0 ) - (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) xd#0 ) - (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) yd#0 ) - (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) - (byte) x#2 ← phi( @3/(byte) x#3 @BEGIN/(byte) x#0 ) - (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @3/(byte) STAR#2 @BEGIN/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - if((byte) xd#1<(byte) e#1) goto @2 - to:@3 -@2: from @1 - (byte) yd#3 ← phi( @1/(byte) yd#1 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 ) - (byte) x#4 ← phi( @1/(byte) x#1 ) - (byte) x1#2 ← phi( @1/(byte) x1#3 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 ) - (byte) e#4 ← phi( @1/(byte) e#1 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 ) - (byte) y#2 ← phi( @1/(byte) y#3 ) - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#4 + (byte) 40 - (byte) e#2 ← (byte) e#4 - (byte) xd#2 - to:@3 -@3: from @1 @2 - (byte) y#5 ← phi( @2/(byte) y#1 @1/(byte) y#3 ) - (byte) xd#3 ← phi( @2/(byte) xd#2 @1/(byte) xd#1 ) - (byte) yd#2 ← phi( @2/(byte) yd#3 @1/(byte) yd#1 ) - (byte) e#5 ← phi( @2/(byte) e#2 @1/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @1/(byte*) cursor#1 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#3 @1/(byte) STAR#1 ) - (byte) x#3 ← phi( @2/(byte) x#4 @1/(byte) x#1 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @1/(byte) x1#3 ) - (byte~) $13 ← (byte) x1#1 + (byte) 1 - if((byte) x#3<(byte~) $13) goto @1 - to:@END -@END: from @3 - -Constant (byte) xd#0 (byte) 39 -Constant (byte) yd#0 (byte) 24 -Constant (byte) x#0 (byte) 0 -Constant (byte) y#0 (byte) 0 -Succesful SSA optimization Pass2ConstantPropagation -CONTROL FLOW GRAPH -@BEGIN: from - (byte) e#0 ← (byte) 24 / (byte) 2 - (byte~) $3 ← (byte) 0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) 0 - to:@1 -@1: from @3 @BEGIN - (byte) x1#3 ← phi( @3/(byte) x1#1 @BEGIN/(byte) 39 ) - (byte) y#3 ← phi( @3/(byte) y#5 @BEGIN/(byte) 0 ) - (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) 39 ) - (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) 24 ) - (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) - (byte) x#2 ← phi( @3/(byte) x#3 @BEGIN/(byte) 0 ) - (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @3/(byte) STAR#2 @BEGIN/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - if((byte) xd#1<(byte) e#1) goto @2 - to:@3 -@2: from @1 - (byte) yd#3 ← phi( @1/(byte) yd#1 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 ) - (byte) x#4 ← phi( @1/(byte) x#1 ) - (byte) x1#2 ← phi( @1/(byte) x1#3 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 ) - (byte) e#4 ← phi( @1/(byte) e#1 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 ) - (byte) y#2 ← phi( @1/(byte) y#3 ) - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#4 + (byte) 40 - (byte) e#2 ← (byte) e#4 - (byte) xd#2 - to:@3 -@3: from @1 @2 - (byte) y#5 ← phi( @2/(byte) y#1 @1/(byte) y#3 ) - (byte) xd#3 ← phi( @2/(byte) xd#2 @1/(byte) xd#1 ) - (byte) yd#2 ← phi( @2/(byte) yd#3 @1/(byte) yd#1 ) - (byte) e#5 ← phi( @2/(byte) e#2 @1/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @1/(byte*) cursor#1 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#3 @1/(byte) STAR#1 ) - (byte) x#3 ← phi( @2/(byte) x#4 @1/(byte) x#1 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @1/(byte) x1#3 ) - (byte~) $13 ← (byte) x1#1 + (byte) 1 - if((byte) x#3<(byte~) $13) goto @1 - to:@END -@END: from @3 - -Multiple usages for variable. Not optimizing sub-constant (byte) x1#1 -Alias (byte) y#2 = (byte) y#3 -Alias (byte*) cursor#1 = (byte*) cursor#4 -Alias (byte) e#1 = (byte) e#4 -Alias (byte) xd#1 = (byte) xd#2 -Alias (byte) x1#2 = (byte) x1#3 -Alias (byte) x#1 = (byte) x#4 -Alias (byte) STAR#1 = (byte) STAR#3 -Alias (byte) yd#1 = (byte) yd#3 -Succesful SSA optimization Pass2AliasElimination -CONTROL FLOW GRAPH -@BEGIN: from - (byte) e#0 ← (byte) 24 / (byte) 2 - (byte~) $3 ← (byte) 0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) 0 - to:@1 -@1: from @3 @BEGIN - (byte) x1#2 ← phi( @3/(byte) x1#1 @BEGIN/(byte) 39 ) - (byte) y#2 ← phi( @3/(byte) y#5 @BEGIN/(byte) 0 ) - (byte) xd#1 ← phi( @3/(byte) xd#3 @BEGIN/(byte) 39 ) - (byte) yd#1 ← phi( @3/(byte) yd#2 @BEGIN/(byte) 24 ) - (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) - (byte) x#2 ← phi( @3/(byte) x#3 @BEGIN/(byte) 0 ) - (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @3/(byte) STAR#2 @BEGIN/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - if((byte) xd#1<(byte) e#1) goto @2 - to:@3 -@2: from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) xd#1 - to:@3 -@3: from @1 @2 - (byte) y#5 ← phi( @2/(byte) y#1 @1/(byte) y#2 ) - (byte) xd#3 ← phi( @2/(byte) xd#1 @1/(byte) xd#1 ) - (byte) yd#2 ← phi( @2/(byte) yd#1 @1/(byte) yd#1 ) - (byte) e#5 ← phi( @2/(byte) e#2 @1/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @1/(byte*) cursor#1 ) - (byte) STAR#2 ← phi( @2/(byte) STAR#1 @1/(byte) STAR#1 ) - (byte) x#3 ← phi( @2/(byte) x#1 @1/(byte) x#1 ) - (byte) x1#1 ← phi( @2/(byte) x1#2 @1/(byte) x1#2 ) - (byte~) $13 ← (byte) x1#1 + (byte) 1 - if((byte) x#3<(byte~) $13) goto @1 - to:@END -@END: from @3 - -Redundant Phi (byte) x1#1 (byte) x1#2 -Redundant Phi (byte) x#3 (byte) x#1 -Redundant Phi (byte) STAR#2 (byte) STAR#1 -Redundant Phi (byte) yd#2 (byte) yd#1 -Redundant Phi (byte) xd#3 (byte) xd#1 -Succesful SSA optimization Pass2RedundantPhiElimination -CONTROL FLOW GRAPH -@BEGIN: from - (byte) e#0 ← (byte) 24 / (byte) 2 - (byte~) $3 ← (byte) 0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) 0 - to:@1 -@1: from @3 @BEGIN - (byte) x1#2 ← phi( @3/(byte) x1#2 @BEGIN/(byte) 39 ) - (byte) y#2 ← phi( @3/(byte) y#5 @BEGIN/(byte) 0 ) - (byte) xd#1 ← phi( @3/(byte) xd#1 @BEGIN/(byte) 39 ) - (byte) yd#1 ← phi( @3/(byte) yd#1 @BEGIN/(byte) 24 ) - (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) - (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) 0 ) - (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @3/(byte) STAR#1 @BEGIN/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - if((byte) xd#1<(byte) e#1) goto @2 - to:@3 -@2: from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) xd#1 - to:@3 -@3: from @1 @2 - (byte) y#5 ← phi( @2/(byte) y#1 @1/(byte) y#2 ) - (byte) e#5 ← phi( @2/(byte) e#2 @1/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @1/(byte*) cursor#1 ) - (byte~) $13 ← (byte) x1#2 + (byte) 1 - if((byte) x#1<(byte~) $13) goto @1 - to:@END -@END: from @3 - -Self Phi Eliminated (byte) STAR#1 -Self Phi Eliminated (byte) yd#1 -Self Phi Eliminated (byte) xd#1 -Self Phi Eliminated (byte) x1#2 -Succesful SSA optimization Pass2SelfPhiElimination -CONTROL FLOW GRAPH -@BEGIN: from - (byte) e#0 ← (byte) 24 / (byte) 2 - (byte~) $3 ← (byte) 0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) 0 - to:@1 @1: from @3 @BEGIN (byte) x1#2 ← phi( @BEGIN/(byte) 39 ) - (byte) y#2 ← phi( @3/(byte) y#5 @BEGIN/(byte) 0 ) - (byte) xd#1 ← phi( @BEGIN/(byte) 39 ) - (byte) yd#1 ← phi( @BEGIN/(byte) 24 ) + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) y#0 ) + (byte) xd#1 ← phi( @BEGIN/(byte) xd#0 ) + (byte) yd#1 ← phi( @BEGIN/(byte) yd#0 ) (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) - (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) 0 ) + (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) x#0 ) (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) (byte) STAR#1 ← phi( @BEGIN/(byte) 81 ) *((byte*) cursor#3) ← (byte) STAR#1 @@ -1025,46 +656,50 @@ CONTROL FLOW GRAPH (byte) e#2 ← (byte) e#1 - (byte) xd#1 to:@3 @3: from @1 @2 - (byte) y#5 ← phi( @2/(byte) y#1 @1/(byte) y#2 ) - (byte) e#5 ← phi( @2/(byte) e#2 @1/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @1/(byte*) cursor#1 ) + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) (byte~) $13 ← (byte) x1#2 + (byte) 1 if((byte) x#1<(byte~) $13) goto @1 to:@END @END: from @3 -Constant (byte) e#0 (byte) 12 -Constant (byte~) $3 (byte) 0 +Constant (byte) xd#0 (byte) 39 +Constant (byte) yd#0 (byte) 24 +Constant (byte) x#0 (byte) 0 +Constant (byte) y#0 (byte) 0 Constant (byte) STAR#1 (byte) 81 -Constant (byte) yd#1 (byte) 24 -Constant (byte) xd#1 (byte) 39 Constant (byte) x1#2 (byte) 39 Succesful SSA optimization Pass2ConstantPropagation CONTROL FLOW GRAPH @BEGIN: from - (byte*~) $4 ← (word) 1024 + (byte) 0 + (byte) e#0 ← (byte) 24 / (byte) 2 + (byte~) $3 ← (byte) 0 * (byte) 40 + (byte*~) $4 ← (word) 1024 + (byte~) $3 (byte*) cursor#0 ← (byte*~) $4 + (byte) 0 to:@1 @1: from @3 @BEGIN - (byte) y#2 ← phi( @3/(byte) y#5 @BEGIN/(byte) 0 ) - (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) 12 ) + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) 0 ) + (byte) xd#1 ← phi( @BEGIN/(byte) 39 ) + (byte) yd#1 ← phi( @BEGIN/(byte) 24 ) + (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) 0 ) (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) *((byte*) cursor#3) ← (byte) 81 (byte) x#1 ← (byte) x#2 + (byte) 1 (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) 24 - if((byte) 39<(byte) e#1) goto @2 + (byte) e#1 ← (byte) e#3 + (byte) yd#1 + if((byte) xd#1<(byte) e#1) goto @2 to:@3 @2: from @1 (byte) y#1 ← (byte) y#2 + (byte) 1 (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) 39 + (byte) e#2 ← (byte) e#1 - (byte) xd#1 to:@3 @3: from @1 @2 - (byte) y#5 ← phi( @2/(byte) y#1 @1/(byte) y#2 ) - (byte) e#5 ← phi( @2/(byte) e#2 @1/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @1/(byte*) cursor#1 ) + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) (byte~) $13 ← (byte) 39 + (byte) 1 if((byte) x#1<(byte~) $13) goto @1 to:@END @@ -1072,15 +707,52 @@ CONTROL FLOW GRAPH Multiple usages for variable. Not optimizing sub-constant (byte) y#2 Multiple usages for variable. Not optimizing sub-constant (byte*) cursor#1 -Constant (byte*~) $4 (word) 1024 +Redundant Phi (byte) yd#1 (byte) 24 +Redundant Phi (byte) xd#1 (byte) 39 +Succesful SSA optimization Pass2RedundantPhiElimination +CONTROL FLOW GRAPH +@BEGIN: from + (byte) e#0 ← (byte) 24 / (byte) 2 + (byte~) $3 ← (byte) 0 * (byte) 40 + (byte*~) $4 ← (word) 1024 + (byte~) $3 + (byte*) cursor#0 ← (byte*~) $4 + (byte) 0 + to:@1 +@1: from @3 @BEGIN + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) 0 ) + (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) e#0 ) + (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) 0 ) + (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) + *((byte*) cursor#3) ← (byte) 81 + (byte) x#1 ← (byte) x#2 + (byte) 1 + (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 + (byte) e#1 ← (byte) e#3 + (byte) 24 + if((byte) 39<(byte) e#1) goto @2 + to:@3 +@2: from @1 + (byte) y#1 ← (byte) y#2 + (byte) 1 + (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 + (byte) e#2 ← (byte) e#1 - (byte) 39 + to:@3 +@3: from @1 @2 + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) + (byte~) $13 ← (byte) 39 + (byte) 1 + if((byte) x#1<(byte~) $13) goto @1 + to:@END +@END: from @3 + +Constant (byte) e#0 (byte) 12 +Constant (byte~) $3 (byte) 0 Constant (byte~) $13 (byte) 40 Succesful SSA optimization Pass2ConstantPropagation CONTROL FLOW GRAPH @BEGIN: from - (byte*) cursor#0 ← (word) 1024 + (byte) 0 + (byte*~) $4 ← (word) 1024 + (byte) 0 + (byte*) cursor#0 ← (byte*~) $4 + (byte) 0 to:@1 @1: from @3 @BEGIN - (byte) y#2 ← phi( @3/(byte) y#5 @BEGIN/(byte) 0 ) + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) 0 ) (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) 12 ) (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) 0 ) (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) @@ -1096,9 +768,41 @@ CONTROL FLOW GRAPH (byte) e#2 ← (byte) e#1 - (byte) 39 to:@3 @3: from @1 @2 - (byte) y#5 ← phi( @2/(byte) y#1 @1/(byte) y#2 ) - (byte) e#5 ← phi( @2/(byte) e#2 @1/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @1/(byte*) cursor#1 ) + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) + if((byte) x#1<(byte) 40) goto @1 + to:@END +@END: from @3 + +Multiple usages for variable. Not optimizing sub-constant (byte) y#2 +Multiple usages for variable. Not optimizing sub-constant (byte*) cursor#1 +Constant (byte*~) $4 (word) 1024 +Succesful SSA optimization Pass2ConstantPropagation +CONTROL FLOW GRAPH +@BEGIN: from + (byte*) cursor#0 ← (word) 1024 + (byte) 0 + to:@1 +@1: from @3 @BEGIN + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) 0 ) + (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) 12 ) + (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) 0 ) + (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(byte*) cursor#0 ) + *((byte*) cursor#3) ← (byte) 81 + (byte) x#1 ← (byte) x#2 + (byte) 1 + (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 + (byte) e#1 ← (byte) e#3 + (byte) 24 + if((byte) 39<(byte) e#1) goto @2 + to:@3 +@2: from @1 + (byte) y#1 ← (byte) y#2 + (byte) 1 + (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 + (byte) e#2 ← (byte) e#1 - (byte) 39 + to:@3 +@3: from @1 @2 + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) if((byte) x#1<(byte) 40) goto @1 to:@END @END: from @3 @@ -1111,7 +815,7 @@ CONTROL FLOW GRAPH @BEGIN: from to:@1 @1: from @3 @BEGIN - (byte) y#2 ← phi( @3/(byte) y#5 @BEGIN/(byte) 0 ) + (byte) y#2 ← phi( @3/(byte) y#4 @BEGIN/(byte) 0 ) (byte) e#3 ← phi( @3/(byte) e#5 @BEGIN/(byte) 12 ) (byte) x#2 ← phi( @3/(byte) x#1 @BEGIN/(byte) 0 ) (byte*) cursor#3 ← phi( @3/(byte*) cursor#5 @BEGIN/(word) 1024 ) @@ -1127,9 +831,9 @@ CONTROL FLOW GRAPH (byte) e#2 ← (byte) e#1 - (byte) 39 to:@3 @3: from @1 @2 - (byte) y#5 ← phi( @2/(byte) y#1 @1/(byte) y#2 ) - (byte) e#5 ← phi( @2/(byte) e#2 @1/(byte) e#1 ) - (byte*) cursor#5 ← phi( @2/(byte*) cursor#2 @1/(byte*) cursor#1 ) + (byte) y#4 ← phi( @1/(byte) y#2 @2/(byte) y#1 ) + (byte) e#5 ← phi( @1/(byte) e#1 @2/(byte) e#2 ) + (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @2/(byte*) cursor#2 ) if((byte) x#1<(byte) 40) goto @1 to:@END @END: from @3 @@ -1157,7 +861,7 @@ B1_from_BBEGIN: sta 10+1 jmp B1 B1_from_B3: - // (byte) y#2 = (byte) y#5 // zpby1=zpby2 + // (byte) y#2 = (byte) y#4 // zpby1=zpby2 lda 18 sta 14 // (byte) e#3 = (byte) e#5 // zpby1=zpby2 @@ -1200,7 +904,7 @@ B1: cmp 5 bcc B2 B3_from_B1: - // (byte) y#5 = (byte) y#2 // zpby1=zpby2 + // (byte) y#4 = (byte) y#2 // zpby1=zpby2 lda 14 sta 18 // (byte) e#5 = (byte) e#1 // zpby1=zpby2 @@ -1239,7 +943,7 @@ B2: sbc #39 sta 9 B3_from_B2: - // (byte) y#5 = (byte) y#1 // zpby1=zpby2 + // (byte) y#4 = (byte) y#1 // zpby1=zpby2 lda 6 sta 18 // (byte) e#5 = (byte) e#2 // zpby1=zpby2 @@ -1275,7 +979,7 @@ B1_from_BBEGIN: sta 10+1 jmp B1 B1_from_B3: - // (byte) y#2 = (byte) y#5 // zpby1=zpby2 + // (byte) y#2 = (byte) y#4 // zpby1=zpby2 lda 18 sta 14 // (byte) e#3 = (byte) e#5 // zpby1=zpby2 @@ -1317,7 +1021,7 @@ B1: cmp 5 bcc B2 B3_from_B1: - // (byte) y#5 = (byte) y#2 // zpby1=zpby2 + // (byte) y#4 = (byte) y#2 // zpby1=zpby2 lda 14 sta 18 // (byte) e#5 = (byte) e#1 // zpby1=zpby2 @@ -1354,7 +1058,7 @@ B2: sbc #39 sta 9 B3_from_B2: - // (byte) y#5 = (byte) y#1 // zpby1=zpby2 + // (byte) y#4 = (byte) y#1 // zpby1=zpby2 lda 6 sta 18 // (byte) e#5 = (byte) e#2 // zpby1=zpby2 @@ -1394,7 +1098,7 @@ FINAL SYMBOL TABLE (byte) y (byte) y#1 zp byte:6 (byte) y#2 zp byte:14 -(byte) y#5 zp byte:18 +(byte) y#4 zp byte:18 (byte) y0 (byte) y1 (byte) yd @@ -1418,7 +1122,7 @@ B1_from_BBEGIN: sta 10+1 jmp B1 B1_from_B3: - // (byte) y#2 = (byte) y#5 // zpby1=zpby2 + // (byte) y#2 = (byte) y#4 // zpby1=zpby2 lda 18 sta 14 // (byte) e#3 = (byte) e#5 // zpby1=zpby2 @@ -1460,7 +1164,7 @@ B1: cmp 5 bcc B2 B3_from_B1: - // (byte) y#5 = (byte) y#2 // zpby1=zpby2 + // (byte) y#4 = (byte) y#2 // zpby1=zpby2 lda 14 sta 18 // (byte) e#5 = (byte) e#1 // zpby1=zpby2 @@ -1497,7 +1201,7 @@ B2: sbc #39 sta 9 B3_from_B2: - // (byte) y#5 = (byte) y#1 // zpby1=zpby2 + // (byte) y#4 = (byte) y#1 // zpby1=zpby2 lda 6 sta 18 // (byte) e#5 = (byte) e#2 // zpby1=zpby2 diff --git a/src/dk/camelot64/kickc/test/ref/bresenham.sym b/src/dk/camelot64/kickc/test/ref/bresenham.sym index 3c684133c..d0153fea4 100644 --- a/src/dk/camelot64/kickc/test/ref/bresenham.sym +++ b/src/dk/camelot64/kickc/test/ref/bresenham.sym @@ -24,7 +24,7 @@ (byte) y (byte) y#1 zp byte:6 (byte) y#2 zp byte:14 -(byte) y#5 zp byte:18 +(byte) y#4 zp byte:18 (byte) y0 (byte) y1 (byte) yd diff --git a/src/dk/camelot64/kickc/test/ref/flipper-rex2.asm b/src/dk/camelot64/kickc/test/ref/flipper-rex2.asm index 9779d0f52..bbae2e108 100644 --- a/src/dk/camelot64/kickc/test/ref/flipper-rex2.asm +++ b/src/dk/camelot64/kickc/test/ref/flipper-rex2.asm @@ -3,17 +3,17 @@ BBEGIN: BEND: main: jsr prepare -main__B2_from_main: +main__B3_from_main: ldx #25 - jmp main__B2 -main__B2_from_B11: + jmp main__B3 +main__B3_from_B11: ldx #25 -main__B2_from_B6: -main__B2: +main__B3_from_B3: +main__B3_from_B6: main__B3: lda 53266 cmp #254 - bne main__main__B3 + bne main__B3_from_B3 main__B4: lda 53266 cmp #255 @@ -21,13 +21,13 @@ main__B4: main__B6: dex cpx #0 - bne main__B2_from_B6 + bne main__B3_from_B6 main__B7: jsr flip main__B10: jsr plot main__B11: - jmp main__B2_from_B11 + jmp main__B3_from_B11 main__Breturn: rts plot: diff --git a/src/dk/camelot64/kickc/test/ref/flipper-rex2.cfg b/src/dk/camelot64/kickc/test/ref/flipper-rex2.cfg index 31d31de79..c33f368e7 100644 --- a/src/dk/camelot64/kickc/test/ref/flipper-rex2.cfg +++ b/src/dk/camelot64/kickc/test/ref/flipper-rex2.cfg @@ -3,11 +3,9 @@ to:@END main: from @BEGIN call prepare param-assignment - to:main::@2 -main::@2: from main main::@11 main::@6 - (byte) main::c#2 ← phi( main/(byte) 25 main::@11/(byte) 25 main::@6/(byte) main::c#1 ) to:main::@3 -main::@3: from main::@2 main::@3 +main::@3: from main main::@11 main::@3 main::@6 + (byte) main::c#2 ← phi( main/(byte) 25 main::@11/(byte) 25 main::@6/(byte) main::c#1 ) (byte~) main::$1 ← * (word) 53266 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 @@ -17,7 +15,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -26,7 +24,7 @@ main::@10: from main::@7 call plot param-assignment to:main::@11 main::@11: from main::@10 - if(true) goto main::@2 + if(true) goto main::@3 to:main::@return main::@return: from main::@11 return diff --git a/src/dk/camelot64/kickc/test/ref/flipper-rex2.log b/src/dk/camelot64/kickc/test/ref/flipper-rex2.log index 7cd1d330e..8ff84827a 100644 --- a/src/dk/camelot64/kickc/test/ref/flipper-rex2.log +++ b/src/dk/camelot64/kickc/test/ref/flipper-rex2.log @@ -360,6 +360,133 @@ plot::@return: from plot::@4 to:@END @END: from @4 +Removing empty block main::@5 +Removing empty block main::@8 +Removing empty block @1 +Removing empty block prepare::@2 +Removing empty block @2 +Removing empty block flip::@6 +Removing empty block @3 +Removing empty block plot::@4 +Removing empty block @4 +@BEGIN: from + (byte[1000]) SCREEN ← (word) 1024 + (byte[256]) buffer1 ← (word) 4096 + (byte[256]) buffer2 ← (word) 4352 + (byte*) RASTER ← (word) 53266 + (void~) $0 ← call main + to:@END +main: from + (void~) main::$0 ← call prepare + to:main::@1 +main::@1: from main main::@7 + (byte) main::c ← (byte) 25 + to:main::@3 +main::@2: from main::@6 + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 + (byte~) main::$1 ← * (byte*) RASTER + (boolean~) main::$2 ← (byte~) main::$1 != (byte) 254 + if((boolean~) main::$2) goto main::@3 + to:main::@4 +main::@4: from main::@3 main::@4 + (byte~) main::$3 ← * (byte*) RASTER + (boolean~) main::$4 ← (byte~) main::$3 != (byte) 255 + if((boolean~) main::$4) goto main::@4 + to:main::@6 +main::@6: from main::@4 + (byte) main::c ← -- (byte) main::c + (boolean~) main::$5 ← (byte) main::c != (byte) 0 + if((boolean~) main::$5) goto main::@2 + to:main::@7 +main::@7: from main::@6 + (void~) main::$6 ← call flip + (void~) main::$7 ← call plot + if(true) goto main::@1 + to:main::@return +main::@return: from main::@7 + return + to:@RETURN +prepare: from + (byte) prepare::i ← (byte) 0 + to:prepare::@1 +prepare::@1: from prepare prepare::@1 + *((byte[256]) buffer1 + (byte) prepare::i) ← (byte) prepare::i + (byte) prepare::i ← ++ (byte) prepare::i + (boolean~) prepare::$0 ← (byte) prepare::i != (byte) 0 + if((boolean~) prepare::$0) goto prepare::@1 + to:prepare::@return +prepare::@return: from prepare::@1 + return + to:@RETURN +flip: from + (byte) flip::srcIdx ← (byte) 0 + (byte) flip::dstIdx ← (byte) 15 + (byte) flip::r ← (byte) 16 + to:flip::@1 +flip::@1: from flip flip::@4 + (byte) flip::c ← (byte) 16 + to:flip::@2 +flip::@2: from flip::@1 flip::@2 + (byte~) flip::$0 ← (byte[256]) buffer1 *idx (byte) flip::srcIdx + *((byte[256]) buffer2 + (byte) flip::dstIdx) ← (byte~) flip::$0 + (byte) flip::srcIdx ← ++ (byte) flip::srcIdx + (byte~) flip::$1 ← (byte) flip::dstIdx + (byte) 16 + (byte) flip::dstIdx ← (byte~) flip::$1 + (byte) flip::c ← -- (byte) flip::c + (boolean~) flip::$2 ← (byte) flip::c != (byte) 0 + if((boolean~) flip::$2) goto flip::@2 + to:flip::@4 +flip::@4: from flip::@2 + (byte) flip::dstIdx ← -- (byte) flip::dstIdx + (byte) flip::r ← -- (byte) flip::r + (boolean~) flip::$3 ← (byte) flip::r != (byte) 0 + if((boolean~) flip::$3) goto flip::@1 + to:flip::@5 +flip::@5: from flip::@4 + (byte) flip::i ← (byte) 0 + to:flip::@3 +flip::@3: from flip::@3 flip::@5 + (byte~) flip::$4 ← (byte[256]) buffer2 *idx (byte) flip::i + *((byte[256]) buffer1 + (byte) flip::i) ← (byte~) flip::$4 + (byte) flip::i ← ++ (byte) flip::i + (boolean~) flip::$5 ← (byte) flip::i != (byte) 0 + if((boolean~) flip::$5) goto flip::@3 + to:flip::@return +flip::@return: from flip::@3 + return + to:@RETURN +plot: from + (byte~) plot::$0 ← (byte) 5 * (byte) 40 + (byte*~) plot::$1 ← (byte[1000]) SCREEN + (byte~) plot::$0 + (byte*~) plot::$2 ← (byte*~) plot::$1 + (byte) 12 + (byte*) plot::line ← (byte*~) plot::$2 + (byte) plot::y ← (byte) 16 + (byte) plot::i ← (byte) 0 + to:plot::@1 +plot::@1: from plot plot::@3 + (byte) plot::x ← (byte) 0 + to:plot::@2 +plot::@2: from plot::@1 plot::@2 + (byte~) plot::$3 ← (byte[256]) buffer1 *idx (byte) plot::i + *((byte*) plot::line + (byte) plot::x) ← (byte~) plot::$3 + (byte) plot::i ← ++ (byte) plot::i + (byte) plot::x ← ++ (byte) plot::x + (boolean~) plot::$4 ← (byte) plot::x < (byte) 16 + if((boolean~) plot::$4) goto plot::@2 + to:plot::@3 +plot::@3: from plot::@2 + (byte*~) plot::$5 ← (byte*) plot::line + (byte) 40 + (byte*) plot::line ← (byte*~) plot::$5 + (byte) plot::y ← -- (byte) plot::y + (boolean~) plot::$6 ← (byte) plot::y != (byte) 0 + if((boolean~) plot::$6) goto plot::@1 + to:plot::@return +plot::@return: from plot::@3 + return + to:@RETURN +@END: from @BEGIN + CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @BEGIN: from (byte[1000]) SCREEN ← (word) 1024 @@ -369,7 +496,7 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL call main param-assignment to:@5 @5: from @BEGIN - to:@1 + to:@END main: from @BEGIN call prepare param-assignment to:main::@9 @@ -377,17 +504,15 @@ main::@9: from main to:main::@1 main::@1: from main::@11 main::@9 (byte) main::c ← (byte) 25 - to:main::@2 -main::@2: from main::@1 main::@6 to:main::@3 -main::@3: from main::@2 main::@3 +main::@2: from main::@6 + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 (byte~) main::$1 ← * (byte*) RASTER (boolean~) main::$2 ← (byte~) main::$1 != (byte) 254 if((boolean~) main::$2) goto main::@3 - to:main::@5 -main::@5: from main::@3 to:main::@4 -main::@4: from main::@4 main::@5 +main::@4: from main::@3 main::@4 (byte~) main::$3 ← * (byte*) RASTER (boolean~) main::$4 ← (byte~) main::$3 != (byte) 255 if((boolean~) main::$4) goto main::@4 @@ -405,14 +530,10 @@ main::@10: from main::@7 to:main::@11 main::@11: from main::@10 if(true) goto main::@1 - to:main::@8 -main::@8: from main::@11 to:main::@return -main::@return: from main::@8 +main::@return: from main::@11 return to:@RETURN -@1: from @5 - to:@2 prepare: from main (byte) prepare::i ← (byte) 0 to:prepare::@1 @@ -421,14 +542,10 @@ prepare::@1: from prepare prepare::@1 (byte) prepare::i ← ++ (byte) prepare::i (boolean~) prepare::$0 ← (byte) prepare::i != (byte) 0 if((boolean~) prepare::$0) goto prepare::@1 - to:prepare::@2 -prepare::@2: from prepare::@1 to:prepare::@return -prepare::@return: from prepare::@2 +prepare::@return: from prepare::@1 return to:@RETURN -@2: from @1 - to:@3 flip: from main::@7 (byte) flip::srcIdx ← (byte) 0 (byte) flip::dstIdx ← (byte) 15 @@ -462,14 +579,10 @@ flip::@3: from flip::@3 flip::@5 (byte) flip::i ← ++ (byte) flip::i (boolean~) flip::$5 ← (byte) flip::i != (byte) 0 if((boolean~) flip::$5) goto flip::@3 - to:flip::@6 -flip::@6: from flip::@3 to:flip::@return -flip::@return: from flip::@6 +flip::@return: from flip::@3 return to:@RETURN -@3: from @2 - to:@4 plot: from main::@10 (byte~) plot::$0 ← (byte) 5 * (byte) 40 (byte*~) plot::$1 ← (byte[1000]) SCREEN + (byte~) plot::$0 @@ -495,15 +608,11 @@ plot::@3: from plot::@2 (byte) plot::y ← -- (byte) plot::y (boolean~) plot::$6 ← (byte) plot::y != (byte) 0 if((boolean~) plot::$6) goto plot::@1 - to:plot::@4 -plot::@4: from plot::@3 to:plot::@return -plot::@return: from plot::@4 +plot::@return: from plot::@3 return to:@RETURN -@4: from @3 - to:@END -@END: from @4 +@END: from @5 Completing Phi functions... Completing Phi functions... @@ -515,8 +624,6 @@ Completing Phi functions... Completing Phi functions... Completing Phi functions... Completing Phi functions... -Completing Phi functions... -Completing Phi functions... CONTROL FLOW GRAPH SSA @BEGIN: from (byte[1000]) SCREEN#0 ← (word) 1024 @@ -526,57 +633,50 @@ CONTROL FLOW GRAPH SSA call main param-assignment to:@5 @5: from @BEGIN - to:@1 + to:@END main: from @BEGIN - (byte[256]) buffer2#16 ← phi( @BEGIN/(byte[256]) buffer2#0 ) - (byte[1000]) SCREEN#12 ← phi( @BEGIN/(byte[1000]) SCREEN#0 ) - (byte*) RASTER#9 ← phi( @BEGIN/(byte*) RASTER#0 ) + (byte[256]) buffer2#15 ← phi( @BEGIN/(byte[256]) buffer2#0 ) + (byte[1000]) SCREEN#11 ← phi( @BEGIN/(byte[1000]) SCREEN#0 ) + (byte*) RASTER#8 ← phi( @BEGIN/(byte*) RASTER#0 ) (byte[256]) buffer1#9 ← phi( @BEGIN/(byte[256]) buffer1#0 ) call prepare param-assignment to:main::@9 main::@9: from main - (byte[256]) buffer2#15 ← phi( main/(byte[256]) buffer2#16 ) - (byte[256]) buffer1#23 ← phi( main/(byte[256]) buffer1#9 ) - (byte[1000]) SCREEN#11 ← phi( main/(byte[1000]) SCREEN#12 ) - (byte*) RASTER#8 ← phi( main/(byte*) RASTER#9 ) + (byte[256]) buffer2#14 ← phi( main/(byte[256]) buffer2#15 ) + (byte[256]) buffer1#22 ← phi( main/(byte[256]) buffer1#9 ) + (byte[1000]) SCREEN#10 ← phi( main/(byte[1000]) SCREEN#11 ) + (byte*) RASTER#6 ← phi( main/(byte*) RASTER#8 ) to:main::@1 main::@1: from main::@11 main::@9 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#22 main::@9/(byte[256]) buffer1#23 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#10 main::@9/(byte[1000]) SCREEN#11 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#7 main::@9/(byte*) RASTER#8 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#13 main::@9/(byte[256]) buffer2#14 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#21 main::@9/(byte[256]) buffer1#22 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#9 main::@9/(byte[1000]) SCREEN#10 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#5 main::@9/(byte*) RASTER#6 ) (byte) main::c#0 ← (byte) 25 - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#8 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#16 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#4 ) - (byte) main::c#6 ← phi( main::@1/(byte) main::c#0 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#6 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#11 ← phi( main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#11 ) - (byte[256]) buffer1#19 ← phi( main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#19 ) - (byte[1000]) SCREEN#7 ← phi( main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#7 ) - (byte) main::c#5 ← phi( main::@2/(byte) main::c#6 main::@3/(byte) main::c#5 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 main::@3/(byte*) RASTER#1 ) +main::@2: from main::@6 + (byte[256]) buffer2#12 ← phi( main::@6/(byte[256]) buffer2#8 ) + (byte[256]) buffer1#20 ← phi( main::@6/(byte[256]) buffer1#16 ) + (byte[1000]) SCREEN#8 ← phi( main::@6/(byte[1000]) SCREEN#4 ) + (byte) main::c#5 ← phi( main::@6/(byte) main::c#1 ) + (byte*) RASTER#4 ← phi( main::@6/(byte*) RASTER#7 ) + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#18 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#6 ) + (byte) main::c#4 ← phi( main::@1/(byte) main::c#0 main::@2/(byte) main::c#5 main::@3/(byte) main::c#4 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@2/(byte*) RASTER#4 main::@3/(byte*) RASTER#1 ) (byte~) main::$1 ← * (byte*) RASTER#1 (boolean~) main::$2 ← (byte~) main::$1 != (byte) 254 if((boolean~) main::$2) goto main::@3 - to:main::@5 -main::@5: from main::@3 - (byte[256]) buffer2#10 ← phi( main::@3/(byte[256]) buffer2#11 ) - (byte[256]) buffer1#18 ← phi( main::@3/(byte[256]) buffer1#19 ) - (byte[1000]) SCREEN#6 ← phi( main::@3/(byte[1000]) SCREEN#7 ) - (byte) main::c#4 ← phi( main::@3/(byte) main::c#5 ) - (byte*) RASTER#4 ← phi( main::@3/(byte*) RASTER#1 ) to:main::@4 -main::@4: from main::@4 main::@5 - (byte[256]) buffer2#9 ← phi( main::@4/(byte[256]) buffer2#9 main::@5/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#17 ← phi( main::@4/(byte[256]) buffer1#17 main::@5/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#5 ← phi( main::@4/(byte[1000]) SCREEN#5 main::@5/(byte[1000]) SCREEN#6 ) - (byte) main::c#3 ← phi( main::@4/(byte) main::c#3 main::@5/(byte) main::c#4 ) - (byte*) RASTER#2 ← phi( main::@4/(byte*) RASTER#2 main::@5/(byte*) RASTER#4 ) +main::@4: from main::@3 main::@4 + (byte[256]) buffer2#9 ← phi( main::@3/(byte[256]) buffer2#10 main::@4/(byte[256]) buffer2#9 ) + (byte[256]) buffer1#17 ← phi( main::@3/(byte[256]) buffer1#18 main::@4/(byte[256]) buffer1#17 ) + (byte[1000]) SCREEN#5 ← phi( main::@3/(byte[1000]) SCREEN#6 main::@4/(byte[1000]) SCREEN#5 ) + (byte) main::c#3 ← phi( main::@3/(byte) main::c#4 main::@4/(byte) main::c#3 ) + (byte*) RASTER#2 ← phi( main::@3/(byte*) RASTER#1 main::@4/(byte*) RASTER#2 ) (byte~) main::$3 ← * (byte*) RASTER#2 (boolean~) main::$4 ← (byte~) main::$3 != (byte) 255 if((boolean~) main::$4) goto main::@4 @@ -585,40 +685,36 @@ main::@6: from main::@4 (byte[256]) buffer2#8 ← phi( main::@4/(byte[256]) buffer2#9 ) (byte[256]) buffer1#16 ← phi( main::@4/(byte[256]) buffer1#17 ) (byte[1000]) SCREEN#4 ← phi( main::@4/(byte[1000]) SCREEN#5 ) - (byte*) RASTER#6 ← phi( main::@4/(byte*) RASTER#2 ) + (byte*) RASTER#7 ← phi( main::@4/(byte*) RASTER#2 ) (byte) main::c#2 ← phi( main::@4/(byte) main::c#3 ) (byte) main::c#1 ← -- (byte) main::c#2 (boolean~) main::$5 ← (byte) main::c#1 != (byte) 0 if((boolean~) main::$5) goto main::@2 to:main::@7 main::@7: from main::@6 - (byte*) RASTER#11 ← phi( main::@6/(byte*) RASTER#6 ) + (byte*) RASTER#10 ← phi( main::@6/(byte*) RASTER#7 ) (byte[256]) buffer2#7 ← phi( main::@6/(byte[256]) buffer2#8 ) (byte[256]) buffer1#14 ← phi( main::@6/(byte[256]) buffer1#16 ) (byte[1000]) SCREEN#3 ← phi( main::@6/(byte[1000]) SCREEN#4 ) call flip param-assignment to:main::@10 main::@10: from main::@7 - (byte[256]) buffer2#17 ← phi( main::@7/(byte[256]) buffer2#7 ) - (byte*) RASTER#10 ← phi( main::@7/(byte*) RASTER#11 ) + (byte[256]) buffer2#16 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte[256]) buffer1#15 ← phi( main::@7/(byte[256]) buffer1#14 ) + (byte*) RASTER#9 ← phi( main::@7/(byte*) RASTER#10 ) (byte[1000]) SCREEN#2 ← phi( main::@7/(byte[1000]) SCREEN#3 ) call plot param-assignment to:main::@11 main::@11: from main::@10 - (byte[256]) buffer2#14 ← phi( main::@10/(byte[256]) buffer2#17 ) - (byte[256]) buffer1#22 ← phi( main::@10/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#10 ← phi( main::@10/(byte[1000]) SCREEN#2 ) - (byte*) RASTER#7 ← phi( main::@10/(byte*) RASTER#10 ) + (byte[256]) buffer2#13 ← phi( main::@10/(byte[256]) buffer2#16 ) + (byte[256]) buffer1#21 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#9 ← phi( main::@10/(byte[1000]) SCREEN#2 ) + (byte*) RASTER#5 ← phi( main::@10/(byte*) RASTER#9 ) if(true) goto main::@1 - to:main::@8 -main::@8: from main::@11 to:main::@return -main::@return: from main::@8 +main::@return: from main::@11 return to:@RETURN -@1: from @5 - to:@2 prepare: from main (byte[256]) buffer1#5 ← phi( main/(byte[256]) buffer1#9 ) (byte) prepare::i#0 ← (byte) 0 @@ -630,14 +726,10 @@ prepare::@1: from prepare prepare::@1 (byte) prepare::i#1 ← ++ (byte) prepare::i#2 (boolean~) prepare::$0 ← (byte) prepare::i#1 != (byte) 0 if((boolean~) prepare::$0) goto prepare::@1 - to:prepare::@2 -prepare::@2: from prepare::@1 to:prepare::@return -prepare::@return: from prepare::@2 +prepare::@return: from prepare::@1 return to:@RETURN -@2: from @1 - to:@3 flip: from main::@7 (byte[256]) buffer2#5 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte[256]) buffer1#10 ← phi( main::@7/(byte[256]) buffer1#14 ) @@ -694,14 +786,10 @@ flip::@3: from flip::@3 flip::@5 (byte) flip::i#1 ← ++ (byte) flip::i#2 (boolean~) flip::$5 ← (byte) flip::i#1 != (byte) 0 if((boolean~) flip::$5) goto flip::@3 - to:flip::@6 -flip::@6: from flip::@3 to:flip::@return -flip::@return: from flip::@6 +flip::@return: from flip::@3 return to:@RETURN -@3: from @2 - to:@4 plot: from main::@10 (byte[256]) buffer1#12 ← phi( main::@10/(byte[256]) buffer1#15 ) (byte[1000]) SCREEN#1 ← phi( main::@10/(byte[1000]) SCREEN#2 ) @@ -742,15 +830,11 @@ plot::@3: from plot::@2 (byte) plot::y#1 ← -- (byte) plot::y#2 (boolean~) plot::$6 ← (byte) plot::y#1 != (byte) 0 if((boolean~) plot::$6) goto plot::@1 - to:plot::@4 -plot::@4: from plot::@3 to:plot::@return -plot::@return: from plot::@4 +plot::@return: from plot::@3 return to:@RETURN -@4: from @3 - to:@END -@END: from @4 +@END: from @5 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @BEGIN: from @@ -761,57 +845,50 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN call main param-assignment to:@5 @5: from @BEGIN - to:@1 + to:@END main: from @BEGIN - (byte[256]) buffer2#16 ← phi( @BEGIN/(byte[256]) buffer2#0 ) - (byte[1000]) SCREEN#12 ← phi( @BEGIN/(byte[1000]) SCREEN#0 ) - (byte*) RASTER#9 ← phi( @BEGIN/(byte*) RASTER#0 ) + (byte[256]) buffer2#15 ← phi( @BEGIN/(byte[256]) buffer2#0 ) + (byte[1000]) SCREEN#11 ← phi( @BEGIN/(byte[1000]) SCREEN#0 ) + (byte*) RASTER#8 ← phi( @BEGIN/(byte*) RASTER#0 ) (byte[256]) buffer1#9 ← phi( @BEGIN/(byte[256]) buffer1#0 ) call prepare param-assignment to:main::@9 main::@9: from main - (byte[256]) buffer2#15 ← phi( main/(byte[256]) buffer2#16 ) - (byte[256]) buffer1#23 ← phi( main/(byte[256]) buffer1#9 ) - (byte[1000]) SCREEN#11 ← phi( main/(byte[1000]) SCREEN#12 ) - (byte*) RASTER#8 ← phi( main/(byte*) RASTER#9 ) + (byte[256]) buffer2#14 ← phi( main/(byte[256]) buffer2#15 ) + (byte[256]) buffer1#22 ← phi( main/(byte[256]) buffer1#9 ) + (byte[1000]) SCREEN#10 ← phi( main/(byte[1000]) SCREEN#11 ) + (byte*) RASTER#6 ← phi( main/(byte*) RASTER#8 ) to:main::@1 main::@1: from main::@11 main::@9 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#22 main::@9/(byte[256]) buffer1#23 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#10 main::@9/(byte[1000]) SCREEN#11 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#7 main::@9/(byte*) RASTER#8 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#13 main::@9/(byte[256]) buffer2#14 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#21 main::@9/(byte[256]) buffer1#22 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#9 main::@9/(byte[1000]) SCREEN#10 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#5 main::@9/(byte*) RASTER#6 ) (byte) main::c#0 ← (byte) 25 - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#8 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#16 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#4 ) - (byte) main::c#6 ← phi( main::@1/(byte) main::c#0 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#6 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#11 ← phi( main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#11 ) - (byte[256]) buffer1#19 ← phi( main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#19 ) - (byte[1000]) SCREEN#7 ← phi( main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#7 ) - (byte) main::c#5 ← phi( main::@2/(byte) main::c#6 main::@3/(byte) main::c#5 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 main::@3/(byte*) RASTER#1 ) +main::@2: from main::@6 + (byte[256]) buffer2#12 ← phi( main::@6/(byte[256]) buffer2#8 ) + (byte[256]) buffer1#20 ← phi( main::@6/(byte[256]) buffer1#16 ) + (byte[1000]) SCREEN#8 ← phi( main::@6/(byte[1000]) SCREEN#4 ) + (byte) main::c#5 ← phi( main::@6/(byte) main::c#1 ) + (byte*) RASTER#4 ← phi( main::@6/(byte*) RASTER#7 ) + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#18 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#6 ) + (byte) main::c#4 ← phi( main::@1/(byte) main::c#0 main::@2/(byte) main::c#5 main::@3/(byte) main::c#4 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@2/(byte*) RASTER#4 main::@3/(byte*) RASTER#1 ) (byte~) main::$1 ← * (byte*) RASTER#1 (boolean~) main::$2 ← (byte~) main::$1 != (byte) 254 if((boolean~) main::$2) goto main::@3 - to:main::@5 -main::@5: from main::@3 - (byte[256]) buffer2#10 ← phi( main::@3/(byte[256]) buffer2#11 ) - (byte[256]) buffer1#18 ← phi( main::@3/(byte[256]) buffer1#19 ) - (byte[1000]) SCREEN#6 ← phi( main::@3/(byte[1000]) SCREEN#7 ) - (byte) main::c#4 ← phi( main::@3/(byte) main::c#5 ) - (byte*) RASTER#4 ← phi( main::@3/(byte*) RASTER#1 ) to:main::@4 -main::@4: from main::@4 main::@5 - (byte[256]) buffer2#9 ← phi( main::@4/(byte[256]) buffer2#9 main::@5/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#17 ← phi( main::@4/(byte[256]) buffer1#17 main::@5/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#5 ← phi( main::@4/(byte[1000]) SCREEN#5 main::@5/(byte[1000]) SCREEN#6 ) - (byte) main::c#3 ← phi( main::@4/(byte) main::c#3 main::@5/(byte) main::c#4 ) - (byte*) RASTER#2 ← phi( main::@4/(byte*) RASTER#2 main::@5/(byte*) RASTER#4 ) +main::@4: from main::@3 main::@4 + (byte[256]) buffer2#9 ← phi( main::@3/(byte[256]) buffer2#10 main::@4/(byte[256]) buffer2#9 ) + (byte[256]) buffer1#17 ← phi( main::@3/(byte[256]) buffer1#18 main::@4/(byte[256]) buffer1#17 ) + (byte[1000]) SCREEN#5 ← phi( main::@3/(byte[1000]) SCREEN#6 main::@4/(byte[1000]) SCREEN#5 ) + (byte) main::c#3 ← phi( main::@3/(byte) main::c#4 main::@4/(byte) main::c#3 ) + (byte*) RASTER#2 ← phi( main::@3/(byte*) RASTER#1 main::@4/(byte*) RASTER#2 ) (byte~) main::$3 ← * (byte*) RASTER#2 (boolean~) main::$4 ← (byte~) main::$3 != (byte) 255 if((boolean~) main::$4) goto main::@4 @@ -820,40 +897,36 @@ main::@6: from main::@4 (byte[256]) buffer2#8 ← phi( main::@4/(byte[256]) buffer2#9 ) (byte[256]) buffer1#16 ← phi( main::@4/(byte[256]) buffer1#17 ) (byte[1000]) SCREEN#4 ← phi( main::@4/(byte[1000]) SCREEN#5 ) - (byte*) RASTER#6 ← phi( main::@4/(byte*) RASTER#2 ) + (byte*) RASTER#7 ← phi( main::@4/(byte*) RASTER#2 ) (byte) main::c#2 ← phi( main::@4/(byte) main::c#3 ) (byte) main::c#1 ← -- (byte) main::c#2 (boolean~) main::$5 ← (byte) main::c#1 != (byte) 0 if((boolean~) main::$5) goto main::@2 to:main::@7 main::@7: from main::@6 - (byte*) RASTER#11 ← phi( main::@6/(byte*) RASTER#6 ) + (byte*) RASTER#10 ← phi( main::@6/(byte*) RASTER#7 ) (byte[256]) buffer2#7 ← phi( main::@6/(byte[256]) buffer2#8 ) (byte[256]) buffer1#14 ← phi( main::@6/(byte[256]) buffer1#16 ) (byte[1000]) SCREEN#3 ← phi( main::@6/(byte[1000]) SCREEN#4 ) call flip param-assignment to:main::@10 main::@10: from main::@7 - (byte[256]) buffer2#17 ← phi( main::@7/(byte[256]) buffer2#7 ) - (byte*) RASTER#10 ← phi( main::@7/(byte*) RASTER#11 ) + (byte[256]) buffer2#16 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte[256]) buffer1#15 ← phi( main::@7/(byte[256]) buffer1#14 ) + (byte*) RASTER#9 ← phi( main::@7/(byte*) RASTER#10 ) (byte[1000]) SCREEN#2 ← phi( main::@7/(byte[1000]) SCREEN#3 ) call plot param-assignment to:main::@11 main::@11: from main::@10 - (byte[256]) buffer2#14 ← phi( main::@10/(byte[256]) buffer2#17 ) - (byte[256]) buffer1#22 ← phi( main::@10/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#10 ← phi( main::@10/(byte[1000]) SCREEN#2 ) - (byte*) RASTER#7 ← phi( main::@10/(byte*) RASTER#10 ) + (byte[256]) buffer2#13 ← phi( main::@10/(byte[256]) buffer2#16 ) + (byte[256]) buffer1#21 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#9 ← phi( main::@10/(byte[1000]) SCREEN#2 ) + (byte*) RASTER#5 ← phi( main::@10/(byte*) RASTER#9 ) if(true) goto main::@1 - to:main::@8 -main::@8: from main::@11 to:main::@return -main::@return: from main::@8 +main::@return: from main::@11 return to:@RETURN -@1: from @5 - to:@2 prepare: from main (byte[256]) buffer1#5 ← phi( main/(byte[256]) buffer1#9 ) (byte) prepare::i#0 ← (byte) 0 @@ -865,14 +938,10 @@ prepare::@1: from prepare prepare::@1 (byte) prepare::i#1 ← ++ (byte) prepare::i#2 (boolean~) prepare::$0 ← (byte) prepare::i#1 != (byte) 0 if((boolean~) prepare::$0) goto prepare::@1 - to:prepare::@2 -prepare::@2: from prepare::@1 to:prepare::@return -prepare::@return: from prepare::@2 +prepare::@return: from prepare::@1 return to:@RETURN -@2: from @1 - to:@3 flip: from main::@7 (byte[256]) buffer2#5 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte[256]) buffer1#10 ← phi( main::@7/(byte[256]) buffer1#14 ) @@ -929,14 +998,10 @@ flip::@3: from flip::@3 flip::@5 (byte) flip::i#1 ← ++ (byte) flip::i#2 (boolean~) flip::$5 ← (byte) flip::i#1 != (byte) 0 if((boolean~) flip::$5) goto flip::@3 - to:flip::@6 -flip::@6: from flip::@3 to:flip::@return -flip::@return: from flip::@6 +flip::@return: from flip::@3 return to:@RETURN -@3: from @2 - to:@4 plot: from main::@10 (byte[256]) buffer1#12 ← phi( main::@10/(byte[256]) buffer1#15 ) (byte[1000]) SCREEN#1 ← phi( main::@10/(byte[1000]) SCREEN#2 ) @@ -977,25 +1042,13 @@ plot::@3: from plot::@2 (byte) plot::y#1 ← -- (byte) plot::y#2 (boolean~) plot::$6 ← (byte) plot::y#1 != (byte) 0 if((boolean~) plot::$6) goto plot::@1 - to:plot::@4 -plot::@4: from plot::@3 to:plot::@return -plot::@return: from plot::@4 +plot::@return: from plot::@3 return to:@RETURN -@4: from @3 - to:@END -@END: from @4 +@END: from @5 Culled Empty Block (label) @5 -Culled Empty Block (label) main::@8 -Culled Empty Block (label) @1 -Culled Empty Block (label) prepare::@2 -Culled Empty Block (label) @2 -Culled Empty Block (label) flip::@6 -Culled Empty Block (label) @3 -Culled Empty Block (label) plot::@4 -Culled Empty Block (label) @4 Succesful SSA optimization Pass2CullEmptyBlocks CONTROL FLOW GRAPH @BEGIN: from @@ -1006,55 +1059,48 @@ CONTROL FLOW GRAPH call main param-assignment to:@END main: from @BEGIN - (byte[256]) buffer2#16 ← phi( @BEGIN/(byte[256]) buffer2#0 ) - (byte[1000]) SCREEN#12 ← phi( @BEGIN/(byte[1000]) SCREEN#0 ) - (byte*) RASTER#9 ← phi( @BEGIN/(byte*) RASTER#0 ) + (byte[256]) buffer2#15 ← phi( @BEGIN/(byte[256]) buffer2#0 ) + (byte[1000]) SCREEN#11 ← phi( @BEGIN/(byte[1000]) SCREEN#0 ) + (byte*) RASTER#8 ← phi( @BEGIN/(byte*) RASTER#0 ) (byte[256]) buffer1#9 ← phi( @BEGIN/(byte[256]) buffer1#0 ) call prepare param-assignment to:main::@9 main::@9: from main - (byte[256]) buffer2#15 ← phi( main/(byte[256]) buffer2#16 ) - (byte[256]) buffer1#23 ← phi( main/(byte[256]) buffer1#9 ) - (byte[1000]) SCREEN#11 ← phi( main/(byte[1000]) SCREEN#12 ) - (byte*) RASTER#8 ← phi( main/(byte*) RASTER#9 ) + (byte[256]) buffer2#14 ← phi( main/(byte[256]) buffer2#15 ) + (byte[256]) buffer1#22 ← phi( main/(byte[256]) buffer1#9 ) + (byte[1000]) SCREEN#10 ← phi( main/(byte[1000]) SCREEN#11 ) + (byte*) RASTER#6 ← phi( main/(byte*) RASTER#8 ) to:main::@1 main::@1: from main::@11 main::@9 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#22 main::@9/(byte[256]) buffer1#23 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#10 main::@9/(byte[1000]) SCREEN#11 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#7 main::@9/(byte*) RASTER#8 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#13 main::@9/(byte[256]) buffer2#14 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#21 main::@9/(byte[256]) buffer1#22 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#9 main::@9/(byte[1000]) SCREEN#10 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#5 main::@9/(byte*) RASTER#6 ) (byte) main::c#0 ← (byte) 25 - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#8 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#16 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#4 ) - (byte) main::c#6 ← phi( main::@1/(byte) main::c#0 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#6 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#11 ← phi( main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#11 ) - (byte[256]) buffer1#19 ← phi( main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#19 ) - (byte[1000]) SCREEN#7 ← phi( main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#7 ) - (byte) main::c#5 ← phi( main::@2/(byte) main::c#6 main::@3/(byte) main::c#5 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 main::@3/(byte*) RASTER#1 ) +main::@2: from main::@6 + (byte[256]) buffer2#12 ← phi( main::@6/(byte[256]) buffer2#8 ) + (byte[256]) buffer1#20 ← phi( main::@6/(byte[256]) buffer1#16 ) + (byte[1000]) SCREEN#8 ← phi( main::@6/(byte[1000]) SCREEN#4 ) + (byte) main::c#5 ← phi( main::@6/(byte) main::c#1 ) + (byte*) RASTER#4 ← phi( main::@6/(byte*) RASTER#7 ) + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#18 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#6 ) + (byte) main::c#4 ← phi( main::@1/(byte) main::c#0 main::@2/(byte) main::c#5 main::@3/(byte) main::c#4 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@2/(byte*) RASTER#4 main::@3/(byte*) RASTER#1 ) (byte~) main::$1 ← * (byte*) RASTER#1 (boolean~) main::$2 ← (byte~) main::$1 != (byte) 254 if((boolean~) main::$2) goto main::@3 - to:main::@5 -main::@5: from main::@3 - (byte[256]) buffer2#10 ← phi( main::@3/(byte[256]) buffer2#11 ) - (byte[256]) buffer1#18 ← phi( main::@3/(byte[256]) buffer1#19 ) - (byte[1000]) SCREEN#6 ← phi( main::@3/(byte[1000]) SCREEN#7 ) - (byte) main::c#4 ← phi( main::@3/(byte) main::c#5 ) - (byte*) RASTER#4 ← phi( main::@3/(byte*) RASTER#1 ) to:main::@4 -main::@4: from main::@4 main::@5 - (byte[256]) buffer2#9 ← phi( main::@4/(byte[256]) buffer2#9 main::@5/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#17 ← phi( main::@4/(byte[256]) buffer1#17 main::@5/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#5 ← phi( main::@4/(byte[1000]) SCREEN#5 main::@5/(byte[1000]) SCREEN#6 ) - (byte) main::c#3 ← phi( main::@4/(byte) main::c#3 main::@5/(byte) main::c#4 ) - (byte*) RASTER#2 ← phi( main::@4/(byte*) RASTER#2 main::@5/(byte*) RASTER#4 ) +main::@4: from main::@3 main::@4 + (byte[256]) buffer2#9 ← phi( main::@3/(byte[256]) buffer2#10 main::@4/(byte[256]) buffer2#9 ) + (byte[256]) buffer1#17 ← phi( main::@3/(byte[256]) buffer1#18 main::@4/(byte[256]) buffer1#17 ) + (byte[1000]) SCREEN#5 ← phi( main::@3/(byte[1000]) SCREEN#6 main::@4/(byte[1000]) SCREEN#5 ) + (byte) main::c#3 ← phi( main::@3/(byte) main::c#4 main::@4/(byte) main::c#3 ) + (byte*) RASTER#2 ← phi( main::@3/(byte*) RASTER#1 main::@4/(byte*) RASTER#2 ) (byte~) main::$3 ← * (byte*) RASTER#2 (boolean~) main::$4 ← (byte~) main::$3 != (byte) 255 if((boolean~) main::$4) goto main::@4 @@ -1063,31 +1109,31 @@ main::@6: from main::@4 (byte[256]) buffer2#8 ← phi( main::@4/(byte[256]) buffer2#9 ) (byte[256]) buffer1#16 ← phi( main::@4/(byte[256]) buffer1#17 ) (byte[1000]) SCREEN#4 ← phi( main::@4/(byte[1000]) SCREEN#5 ) - (byte*) RASTER#6 ← phi( main::@4/(byte*) RASTER#2 ) + (byte*) RASTER#7 ← phi( main::@4/(byte*) RASTER#2 ) (byte) main::c#2 ← phi( main::@4/(byte) main::c#3 ) (byte) main::c#1 ← -- (byte) main::c#2 (boolean~) main::$5 ← (byte) main::c#1 != (byte) 0 if((boolean~) main::$5) goto main::@2 to:main::@7 main::@7: from main::@6 - (byte*) RASTER#11 ← phi( main::@6/(byte*) RASTER#6 ) + (byte*) RASTER#10 ← phi( main::@6/(byte*) RASTER#7 ) (byte[256]) buffer2#7 ← phi( main::@6/(byte[256]) buffer2#8 ) (byte[256]) buffer1#14 ← phi( main::@6/(byte[256]) buffer1#16 ) (byte[1000]) SCREEN#3 ← phi( main::@6/(byte[1000]) SCREEN#4 ) call flip param-assignment to:main::@10 main::@10: from main::@7 - (byte[256]) buffer2#17 ← phi( main::@7/(byte[256]) buffer2#7 ) - (byte*) RASTER#10 ← phi( main::@7/(byte*) RASTER#11 ) + (byte[256]) buffer2#16 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte[256]) buffer1#15 ← phi( main::@7/(byte[256]) buffer1#14 ) + (byte*) RASTER#9 ← phi( main::@7/(byte*) RASTER#10 ) (byte[1000]) SCREEN#2 ← phi( main::@7/(byte[1000]) SCREEN#3 ) call plot param-assignment to:main::@11 main::@11: from main::@10 - (byte[256]) buffer2#14 ← phi( main::@10/(byte[256]) buffer2#17 ) - (byte[256]) buffer1#22 ← phi( main::@10/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#10 ← phi( main::@10/(byte[1000]) SCREEN#2 ) - (byte*) RASTER#7 ← phi( main::@10/(byte*) RASTER#10 ) + (byte[256]) buffer2#13 ← phi( main::@10/(byte[256]) buffer2#16 ) + (byte[256]) buffer1#21 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#9 ← phi( main::@10/(byte[1000]) SCREEN#2 ) + (byte*) RASTER#5 ← phi( main::@10/(byte*) RASTER#9 ) if(true) goto main::@1 to:main::@return main::@return: from main::@11 @@ -1235,54 +1281,47 @@ CONTROL FLOW GRAPH call main param-assignment to:@END main: from @BEGIN - (byte[256]) buffer2#16 ← phi( @BEGIN/(word) 4352 ) - (byte[1000]) SCREEN#12 ← phi( @BEGIN/(word) 1024 ) - (byte*) RASTER#9 ← phi( @BEGIN/(word) 53266 ) + (byte[256]) buffer2#15 ← phi( @BEGIN/(word) 4352 ) + (byte[1000]) SCREEN#11 ← phi( @BEGIN/(word) 1024 ) + (byte*) RASTER#8 ← phi( @BEGIN/(word) 53266 ) (byte[256]) buffer1#9 ← phi( @BEGIN/(word) 4096 ) call prepare param-assignment to:main::@9 main::@9: from main - (byte[256]) buffer2#15 ← phi( main/(byte[256]) buffer2#16 ) - (byte[256]) buffer1#23 ← phi( main/(byte[256]) buffer1#9 ) - (byte[1000]) SCREEN#11 ← phi( main/(byte[1000]) SCREEN#12 ) - (byte*) RASTER#8 ← phi( main/(byte*) RASTER#9 ) + (byte[256]) buffer2#14 ← phi( main/(byte[256]) buffer2#15 ) + (byte[256]) buffer1#22 ← phi( main/(byte[256]) buffer1#9 ) + (byte[1000]) SCREEN#10 ← phi( main/(byte[1000]) SCREEN#11 ) + (byte*) RASTER#6 ← phi( main/(byte*) RASTER#8 ) to:main::@1 main::@1: from main::@11 main::@9 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#22 main::@9/(byte[256]) buffer1#23 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#10 main::@9/(byte[1000]) SCREEN#11 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#7 main::@9/(byte*) RASTER#8 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#8 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#16 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#4 ) - (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#6 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#13 main::@9/(byte[256]) buffer2#14 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#21 main::@9/(byte[256]) buffer1#22 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#9 main::@9/(byte[1000]) SCREEN#10 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#5 main::@9/(byte*) RASTER#6 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#11 ← phi( main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#11 ) - (byte[256]) buffer1#19 ← phi( main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#19 ) - (byte[1000]) SCREEN#7 ← phi( main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#7 ) - (byte) main::c#5 ← phi( main::@2/(byte) main::c#6 main::@3/(byte) main::c#5 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 main::@3/(byte*) RASTER#1 ) +main::@2: from main::@6 + (byte[256]) buffer2#12 ← phi( main::@6/(byte[256]) buffer2#8 ) + (byte[256]) buffer1#20 ← phi( main::@6/(byte[256]) buffer1#16 ) + (byte[1000]) SCREEN#8 ← phi( main::@6/(byte[1000]) SCREEN#4 ) + (byte) main::c#5 ← phi( main::@6/(byte) main::c#1 ) + (byte*) RASTER#4 ← phi( main::@6/(byte*) RASTER#7 ) + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#18 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#6 ) + (byte) main::c#4 ← phi( main::@1/(byte) 25 main::@2/(byte) main::c#5 main::@3/(byte) main::c#4 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@2/(byte*) RASTER#4 main::@3/(byte*) RASTER#1 ) (byte~) main::$1 ← * (byte*) RASTER#1 (boolean~) main::$2 ← (byte~) main::$1 != (byte) 254 if((boolean~) main::$2) goto main::@3 - to:main::@5 -main::@5: from main::@3 - (byte[256]) buffer2#10 ← phi( main::@3/(byte[256]) buffer2#11 ) - (byte[256]) buffer1#18 ← phi( main::@3/(byte[256]) buffer1#19 ) - (byte[1000]) SCREEN#6 ← phi( main::@3/(byte[1000]) SCREEN#7 ) - (byte) main::c#4 ← phi( main::@3/(byte) main::c#5 ) - (byte*) RASTER#4 ← phi( main::@3/(byte*) RASTER#1 ) to:main::@4 -main::@4: from main::@4 main::@5 - (byte[256]) buffer2#9 ← phi( main::@4/(byte[256]) buffer2#9 main::@5/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#17 ← phi( main::@4/(byte[256]) buffer1#17 main::@5/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#5 ← phi( main::@4/(byte[1000]) SCREEN#5 main::@5/(byte[1000]) SCREEN#6 ) - (byte) main::c#3 ← phi( main::@4/(byte) main::c#3 main::@5/(byte) main::c#4 ) - (byte*) RASTER#2 ← phi( main::@4/(byte*) RASTER#2 main::@5/(byte*) RASTER#4 ) +main::@4: from main::@3 main::@4 + (byte[256]) buffer2#9 ← phi( main::@3/(byte[256]) buffer2#10 main::@4/(byte[256]) buffer2#9 ) + (byte[256]) buffer1#17 ← phi( main::@3/(byte[256]) buffer1#18 main::@4/(byte[256]) buffer1#17 ) + (byte[1000]) SCREEN#5 ← phi( main::@3/(byte[1000]) SCREEN#6 main::@4/(byte[1000]) SCREEN#5 ) + (byte) main::c#3 ← phi( main::@3/(byte) main::c#4 main::@4/(byte) main::c#3 ) + (byte*) RASTER#2 ← phi( main::@3/(byte*) RASTER#1 main::@4/(byte*) RASTER#2 ) (byte~) main::$3 ← * (byte*) RASTER#2 (boolean~) main::$4 ← (byte~) main::$3 != (byte) 255 if((boolean~) main::$4) goto main::@4 @@ -1291,31 +1330,31 @@ main::@6: from main::@4 (byte[256]) buffer2#8 ← phi( main::@4/(byte[256]) buffer2#9 ) (byte[256]) buffer1#16 ← phi( main::@4/(byte[256]) buffer1#17 ) (byte[1000]) SCREEN#4 ← phi( main::@4/(byte[1000]) SCREEN#5 ) - (byte*) RASTER#6 ← phi( main::@4/(byte*) RASTER#2 ) + (byte*) RASTER#7 ← phi( main::@4/(byte*) RASTER#2 ) (byte) main::c#2 ← phi( main::@4/(byte) main::c#3 ) (byte) main::c#1 ← -- (byte) main::c#2 (boolean~) main::$5 ← (byte) main::c#1 != (byte) 0 if((boolean~) main::$5) goto main::@2 to:main::@7 main::@7: from main::@6 - (byte*) RASTER#11 ← phi( main::@6/(byte*) RASTER#6 ) + (byte*) RASTER#10 ← phi( main::@6/(byte*) RASTER#7 ) (byte[256]) buffer2#7 ← phi( main::@6/(byte[256]) buffer2#8 ) (byte[256]) buffer1#14 ← phi( main::@6/(byte[256]) buffer1#16 ) (byte[1000]) SCREEN#3 ← phi( main::@6/(byte[1000]) SCREEN#4 ) call flip param-assignment to:main::@10 main::@10: from main::@7 - (byte[256]) buffer2#17 ← phi( main::@7/(byte[256]) buffer2#7 ) - (byte*) RASTER#10 ← phi( main::@7/(byte*) RASTER#11 ) + (byte[256]) buffer2#16 ← phi( main::@7/(byte[256]) buffer2#7 ) (byte[256]) buffer1#15 ← phi( main::@7/(byte[256]) buffer1#14 ) + (byte*) RASTER#9 ← phi( main::@7/(byte*) RASTER#10 ) (byte[1000]) SCREEN#2 ← phi( main::@7/(byte[1000]) SCREEN#3 ) call plot param-assignment to:main::@11 main::@11: from main::@10 - (byte[256]) buffer2#14 ← phi( main::@10/(byte[256]) buffer2#17 ) - (byte[256]) buffer1#22 ← phi( main::@10/(byte[256]) buffer1#15 ) - (byte[1000]) SCREEN#10 ← phi( main::@10/(byte[1000]) SCREEN#2 ) - (byte*) RASTER#7 ← phi( main::@10/(byte*) RASTER#10 ) + (byte[256]) buffer2#13 ← phi( main::@10/(byte[256]) buffer2#16 ) + (byte[256]) buffer1#21 ← phi( main::@10/(byte[256]) buffer1#15 ) + (byte[1000]) SCREEN#9 ← phi( main::@10/(byte[1000]) SCREEN#2 ) + (byte*) RASTER#5 ← phi( main::@10/(byte*) RASTER#9 ) if(true) goto main::@1 to:main::@return main::@return: from main::@11 @@ -1432,20 +1471,16 @@ plot::@return: from plot::@3 to:@RETURN @END: from @BEGIN -Alias (byte*) RASTER#8 = (byte*) RASTER#9 -Alias (byte[1000]) SCREEN#11 = (byte[1000]) SCREEN#12 -Alias (byte[256]) buffer1#23 = (byte[256]) buffer1#9 (byte[256]) buffer1#5 -Alias (byte[256]) buffer2#15 = (byte[256]) buffer2#16 -Alias (byte*) RASTER#1 = (byte*) RASTER#4 -Alias (byte) main::c#4 = (byte) main::c#5 -Alias (byte[1000]) SCREEN#6 = (byte[1000]) SCREEN#7 -Alias (byte[256]) buffer1#18 = (byte[256]) buffer1#19 -Alias (byte[256]) buffer2#10 = (byte[256]) buffer2#11 +Alias (byte*) RASTER#6 = (byte*) RASTER#8 +Alias (byte[1000]) SCREEN#10 = (byte[1000]) SCREEN#11 +Alias (byte[256]) buffer1#22 = (byte[256]) buffer1#9 (byte[256]) buffer1#5 +Alias (byte[256]) buffer2#14 = (byte[256]) buffer2#15 +Alias (byte*) RASTER#10 = (byte*) RASTER#4 (byte*) RASTER#7 (byte*) RASTER#2 (byte*) RASTER#9 (byte*) RASTER#5 +Alias (byte) main::c#1 = (byte) main::c#5 +Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#8 (byte[1000]) SCREEN#4 (byte[1000]) SCREEN#5 (byte[1000]) SCREEN#3 (byte[1000]) SCREEN#2 (byte[1000]) SCREEN#9 +Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#20 (byte[256]) buffer1#16 (byte[256]) buffer1#17 (byte[256]) buffer1#14 (byte[256]) buffer1#15 (byte[256]) buffer1#21 (byte[256]) buffer1#12 +Alias (byte[256]) buffer2#12 = (byte[256]) buffer2#8 (byte[256]) buffer2#9 (byte[256]) buffer2#7 (byte[256]) buffer2#16 (byte[256]) buffer2#13 (byte[256]) buffer2#5 Alias (byte) main::c#2 = (byte) main::c#3 -Alias (byte*) RASTER#10 = (byte*) RASTER#6 (byte*) RASTER#2 (byte*) RASTER#11 (byte*) RASTER#7 -Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#4 (byte[1000]) SCREEN#5 (byte[1000]) SCREEN#3 (byte[1000]) SCREEN#2 (byte[1000]) SCREEN#10 -Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#16 (byte[256]) buffer1#17 (byte[256]) buffer1#14 (byte[256]) buffer1#15 (byte[256]) buffer1#22 (byte[256]) buffer1#12 -Alias (byte[256]) buffer2#14 = (byte[256]) buffer2#8 (byte[256]) buffer2#9 (byte[256]) buffer2#7 (byte[256]) buffer2#17 (byte[256]) buffer2#5 Alias (byte) flip::dstIdx#1 = (byte~) flip::$1 (byte) flip::dstIdx#4 Alias (byte) flip::r#2 = (byte) flip::r#3 Alias (byte[256]) buffer1#11 = (byte[256]) buffer1#2 (byte[256]) buffer1#7 @@ -1463,45 +1498,38 @@ CONTROL FLOW GRAPH call main param-assignment to:@END main: from @BEGIN - (byte[256]) buffer2#15 ← phi( @BEGIN/(word) 4352 ) - (byte[1000]) SCREEN#11 ← phi( @BEGIN/(word) 1024 ) - (byte*) RASTER#8 ← phi( @BEGIN/(word) 53266 ) - (byte[256]) buffer1#23 ← phi( @BEGIN/(word) 4096 ) + (byte[256]) buffer2#14 ← phi( @BEGIN/(word) 4352 ) + (byte[1000]) SCREEN#10 ← phi( @BEGIN/(word) 1024 ) + (byte*) RASTER#6 ← phi( @BEGIN/(word) 53266 ) + (byte[256]) buffer1#22 ← phi( @BEGIN/(word) 4096 ) call prepare param-assignment to:main::@9 main::@9: from main to:main::@1 main::@1: from main::@11 main::@9 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(byte[256]) buffer2#15 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(byte[256]) buffer1#23 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(byte[1000]) SCREEN#11 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main::@9/(byte*) RASTER#8 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) - (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#10 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#12 main::@9/(byte[256]) buffer2#14 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(byte[256]) buffer1#22 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(byte[1000]) SCREEN#10 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#10 main::@9/(byte*) RASTER#6 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#10 ← phi( main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#18 ← phi( main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#6 ← phi( main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#6 ) - (byte) main::c#4 ← phi( main::@2/(byte) main::c#6 main::@3/(byte) main::c#4 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 main::@3/(byte*) RASTER#1 ) +main::@2: from main::@6 + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@2/(byte[256]) buffer1#10 main::@3/(byte[256]) buffer1#18 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@2/(byte[1000]) SCREEN#1 main::@3/(byte[1000]) SCREEN#6 ) + (byte) main::c#4 ← phi( main::@1/(byte) 25 main::@2/(byte) main::c#1 main::@3/(byte) main::c#4 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@2/(byte*) RASTER#10 main::@3/(byte*) RASTER#1 ) (byte~) main::$1 ← * (byte*) RASTER#1 (boolean~) main::$2 ← (byte~) main::$1 != (byte) 254 if((boolean~) main::$2) goto main::@3 - to:main::@5 -main::@5: from main::@3 to:main::@4 -main::@4: from main::@4 main::@5 - (byte[256]) buffer2#14 ← phi( main::@4/(byte[256]) buffer2#14 main::@5/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#10 ← phi( main::@4/(byte[256]) buffer1#10 main::@5/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#1 ← phi( main::@4/(byte[1000]) SCREEN#1 main::@5/(byte[1000]) SCREEN#6 ) - (byte) main::c#2 ← phi( main::@4/(byte) main::c#2 main::@5/(byte) main::c#4 ) - (byte*) RASTER#10 ← phi( main::@4/(byte*) RASTER#10 main::@5/(byte*) RASTER#1 ) +main::@4: from main::@3 main::@4 + (byte[256]) buffer2#12 ← phi( main::@3/(byte[256]) buffer2#10 main::@4/(byte[256]) buffer2#12 ) + (byte[256]) buffer1#10 ← phi( main::@3/(byte[256]) buffer1#18 main::@4/(byte[256]) buffer1#10 ) + (byte[1000]) SCREEN#1 ← phi( main::@3/(byte[1000]) SCREEN#6 main::@4/(byte[1000]) SCREEN#1 ) + (byte) main::c#2 ← phi( main::@3/(byte) main::c#4 main::@4/(byte) main::c#2 ) + (byte*) RASTER#10 ← phi( main::@3/(byte*) RASTER#1 main::@4/(byte*) RASTER#10 ) (byte~) main::$3 ← * (byte*) RASTER#10 (boolean~) main::$4 ← (byte~) main::$3 != (byte) 255 if((boolean~) main::$4) goto main::@4 @@ -1526,7 +1554,7 @@ main::@return: from main::@11 prepare: from main to:prepare::@1 prepare::@1: from prepare prepare::@1 - (byte[256]) buffer1#1 ← phi( prepare/(byte[256]) buffer1#23 prepare::@1/(byte[256]) buffer1#1 ) + (byte[256]) buffer1#1 ← phi( prepare/(byte[256]) buffer1#22 prepare::@1/(byte[256]) buffer1#1 ) (byte) prepare::i#2 ← phi( prepare/(byte) 0 prepare::@1/(byte) prepare::i#1 ) *((byte[256]) buffer1#1 + (byte) prepare::i#2) ← (byte) prepare::i#2 (byte) prepare::i#1 ← ++ (byte) prepare::i#2 @@ -1541,7 +1569,7 @@ flip: from main::@7 flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#12 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) to:flip::@2 @@ -1615,10 +1643,10 @@ plot::@return: from plot::@3 to:@RETURN @END: from @BEGIN -Redundant Phi (byte[256]) buffer1#23 (word) 4096 -Redundant Phi (byte*) RASTER#8 (word) 53266 -Redundant Phi (byte[1000]) SCREEN#11 (word) 1024 -Redundant Phi (byte[256]) buffer2#15 (word) 4352 +Redundant Phi (byte[256]) buffer1#22 (word) 4096 +Redundant Phi (byte*) RASTER#6 (word) 53266 +Redundant Phi (byte[1000]) SCREEN#10 (word) 1024 +Redundant Phi (byte[256]) buffer2#14 (word) 4352 Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @BEGIN: from @@ -1630,36 +1658,29 @@ main: from @BEGIN main::@9: from main to:main::@1 main::@1: from main::@11 main::@9 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(word) 4352 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(word) 4096 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(word) 1024 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main::@9/(word) 53266 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) - (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#10 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#12 main::@9/(word) 4352 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(word) 4096 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(word) 1024 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#10 main::@9/(word) 53266 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#10 ← phi( main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#18 ← phi( main::@2/(byte[256]) buffer1#20 main::@3/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#6 ← phi( main::@2/(byte[1000]) SCREEN#8 main::@3/(byte[1000]) SCREEN#6 ) - (byte) main::c#4 ← phi( main::@2/(byte) main::c#6 main::@3/(byte) main::c#4 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 main::@3/(byte*) RASTER#1 ) +main::@2: from main::@6 + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@2/(byte[256]) buffer2#12 main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@2/(byte[256]) buffer1#10 main::@3/(byte[256]) buffer1#18 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@2/(byte[1000]) SCREEN#1 main::@3/(byte[1000]) SCREEN#6 ) + (byte) main::c#4 ← phi( main::@1/(byte) 25 main::@2/(byte) main::c#1 main::@3/(byte) main::c#4 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@2/(byte*) RASTER#10 main::@3/(byte*) RASTER#1 ) (byte~) main::$1 ← * (byte*) RASTER#1 (boolean~) main::$2 ← (byte~) main::$1 != (byte) 254 if((boolean~) main::$2) goto main::@3 - to:main::@5 -main::@5: from main::@3 to:main::@4 -main::@4: from main::@4 main::@5 - (byte[256]) buffer2#14 ← phi( main::@4/(byte[256]) buffer2#14 main::@5/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#10 ← phi( main::@4/(byte[256]) buffer1#10 main::@5/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#1 ← phi( main::@4/(byte[1000]) SCREEN#1 main::@5/(byte[1000]) SCREEN#6 ) - (byte) main::c#2 ← phi( main::@4/(byte) main::c#2 main::@5/(byte) main::c#4 ) - (byte*) RASTER#10 ← phi( main::@4/(byte*) RASTER#10 main::@5/(byte*) RASTER#1 ) +main::@4: from main::@3 main::@4 + (byte[256]) buffer2#12 ← phi( main::@3/(byte[256]) buffer2#10 main::@4/(byte[256]) buffer2#12 ) + (byte[256]) buffer1#10 ← phi( main::@3/(byte[256]) buffer1#18 main::@4/(byte[256]) buffer1#10 ) + (byte[1000]) SCREEN#1 ← phi( main::@3/(byte[1000]) SCREEN#6 main::@4/(byte[1000]) SCREEN#1 ) + (byte) main::c#2 ← phi( main::@3/(byte) main::c#4 main::@4/(byte) main::c#2 ) + (byte*) RASTER#10 ← phi( main::@3/(byte*) RASTER#1 main::@4/(byte*) RASTER#10 ) (byte~) main::$3 ← * (byte*) RASTER#10 (boolean~) main::$4 ← (byte~) main::$3 != (byte) 255 if((boolean~) main::$4) goto main::@4 @@ -1699,7 +1720,7 @@ flip: from main::@7 flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#12 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) to:flip::@2 @@ -1782,7 +1803,7 @@ Self Phi Eliminated (byte*) RASTER#10 Self Phi Eliminated (byte) main::c#2 Self Phi Eliminated (byte[1000]) SCREEN#1 Self Phi Eliminated (byte[256]) buffer1#10 -Self Phi Eliminated (byte[256]) buffer2#14 +Self Phi Eliminated (byte[256]) buffer2#12 Self Phi Eliminated (byte[256]) buffer1#1 Self Phi Eliminated (byte[256]) buffer1#11 Self Phi Eliminated (byte[256]) buffer2#1 @@ -1803,36 +1824,29 @@ main: from @BEGIN main::@9: from main to:main::@1 main::@1: from main::@11 main::@9 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(word) 4352 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(word) 4096 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(word) 1024 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main::@9/(word) 53266 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) - (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#10 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#12 main::@9/(word) 4352 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(word) 4096 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(word) 1024 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#10 main::@9/(word) 53266 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#10 ← phi( main::@2/(byte[256]) buffer2#12 ) - (byte[256]) buffer1#18 ← phi( main::@2/(byte[256]) buffer1#20 ) - (byte[1000]) SCREEN#6 ← phi( main::@2/(byte[1000]) SCREEN#8 ) - (byte) main::c#4 ← phi( main::@2/(byte) main::c#6 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 ) +main::@2: from main::@6 + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@2/(byte[256]) buffer2#12 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@2/(byte[256]) buffer1#10 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@2/(byte[1000]) SCREEN#1 ) + (byte) main::c#4 ← phi( main::@1/(byte) 25 main::@2/(byte) main::c#1 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@2/(byte*) RASTER#10 ) (byte~) main::$1 ← * (byte*) RASTER#1 (boolean~) main::$2 ← (byte~) main::$1 != (byte) 254 if((boolean~) main::$2) goto main::@3 - to:main::@5 -main::@5: from main::@3 to:main::@4 -main::@4: from main::@4 main::@5 - (byte[256]) buffer2#14 ← phi( main::@5/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#10 ← phi( main::@5/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#1 ← phi( main::@5/(byte[1000]) SCREEN#6 ) - (byte) main::c#2 ← phi( main::@5/(byte) main::c#4 ) - (byte*) RASTER#10 ← phi( main::@5/(byte*) RASTER#1 ) +main::@4: from main::@3 main::@4 + (byte[256]) buffer2#12 ← phi( main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer1#10 ← phi( main::@3/(byte[256]) buffer1#18 ) + (byte[1000]) SCREEN#1 ← phi( main::@3/(byte[1000]) SCREEN#6 ) + (byte) main::c#2 ← phi( main::@3/(byte) main::c#4 ) + (byte*) RASTER#10 ← phi( main::@3/(byte*) RASTER#1 ) (byte~) main::$3 ← * (byte*) RASTER#10 (boolean~) main::$4 ← (byte~) main::$3 != (byte) 255 if((boolean~) main::$4) goto main::@4 @@ -1872,7 +1886,7 @@ flip: from main::@7 flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#12 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) to:flip::@2 @@ -1966,35 +1980,28 @@ main: from @BEGIN main::@9: from main to:main::@1 main::@1: from main::@11 main::@9 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main::@9/(word) 4352 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(word) 4096 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(word) 1024 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main::@9/(word) 53266 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) - (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#10 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#12 main::@9/(word) 4352 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#10 main::@9/(word) 4096 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#1 main::@9/(word) 1024 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#10 main::@9/(word) 53266 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#10 ← phi( main::@2/(byte[256]) buffer2#12 ) - (byte[256]) buffer1#18 ← phi( main::@2/(byte[256]) buffer1#20 ) - (byte[1000]) SCREEN#6 ← phi( main::@2/(byte[1000]) SCREEN#8 ) - (byte) main::c#4 ← phi( main::@2/(byte) main::c#6 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 ) +main::@2: from main::@6 + to:main::@3 +main::@3: from main::@1 main::@2 main::@3 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@2/(byte[256]) buffer2#12 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@2/(byte[256]) buffer1#10 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@2/(byte[1000]) SCREEN#1 ) + (byte) main::c#4 ← phi( main::@1/(byte) 25 main::@2/(byte) main::c#1 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@2/(byte*) RASTER#10 ) (byte~) main::$1 ← * (byte*) RASTER#1 if((byte~) main::$1!=(byte) 254) goto main::@3 - to:main::@5 -main::@5: from main::@3 to:main::@4 -main::@4: from main::@4 main::@5 - (byte[256]) buffer2#14 ← phi( main::@5/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#10 ← phi( main::@5/(byte[256]) buffer1#18 ) - (byte[1000]) SCREEN#1 ← phi( main::@5/(byte[1000]) SCREEN#6 ) - (byte) main::c#2 ← phi( main::@5/(byte) main::c#4 ) - (byte*) RASTER#10 ← phi( main::@5/(byte*) RASTER#1 ) +main::@4: from main::@3 main::@4 + (byte[256]) buffer2#12 ← phi( main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer1#10 ← phi( main::@3/(byte[256]) buffer1#18 ) + (byte[1000]) SCREEN#1 ← phi( main::@3/(byte[1000]) SCREEN#6 ) + (byte) main::c#2 ← phi( main::@3/(byte) main::c#4 ) + (byte*) RASTER#10 ← phi( main::@3/(byte*) RASTER#1 ) (byte~) main::$3 ← * (byte*) RASTER#10 if((byte~) main::$3!=(byte) 255) goto main::@4 to:main::@6 @@ -2031,7 +2038,7 @@ flip: from main::@7 flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#12 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) to:flip::@2 @@ -2101,7 +2108,7 @@ plot::@return: from plot::@3 @END: from @BEGIN Culled Empty Block (label) main::@9 -Culled Empty Block (label) main::@5 +Culled Empty Block (label) main::@2 Culled Empty Block (label) flip::@5 Succesful SSA optimization Pass2CullEmptyBlocks CONTROL FLOW GRAPH @@ -2112,29 +2119,22 @@ main: from @BEGIN call prepare param-assignment to:main::@1 main::@1: from main main::@11 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main/(word) 4352 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main/(word) 53266 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) - (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#10 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#12 main/(word) 4352 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#10 main/(word) 53266 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#10 ← phi( main::@2/(byte[256]) buffer2#12 ) - (byte[256]) buffer1#18 ← phi( main::@2/(byte[256]) buffer1#20 ) - (byte[1000]) SCREEN#6 ← phi( main::@2/(byte[1000]) SCREEN#8 ) - (byte) main::c#4 ← phi( main::@2/(byte) main::c#6 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 ) +main::@3: from main::@1 main::@3 main::@6 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@6/(byte[256]) buffer2#12 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@6/(byte[256]) buffer1#10 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@6/(byte[1000]) SCREEN#1 ) + (byte) main::c#4 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@6/(byte*) RASTER#10 ) (byte~) main::$1 ← * (byte*) RASTER#1 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 main::@4: from main::@3 main::@4 - (byte[256]) buffer2#14 ← phi( main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer2#12 ← phi( main::@3/(byte[256]) buffer2#10 ) (byte[256]) buffer1#10 ← phi( main::@3/(byte[256]) buffer1#18 ) (byte[1000]) SCREEN#1 ← phi( main::@3/(byte[1000]) SCREEN#6 ) (byte) main::c#2 ← phi( main::@3/(byte) main::c#4 ) @@ -2144,7 +2144,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -2175,7 +2175,7 @@ flip: from main::@7 flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#12 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) to:flip::@2 @@ -2252,29 +2252,22 @@ main: from @BEGIN call prepare param-assignment to:main::@1 main::@1: from main main::@11 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#14 main/(word) 4352 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#10 main/(word) 53266 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#12 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#14 ) - (byte[256]) buffer1#20 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) - (byte[1000]) SCREEN#8 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) - (byte) main::c#6 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) - (byte*) RASTER#3 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#10 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#12 main/(word) 4352 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#10 main/(word) 53266 ) to:main::@3 -main::@3: from main::@2 main::@3 - (byte[256]) buffer2#10 ← phi( main::@2/(byte[256]) buffer2#12 ) - (byte[256]) buffer1#18 ← phi( main::@2/(byte[256]) buffer1#20 ) - (byte[1000]) SCREEN#6 ← phi( main::@2/(byte[1000]) SCREEN#8 ) - (byte) main::c#4 ← phi( main::@2/(byte) main::c#6 ) - (byte*) RASTER#1 ← phi( main::@2/(byte*) RASTER#3 ) +main::@3: from main::@1 main::@3 main::@6 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@6/(byte[256]) buffer2#12 ) + (byte[256]) buffer1#18 ← phi( main::@1/(byte[256]) buffer1#19 main::@6/(byte[256]) buffer1#10 ) + (byte[1000]) SCREEN#6 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@6/(byte[1000]) SCREEN#1 ) + (byte) main::c#4 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@6/(byte*) RASTER#10 ) (byte~) main::$1 ← * (byte*) RASTER#1 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 main::@4: from main::@3 main::@4 - (byte[256]) buffer2#14 ← phi( main::@3/(byte[256]) buffer2#10 ) + (byte[256]) buffer2#12 ← phi( main::@3/(byte[256]) buffer2#10 ) (byte[256]) buffer1#10 ← phi( main::@3/(byte[256]) buffer1#18 ) (byte[1000]) SCREEN#1 ← phi( main::@3/(byte[1000]) SCREEN#6 ) (byte) main::c#2 ← phi( main::@3/(byte) main::c#4 ) @@ -2284,7 +2277,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -2314,7 +2307,7 @@ flip: from main::@7 flip::@1: from flip flip::@4 (byte) flip::r#4 ← phi( flip/(byte) 16 flip::@4/(byte) flip::r#1 ) (byte) flip::dstIdx#5 ← phi( flip/(byte) 15 flip::@4/(byte) flip::dstIdx#2 ) - (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#14 flip::@4/(byte[256]) buffer2#1 ) + (byte[256]) buffer2#3 ← phi( flip/(byte[256]) buffer2#12 flip::@4/(byte[256]) buffer2#1 ) (byte) flip::srcIdx#3 ← phi( flip/(byte) 0 flip::@4/(byte) flip::srcIdx#1 ) (byte[256]) buffer1#6 ← phi( flip/(byte[256]) buffer1#10 flip::@4/(byte[256]) buffer1#11 ) to:flip::@2 @@ -2383,11 +2376,11 @@ plot::@return: from plot::@3 Multiple usages for variable. Not optimizing sub-constant (byte) prepare::i#2 Multiple usages for variable. Not optimizing sub-constant (byte[1000]) SCREEN#1 -Alias (byte*) RASTER#1 = (byte*) RASTER#3 (byte*) RASTER#10 -Alias (byte) main::c#2 = (byte) main::c#4 (byte) main::c#6 -Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#6 (byte[1000]) SCREEN#8 -Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#18 (byte[256]) buffer1#20 -Alias (byte[256]) buffer2#10 = (byte[256]) buffer2#12 (byte[256]) buffer2#14 +Alias (byte*) RASTER#1 = (byte*) RASTER#10 +Alias (byte) main::c#2 = (byte) main::c#4 +Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#6 +Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#18 +Alias (byte[256]) buffer2#10 = (byte[256]) buffer2#12 Alias (byte[256]) buffer1#11 = (byte[256]) buffer1#6 (byte[256]) buffer1#3 Alias (byte[256]) buffer2#1 = (byte[256]) buffer2#3 (byte[256]) buffer2#2 Alias (byte) flip::r#2 = (byte) flip::r#4 @@ -2403,19 +2396,17 @@ main: from @BEGIN call prepare param-assignment to:main::@1 main::@1: from main main::@11 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#10 main/(word) 4352 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#1 main/(word) 53266 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#13 main::@6/(byte[256]) buffer2#10 ) - (byte[256]) buffer1#10 ← phi( main::@1/(byte[256]) buffer1#21 main::@6/(byte[256]) buffer1#10 ) - (byte[1000]) SCREEN#1 ← phi( main::@1/(byte[1000]) SCREEN#9 main::@6/(byte[1000]) SCREEN#1 ) - (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) - (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#5 main::@6/(byte*) RASTER#1 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#10 main/(word) 4352 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#1 main/(word) 53266 ) to:main::@3 -main::@3: from main::@2 main::@3 +main::@3: from main::@1 main::@3 main::@6 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 main::@6/(byte[256]) buffer2#10 ) + (byte[256]) buffer1#10 ← phi( main::@1/(byte[256]) buffer1#19 main::@6/(byte[256]) buffer1#10 ) + (byte[1000]) SCREEN#1 ← phi( main::@1/(byte[1000]) SCREEN#7 main::@6/(byte[1000]) SCREEN#1 ) + (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 main::@6/(byte*) RASTER#1 ) (byte~) main::$1 ← * (byte*) RASTER#1 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 @@ -2425,7 +2416,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -2530,19 +2521,17 @@ main: from @BEGIN call prepare param-assignment to:main::@1 main::@1: from main main::@11 - (byte[256]) buffer2#13 ← phi( main::@11/(byte[256]) buffer2#10 main/(word) 4352 ) - (byte[256]) buffer1#21 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) - (byte[1000]) SCREEN#9 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) - (byte*) RASTER#5 ← phi( main::@11/(byte*) RASTER#1 main/(word) 53266 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#13 ) - (byte[256]) buffer1#10 ← phi( main::@1/(byte[256]) buffer1#21 ) - (byte[1000]) SCREEN#1 ← phi( main::@1/(byte[1000]) SCREEN#9 ) - (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) - (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#5 ) + (byte[256]) buffer2#11 ← phi( main::@11/(byte[256]) buffer2#10 main/(word) 4352 ) + (byte[256]) buffer1#19 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) + (byte[1000]) SCREEN#7 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) + (byte*) RASTER#3 ← phi( main::@11/(byte*) RASTER#1 main/(word) 53266 ) to:main::@3 -main::@3: from main::@2 main::@3 +main::@3: from main::@1 main::@3 main::@6 + (byte[256]) buffer2#10 ← phi( main::@1/(byte[256]) buffer2#11 ) + (byte[256]) buffer1#10 ← phi( main::@1/(byte[256]) buffer1#19 ) + (byte[1000]) SCREEN#1 ← phi( main::@1/(byte[1000]) SCREEN#7 ) + (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) + (byte*) RASTER#1 ← phi( main::@1/(byte*) RASTER#3 ) (byte~) main::$1 ← * (byte*) RASTER#1 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 @@ -2552,7 +2541,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -2643,10 +2632,10 @@ plot::@return: from plot::@3 Multiple usages for variable. Not optimizing sub-constant (byte) prepare::i#2 Multiple usages for variable. Not optimizing sub-constant (byte[1000]) SCREEN#1 -Alias (byte*) RASTER#1 = (byte*) RASTER#5 -Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#9 -Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#21 (byte[256]) buffer1#11 (byte[256]) buffer1#13 -Alias (byte[256]) buffer2#1 = (byte[256]) buffer2#10 (byte[256]) buffer2#13 +Alias (byte*) RASTER#1 = (byte*) RASTER#3 +Alias (byte[1000]) SCREEN#1 = (byte[1000]) SCREEN#7 +Alias (byte[256]) buffer1#10 = (byte[256]) buffer1#19 (byte[256]) buffer1#11 (byte[256]) buffer1#13 +Alias (byte[256]) buffer2#1 = (byte[256]) buffer2#10 (byte[256]) buffer2#11 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @BEGIN: from @@ -2660,11 +2649,9 @@ main::@1: from main main::@11 (byte[256]) buffer1#10 ← phi( main::@11/(byte[256]) buffer1#10 main/(word) 4096 ) (byte[1000]) SCREEN#1 ← phi( main::@11/(byte[1000]) SCREEN#1 main/(word) 1024 ) (byte*) RASTER#1 ← phi( main::@11/(byte*) RASTER#1 main/(word) 53266 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) to:main::@3 -main::@3: from main::@2 main::@3 +main::@3: from main::@1 main::@3 main::@6 + (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) (byte~) main::$1 ← * (byte*) RASTER#1 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 @@ -2674,7 +2661,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -2777,11 +2764,9 @@ main::@1: from main main::@11 (byte[256]) buffer1#10 ← phi( main/(word) 4096 ) (byte[1000]) SCREEN#1 ← phi( main/(word) 1024 ) (byte*) RASTER#1 ← phi( main/(word) 53266 ) - to:main::@2 -main::@2: from main::@1 main::@6 - (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) to:main::@3 -main::@3: from main::@2 main::@3 +main::@3: from main::@1 main::@3 main::@6 + (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) (byte~) main::$1 ← * (byte*) RASTER#1 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 @@ -2791,7 +2776,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -2890,11 +2875,9 @@ main: from @BEGIN call prepare param-assignment to:main::@1 main::@1: from main main::@11 - to:main::@2 -main::@2: from main::@1 main::@6 - (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) to:main::@3 -main::@3: from main::@2 main::@3 +main::@3: from main::@1 main::@3 main::@6 + (byte) main::c#2 ← phi( main::@1/(byte) 25 main::@6/(byte) main::c#1 ) (byte~) main::$1 ← * (word) 53266 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 @@ -2904,7 +2887,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -3003,11 +2986,9 @@ CONTROL FLOW GRAPH to:@END main: from @BEGIN call prepare param-assignment - to:main::@2 -main::@2: from main main::@11 main::@6 - (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) to:main::@3 -main::@3: from main::@2 main::@3 +main::@3: from main main::@11 main::@3 main::@6 + (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) (byte~) main::$1 ← * (word) 53266 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 @@ -3017,7 +2998,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -3026,7 +3007,7 @@ main::@10: from main::@7 call plot param-assignment to:main::@11 main::@11: from main::@10 - if(true) goto main::@2 + if(true) goto main::@3 to:main::@return main::@return: from main::@11 return @@ -3111,11 +3092,9 @@ CONTROL FLOW GRAPH to:@END main: from @BEGIN call prepare param-assignment - to:main::@2 -main::@2: from main main::@11 main::@6 - (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) to:main::@3 -main::@3: from main::@2 main::@3 +main::@3: from main main::@11 main::@3 main::@6 + (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) (byte~) main::$1 ← * (word) 53266 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 @@ -3125,7 +3104,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -3134,7 +3113,7 @@ main::@10: from main::@7 call plot param-assignment to:main::@11 main::@11: from main::@10 - if(true) goto main::@2 + if(true) goto main::@3 to:main::@return main::@return: from main::@11 return @@ -3223,11 +3202,9 @@ CONTROL FLOW GRAPH to:@END main: from @BEGIN call prepare param-assignment - to:main::@2 -main::@2: from main main::@11 main::@6 - (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) to:main::@3 -main::@3: from main::@2 main::@3 +main::@3: from main main::@11 main::@3 main::@6 + (byte) main::c#2 ← phi( main/(byte) 25 main::@6/(byte) main::c#1 main::@11/(byte) 25 ) (byte~) main::$1 ← * (word) 53266 if((byte~) main::$1!=(byte) 254) goto main::@3 to:main::@4 @@ -3237,7 +3214,7 @@ main::@4: from main::@3 main::@4 to:main::@6 main::@6: from main::@4 (byte) main::c#1 ← -- (byte) main::c#2 - if((byte) main::c#1!=(byte) 0) goto main::@2 + if((byte) main::c#1!=(byte) 0) goto main::@3 to:main::@7 main::@7: from main::@6 call flip param-assignment @@ -3246,7 +3223,7 @@ main::@10: from main::@7 call plot param-assignment to:main::@11 main::@11: from main::@10 - if(true) goto main::@2 + if(true) goto main::@3 to:main::@return main::@return: from main::@11 return @@ -3338,25 +3315,25 @@ BBEGIN: BEND: main: jsr prepare -main__B2_from_main: +main__B3_from_main: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 - jmp main__B2 -main__B2_from_B11: + jmp main__B3 +main__B3_from_B11: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 - jmp main__B2 -main__B2_from_B6: + jmp main__B3 +main__B3_from_B3: + jmp main__B3 +main__B3_from_B6: // (byte) main::c#2 = (byte) main::c#1 // register copy - jmp main__B2 -main__B2: jmp main__B3 main__B3: // (byte~) main::$1 ← * (word) 53266 // aby=_star_cowo1 lda 53266 // if((byte~) main::$1!=(byte) 254) goto main::@3 // aby_neq_coby1_then_la1 cmp #254 - bne main__main__B3 + bne main__B3_from_B3 jmp main__B4 main__B4: // (byte~) main::$3 ← * (word) 53266 // aby=_star_cowo1 @@ -3368,9 +3345,9 @@ main__B4: main__B6: // (byte) main::c#1 ← -- (byte) main::c#2 // xby=_dec_xby dex - // if((byte) main::c#1!=(byte) 0) goto main::@2 // xby_neq_0_then_la1 + // if((byte) main::c#1!=(byte) 0) goto main::@3 // xby_neq_0_then_la1 cpx #0 - bne main__B2_from_B6 + bne main__B3_from_B6 jmp main__B7 main__B7: jsr flip @@ -3379,8 +3356,8 @@ main__B10: jsr plot jmp main__B11 main__B11: - // if(true) goto main::@2 // true_then_la1 - jmp main__B2_from_B11 + // if(true) goto main::@3 // true_then_la1 + jmp main__B3_from_B11 jmp main__Breturn main__Breturn: rts @@ -3538,7 +3515,6 @@ prepare__Breturn: rts Removing instruction jmp BEND -Removing instruction jmp main__B2 Removing instruction jmp main__B3 Removing instruction jmp main__B4 Removing instruction jmp main__B6 @@ -3564,23 +3540,24 @@ BBEGIN: BEND: main: jsr prepare -main__B2_from_main: +main__B3_from_main: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 - jmp main__B2 -main__B2_from_B11: + jmp main__B3 +main__B3_from_B11: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 - jmp main__B2 -main__B2_from_B6: + jmp main__B3 +main__B3_from_B3: + jmp main__B3 +main__B3_from_B6: // (byte) main::c#2 = (byte) main::c#1 // register copy -main__B2: main__B3: // (byte~) main::$1 ← * (word) 53266 // aby=_star_cowo1 lda 53266 // if((byte~) main::$1!=(byte) 254) goto main::@3 // aby_neq_coby1_then_la1 cmp #254 - bne main__main__B3 + bne main__B3_from_B3 main__B4: // (byte~) main::$3 ← * (word) 53266 // aby=_star_cowo1 lda 53266 @@ -3590,16 +3567,16 @@ main__B4: main__B6: // (byte) main::c#1 ← -- (byte) main::c#2 // xby=_dec_xby dex - // if((byte) main::c#1!=(byte) 0) goto main::@2 // xby_neq_0_then_la1 + // if((byte) main::c#1!=(byte) 0) goto main::@3 // xby_neq_0_then_la1 cpx #0 - bne main__B2_from_B6 + bne main__B3_from_B6 main__B7: jsr flip main__B10: jsr plot main__B11: - // if(true) goto main::@2 // true_then_la1 - jmp main__B2_from_B11 + // if(true) goto main::@3 // true_then_la1 + jmp main__B3_from_B11 main__Breturn: rts plot: @@ -3744,7 +3721,7 @@ prepare__B1: prepare__Breturn: rts -Removing instruction jmp main__B2 +Removing instruction jmp main__B3 Removing instruction jmp plot__B1 Removing instruction jmp plot__B2 Removing instruction jmp flip__B1 @@ -3758,22 +3735,23 @@ BBEGIN: BEND: main: jsr prepare -main__B2_from_main: +main__B3_from_main: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 - jmp main__B2 -main__B2_from_B11: + jmp main__B3 +main__B3_from_B11: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 -main__B2_from_B6: + jmp main__B3 +main__B3_from_B3: +main__B3_from_B6: // (byte) main::c#2 = (byte) main::c#1 // register copy -main__B2: main__B3: // (byte~) main::$1 ← * (word) 53266 // aby=_star_cowo1 lda 53266 // if((byte~) main::$1!=(byte) 254) goto main::@3 // aby_neq_coby1_then_la1 cmp #254 - bne main__main__B3 + bne main__B3_from_B3 main__B4: // (byte~) main::$3 ← * (word) 53266 // aby=_star_cowo1 lda 53266 @@ -3783,16 +3761,197 @@ main__B4: main__B6: // (byte) main::c#1 ← -- (byte) main::c#2 // xby=_dec_xby dex - // if((byte) main::c#1!=(byte) 0) goto main::@2 // xby_neq_0_then_la1 + // if((byte) main::c#1!=(byte) 0) goto main::@3 // xby_neq_0_then_la1 cpx #0 - bne main__B2_from_B6 + bne main__B3_from_B6 main__B7: jsr flip main__B10: jsr plot main__B11: - // if(true) goto main::@2 // true_then_la1 - jmp main__B2_from_B11 + // if(true) goto main::@3 // true_then_la1 + jmp main__B3_from_B11 +main__Breturn: + rts +plot: +plot__B1_from_plot: + // (byte) plot::y#2 = (byte) 16 // zpby1=coby1 + lda #16 + sta 100 + // (byte*) plot::line#2 = (word) 1236 // zpptrby1=cowo1 + lda #<1236 + sta 101 + lda #>1236 + sta 101+1 + // (byte) plot::i#3 = (byte) 0 // xby=coby1 + ldx #0 +plot__B1_from_B3: + // (byte) plot::y#2 = (byte) plot::y#1 // register copy + // (byte*) plot::line#2 = (byte*) plot::line#1 // register copy + // (byte) plot::i#3 = (byte) plot::i#1 // register copy +plot__B1: +plot__B2_from_B1: + // (byte) plot::x#2 = (byte) 0 // yby=coby1 + ldy #0 + // (byte) plot::i#2 = (byte) plot::i#3 // register copy +plot__B2_from_B2: + // (byte) plot::x#2 = (byte) plot::x#1 // register copy + // (byte) plot::i#2 = (byte) plot::i#1 // register copy +plot__B2: + // (byte~) plot::$3 ← (word) 4096 *idx (byte) plot::i#2 // aby=cowo1_staridx_xby + lda 4096,x + // *((byte*) plot::line#2 + (byte) plot::x#2) ← (byte~) plot::$3 // ptr_zpptrby1_yby=aby + sta (101),y + // (byte) plot::i#1 ← ++ (byte) plot::i#2 // xby=_inc_xby + inx + // (byte) plot::x#1 ← ++ (byte) plot::x#2 // yby=_inc_yby + iny + // if((byte) plot::x#1<(byte) 16) goto plot::@2 // yby_lt_coby1_then_la1 + cpy #16 + bcc plot__B2_from_B2 +plot__B3: + // (byte*) plot::line#1 ← (byte*) plot::line#2 + (byte) 40 // zpptrby1=zpptrby1_plus_coby1 + lda 101 + clc + adc #40 + sta 101 + bcc !+ + inc 101+1 +!: + // (byte) plot::y#1 ← -- (byte) plot::y#2 // zpby1=_dec_zpby1 + dec 100 + // if((byte) plot::y#1!=(byte) 0) goto plot::@1 // zpby1_neq_0_then_la1 + lda 100 + bne plot__B1_from_B3 +plot__Breturn: + rts +flip: +flip__B1_from_flip: + // (byte) flip::r#2 = (byte) 16 // zpby1=coby1 + lda #16 + sta 104 + // (byte) flip::dstIdx#5 = (byte) 15 // yby=coby1 + ldy #15 + // (byte) flip::srcIdx#3 = (byte) 0 // xby=coby1 + ldx #0 +flip__B1_from_B4: + // (byte) flip::r#2 = (byte) flip::r#1 // register copy + // (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 // register copy + // (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 // register copy +flip__B1: +flip__B2_from_B1: + // (byte) flip::c#2 = (byte) 16 // zpby1=coby1 + lda #16 + sta 103 + // (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 // register copy + // (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 // register copy +flip__B2_from_B2: + // (byte) flip::c#2 = (byte) flip::c#1 // register copy + // (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 // register copy + // (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 // register copy +flip__B2: + // (byte~) flip::$0 ← (word) 4096 *idx (byte) flip::srcIdx#2 // aby=cowo1_staridx_xby + lda 4096,x + // *((word) 4352 + (byte) flip::dstIdx#3) ← (byte~) flip::$0 // ptr_cowo1_yby=aby + sta 4352,y + // (byte) flip::srcIdx#1 ← ++ (byte) flip::srcIdx#2 // xby=_inc_xby + inx + // (byte) flip::dstIdx#1 ← (byte) flip::dstIdx#3 + (byte) 16 // yby=yby_plus_coby1 + tya + clc + adc #16 + tay + // (byte) flip::c#1 ← -- (byte) flip::c#2 // zpby1=_dec_zpby1 + dec 103 + // if((byte) flip::c#1!=(byte) 0) goto flip::@2 // zpby1_neq_0_then_la1 + lda 103 + bne flip__B2_from_B2 +flip__B4: + // (byte) flip::dstIdx#2 ← -- (byte) flip::dstIdx#1 // yby=_dec_yby + dey + // (byte) flip::r#1 ← -- (byte) flip::r#2 // zpby1=_dec_zpby1 + dec 104 + // if((byte) flip::r#1!=(byte) 0) goto flip::@1 // zpby1_neq_0_then_la1 + lda 104 + bne flip__B1_from_B4 +flip__B3_from_B4: + // (byte) flip::i#2 = (byte) 0 // xby=coby1 + ldx #0 +flip__B3_from_B3: + // (byte) flip::i#2 = (byte) flip::i#1 // register copy +flip__B3: + // (byte~) flip::$4 ← (word) 4352 *idx (byte) flip::i#2 // aby=cowo1_staridx_xby + lda 4352,x + // *((word) 4096 + (byte) flip::i#2) ← (byte~) flip::$4 // ptr_cowo1_xby=aby + sta 4096,x + // (byte) flip::i#1 ← ++ (byte) flip::i#2 // xby=_inc_xby + inx + // if((byte) flip::i#1!=(byte) 0) goto flip::@3 // xby_neq_0_then_la1 + cpx #0 + bne flip__B3_from_B3 +flip__Breturn: + rts +prepare: +prepare__B1_from_prepare: + // (byte) prepare::i#2 = (byte) 0 // xby=coby1 + ldx #0 +prepare__B1_from_B1: + // (byte) prepare::i#2 = (byte) prepare::i#1 // register copy +prepare__B1: + // *((word) 4096 + (byte) prepare::i#2) ← (byte) prepare::i#2 // ptr_cowo1_xby=xby + txa + sta 4096,x + // (byte) prepare::i#1 ← ++ (byte) prepare::i#2 // xby=_inc_xby + inx + // if((byte) prepare::i#1!=(byte) 0) goto prepare::@1 // xby_neq_0_then_la1 + cpx #0 + bne prepare__B1_from_B1 +prepare__Breturn: + rts + +Removing instruction jmp main__B3 +Succesful ASM optimization Pass4NextJumpElimination +ASSEMBLER +BBEGIN: + jsr main +BEND: +main: + jsr prepare +main__B3_from_main: + // (byte) main::c#2 = (byte) 25 // xby=coby1 + ldx #25 + jmp main__B3 +main__B3_from_B11: + // (byte) main::c#2 = (byte) 25 // xby=coby1 + ldx #25 +main__B3_from_B3: +main__B3_from_B6: + // (byte) main::c#2 = (byte) main::c#1 // register copy +main__B3: + // (byte~) main::$1 ← * (word) 53266 // aby=_star_cowo1 + lda 53266 + // if((byte~) main::$1!=(byte) 254) goto main::@3 // aby_neq_coby1_then_la1 + cmp #254 + bne main__B3_from_B3 +main__B4: + // (byte~) main::$3 ← * (word) 53266 // aby=_star_cowo1 + lda 53266 + // if((byte~) main::$3!=(byte) 255) goto main::@4 // aby_neq_coby1_then_la1 + cmp #255 + bne main__main__B4 +main__B6: + // (byte) main::c#1 ← -- (byte) main::c#2 // xby=_dec_xby + dex + // if((byte) main::c#1!=(byte) 0) goto main::@3 // xby_neq_0_then_la1 + cpx #0 + bne main__B3_from_B6 +main__B7: + jsr flip +main__B10: + jsr plot +main__B11: + // if(true) goto main::@3 // true_then_la1 + jmp main__B3_from_B11 main__Breturn: rts plot: @@ -3970,7 +4129,6 @@ FINAL SYMBOL TABLE (byte~) main::$3 reg byte a (label) main::@10 (label) main::@11 -(label) main::@2 (label) main::@3 (label) main::@4 (label) main::@6 @@ -4014,22 +4172,22 @@ BBEGIN: BEND: main: jsr prepare -main__B2_from_main: +main__B3_from_main: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 - jmp main__B2 -main__B2_from_B11: + jmp main__B3 +main__B3_from_B11: // (byte) main::c#2 = (byte) 25 // xby=coby1 ldx #25 -main__B2_from_B6: +main__B3_from_B3: +main__B3_from_B6: // (byte) main::c#2 = (byte) main::c#1 // register copy -main__B2: main__B3: // (byte~) main::$1 ← * (word) 53266 // aby=_star_cowo1 lda 53266 // if((byte~) main::$1!=(byte) 254) goto main::@3 // aby_neq_coby1_then_la1 cmp #254 - bne main__main__B3 + bne main__B3_from_B3 main__B4: // (byte~) main::$3 ← * (word) 53266 // aby=_star_cowo1 lda 53266 @@ -4039,16 +4197,16 @@ main__B4: main__B6: // (byte) main::c#1 ← -- (byte) main::c#2 // xby=_dec_xby dex - // if((byte) main::c#1!=(byte) 0) goto main::@2 // xby_neq_0_then_la1 + // if((byte) main::c#1!=(byte) 0) goto main::@3 // xby_neq_0_then_la1 cpx #0 - bne main__B2_from_B6 + bne main__B3_from_B6 main__B7: jsr flip main__B10: jsr plot main__B11: - // if(true) goto main::@2 // true_then_la1 - jmp main__B2_from_B11 + // if(true) goto main::@3 // true_then_la1 + jmp main__B3_from_B11 main__Breturn: rts plot: diff --git a/src/dk/camelot64/kickc/test/ref/flipper-rex2.sym b/src/dk/camelot64/kickc/test/ref/flipper-rex2.sym index c5dd35d21..efb0cafd8 100644 --- a/src/dk/camelot64/kickc/test/ref/flipper-rex2.sym +++ b/src/dk/camelot64/kickc/test/ref/flipper-rex2.sym @@ -36,7 +36,6 @@ (byte~) main::$3 reg byte a (label) main::@10 (label) main::@11 -(label) main::@2 (label) main::@3 (label) main::@4 (label) main::@6 diff --git a/src/dk/camelot64/kickc/test/ref/loopmin.cfg b/src/dk/camelot64/kickc/test/ref/loopmin.cfg index 3bcf10378..9bafd3893 100644 --- a/src/dk/camelot64/kickc/test/ref/loopmin.cfg +++ b/src/dk/camelot64/kickc/test/ref/loopmin.cfg @@ -1,7 +1,7 @@ @BEGIN: from to:@1 @1: from @3 @BEGIN - (byte) s#2 ← phi( @3/(byte) s#5 @BEGIN/(byte) 0 ) + (byte) s#2 ← phi( @3/(byte) s#4 @BEGIN/(byte) 0 ) (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) 10 ) if((byte) i#2>(byte) 5) goto @2 to:@3 @@ -9,7 +9,7 @@ (byte) s#1 ← (byte) s#2 + (byte) i#2 to:@3 @3: from @1 @2 - (byte) s#5 ← phi( @1/(byte) s#2 @2/(byte) s#1 ) + (byte) s#4 ← phi( @1/(byte) s#2 @2/(byte) s#1 ) (byte) i#1 ← -- (byte) i#2 if((byte) i#1>(byte) 0) goto @1 to:@END diff --git a/src/dk/camelot64/kickc/test/ref/loopmin.log b/src/dk/camelot64/kickc/test/ref/loopmin.log index 1adee14d4..e8d8d7a17 100644 --- a/src/dk/camelot64/kickc/test/ref/loopmin.log +++ b/src/dk/camelot64/kickc/test/ref/loopmin.log @@ -58,6 +58,28 @@ INITIAL CONTROL FLOW GRAPH to:@END @END: from @6 +Removing empty block @4 +Removing empty block @5 +Removing empty block @6 +@BEGIN: from + (byte) i ← (byte) 10 + (byte) s ← (byte) 0 + to:@1 +@1: from @3 @BEGIN + (boolean~) $0 ← (byte) i > (byte) 5 + if((boolean~) $0) goto @2 + to:@3 +@2: from @1 + (byte~) $1 ← (byte) s + (byte) i + (byte) s ← (byte~) $1 + to:@3 +@3: from @1 @2 + (byte) i ← -- (byte) i + (boolean~) $2 ← (byte) i > (byte) 0 + if((boolean~) $2) goto @1 + to:@END +@END: from @3 + CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @BEGIN: from (byte) i ← (byte) 10 @@ -66,63 +88,46 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @1: from @3 @BEGIN (boolean~) $0 ← (byte) i > (byte) 5 if((boolean~) $0) goto @2 - to:@4 -@2: from @1 @5 + to:@3 +@2: from @1 (byte~) $1 ← (byte) s + (byte) i (byte) s ← (byte~) $1 to:@3 -@4: from @1 - to:@3 -@3: from @2 @4 +@3: from @1 @2 (byte) i ← -- (byte) i (boolean~) $2 ← (byte) i > (byte) 0 if((boolean~) $2) goto @1 - to:@6 -@5: from - to:@2 -@6: from @3 to:@END -@END: from @6 +@END: from @3 Completing Phi functions... Completing Phi functions... Completing Phi functions... -Completing Phi functions... CONTROL FLOW GRAPH SSA @BEGIN: from (byte) i#0 ← (byte) 10 (byte) s#0 ← (byte) 0 to:@1 @1: from @3 @BEGIN - (byte) s#3 ← phi( @3/(byte) s#5 @BEGIN/(byte) s#0 ) + (byte) s#3 ← phi( @3/(byte) s#4 @BEGIN/(byte) s#0 ) (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) i#0 ) (boolean~) $0 ← (byte) i#2 > (byte) 5 if((boolean~) $0) goto @2 - to:@4 -@2: from @1 @5 - (byte) i#3 ← phi( @1/(byte) i#2 @5/(byte) i#5 ) - (byte) s#2 ← phi( @1/(byte) s#3 @5/(byte) s#4 ) + to:@3 +@2: from @1 + (byte) i#3 ← phi( @1/(byte) i#2 ) + (byte) s#2 ← phi( @1/(byte) s#3 ) (byte~) $1 ← (byte) s#2 + (byte) i#3 (byte) s#1 ← (byte~) $1 to:@3 -@4: from @1 - (byte) s#6 ← phi( @1/(byte) s#3 ) - (byte) i#6 ← phi( @1/(byte) i#2 ) - to:@3 -@3: from @2 @4 - (byte) s#5 ← phi( @2/(byte) s#1 @4/(byte) s#6 ) - (byte) i#4 ← phi( @2/(byte) i#3 @4/(byte) i#6 ) +@3: from @1 @2 + (byte) s#4 ← phi( @1/(byte) s#3 @2/(byte) s#1 ) + (byte) i#4 ← phi( @1/(byte) i#2 @2/(byte) i#3 ) (byte) i#1 ← -- (byte) i#4 (boolean~) $2 ← (byte) i#1 > (byte) 0 if((boolean~) $2) goto @1 - to:@6 -@5: from - (byte) i#5 ← phi( ) - (byte) s#4 ← phi( ) - to:@2 -@6: from @3 to:@END -@END: from @6 +@END: from @3 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN @BEGIN: from @@ -130,70 +135,24 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN (byte) s#0 ← (byte) 0 to:@1 @1: from @3 @BEGIN - (byte) s#3 ← phi( @3/(byte) s#5 @BEGIN/(byte) s#0 ) + (byte) s#3 ← phi( @3/(byte) s#4 @BEGIN/(byte) s#0 ) (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) i#0 ) (boolean~) $0 ← (byte) i#2 > (byte) 5 if((boolean~) $0) goto @2 - to:@4 -@2: from @1 @5 - (byte) i#3 ← phi( @1/(byte) i#2 @5/(byte) i#5 ) - (byte) s#2 ← phi( @1/(byte) s#3 @5/(byte) s#4 ) + to:@3 +@2: from @1 + (byte) i#3 ← phi( @1/(byte) i#2 ) + (byte) s#2 ← phi( @1/(byte) s#3 ) (byte~) $1 ← (byte) s#2 + (byte) i#3 (byte) s#1 ← (byte~) $1 to:@3 -@4: from @1 - (byte) s#6 ← phi( @1/(byte) s#3 ) - (byte) i#6 ← phi( @1/(byte) i#2 ) - to:@3 -@3: from @2 @4 - (byte) s#5 ← phi( @2/(byte) s#1 @4/(byte) s#6 ) - (byte) i#4 ← phi( @2/(byte) i#3 @4/(byte) i#6 ) - (byte) i#1 ← -- (byte) i#4 - (boolean~) $2 ← (byte) i#1 > (byte) 0 - if((boolean~) $2) goto @1 - to:@6 -@5: from - (byte) i#5 ← phi( ) - (byte) s#4 ← phi( ) - to:@2 -@6: from @3 - to:@END -@END: from @6 - -Culled Empty Block (label) @6 -Succesful SSA optimization Pass2CullEmptyBlocks -CONTROL FLOW GRAPH -@BEGIN: from - (byte) i#0 ← (byte) 10 - (byte) s#0 ← (byte) 0 - to:@1 -@1: from @3 @BEGIN - (byte) s#3 ← phi( @3/(byte) s#5 @BEGIN/(byte) s#0 ) - (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) i#0 ) - (boolean~) $0 ← (byte) i#2 > (byte) 5 - if((boolean~) $0) goto @2 - to:@4 -@2: from @1 @5 - (byte) i#3 ← phi( @1/(byte) i#2 @5/(byte) i#5 ) - (byte) s#2 ← phi( @1/(byte) s#3 @5/(byte) s#4 ) - (byte~) $1 ← (byte) s#2 + (byte) i#3 - (byte) s#1 ← (byte~) $1 - to:@3 -@4: from @1 - (byte) s#6 ← phi( @1/(byte) s#3 ) - (byte) i#6 ← phi( @1/(byte) i#2 ) - to:@3 -@3: from @2 @4 - (byte) s#5 ← phi( @2/(byte) s#1 @4/(byte) s#6 ) - (byte) i#4 ← phi( @2/(byte) i#3 @4/(byte) i#6 ) +@3: from @1 @2 + (byte) s#4 ← phi( @1/(byte) s#3 @2/(byte) s#1 ) + (byte) i#4 ← phi( @1/(byte) i#2 @2/(byte) i#3 ) (byte) i#1 ← -- (byte) i#4 (boolean~) $2 ← (byte) i#1 > (byte) 0 if((boolean~) $2) goto @1 to:@END -@5: from - (byte) i#5 ← phi( ) - (byte) s#4 ← phi( ) - to:@2 @END: from @3 Constant (byte) i#0 (byte) 10 @@ -203,168 +162,48 @@ CONTROL FLOW GRAPH @BEGIN: from to:@1 @1: from @3 @BEGIN - (byte) s#3 ← phi( @3/(byte) s#5 @BEGIN/(byte) 0 ) + (byte) s#3 ← phi( @3/(byte) s#4 @BEGIN/(byte) 0 ) (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) 10 ) (boolean~) $0 ← (byte) i#2 > (byte) 5 if((boolean~) $0) goto @2 - to:@4 -@2: from @1 @5 - (byte) i#3 ← phi( @1/(byte) i#2 @5/(byte) i#5 ) - (byte) s#2 ← phi( @1/(byte) s#3 @5/(byte) s#4 ) - (byte~) $1 ← (byte) s#2 + (byte) i#3 - (byte) s#1 ← (byte~) $1 - to:@3 -@4: from @1 - (byte) s#6 ← phi( @1/(byte) s#3 ) - (byte) i#6 ← phi( @1/(byte) i#2 ) - to:@3 -@3: from @2 @4 - (byte) s#5 ← phi( @2/(byte) s#1 @4/(byte) s#6 ) - (byte) i#4 ← phi( @2/(byte) i#3 @4/(byte) i#6 ) - (byte) i#1 ← -- (byte) i#4 - (boolean~) $2 ← (byte) i#1 > (byte) 0 - if((boolean~) $2) goto @1 - to:@END -@5: from - (byte) i#5 ← phi( ) - (byte) s#4 ← phi( ) - to:@2 -@END: from @3 - -Alias (byte) s#1 = (byte~) $1 -Alias (byte) i#2 = (byte) i#6 -Alias (byte) s#3 = (byte) s#6 -Succesful SSA optimization Pass2AliasElimination -CONTROL FLOW GRAPH -@BEGIN: from - to:@1 -@1: from @3 @BEGIN - (byte) s#3 ← phi( @3/(byte) s#5 @BEGIN/(byte) 0 ) - (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) 10 ) - (boolean~) $0 ← (byte) i#2 > (byte) 5 - if((boolean~) $0) goto @2 - to:@4 -@2: from @1 @5 - (byte) i#3 ← phi( @1/(byte) i#2 @5/(byte) i#5 ) - (byte) s#2 ← phi( @1/(byte) s#3 @5/(byte) s#4 ) - (byte) s#1 ← (byte) s#2 + (byte) i#3 - to:@3 -@4: from @1 - to:@3 -@3: from @2 @4 - (byte) s#5 ← phi( @2/(byte) s#1 @4/(byte) s#3 ) - (byte) i#4 ← phi( @2/(byte) i#3 @4/(byte) i#2 ) - (byte) i#1 ← -- (byte) i#4 - (boolean~) $2 ← (byte) i#1 > (byte) 0 - if((boolean~) $2) goto @1 - to:@END -@5: from - (byte) i#5 ← phi( ) - (byte) s#4 ← phi( ) - to:@2 -@END: from @3 - -Redundant Phi (byte) s#4 VOID -Redundant Phi (byte) i#5 VOID -Succesful SSA optimization Pass2RedundantPhiElimination -CONTROL FLOW GRAPH -@BEGIN: from - to:@1 -@1: from @3 @BEGIN - (byte) s#3 ← phi( @3/(byte) s#5 @BEGIN/(byte) 0 ) - (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) 10 ) - (boolean~) $0 ← (byte) i#2 > (byte) 5 - if((boolean~) $0) goto @2 - to:@4 -@2: from @1 @5 - (byte) i#3 ← phi( @1/(byte) i#2 ) - (byte) s#2 ← phi( @1/(byte) s#3 ) - (byte) s#1 ← (byte) s#2 + (byte) i#3 - to:@3 -@4: from @1 - to:@3 -@3: from @2 @4 - (byte) s#5 ← phi( @2/(byte) s#1 @4/(byte) s#3 ) - (byte) i#4 ← phi( @2/(byte) i#3 @4/(byte) i#2 ) - (byte) i#1 ← -- (byte) i#4 - (boolean~) $2 ← (byte) i#1 > (byte) 0 - if((boolean~) $2) goto @1 - to:@END -@5: from - to:@2 -@END: from @3 - -Simple Condition (boolean~) $0 if((byte) i#2>(byte) 5) goto @2 -Simple Condition (boolean~) $2 if((byte) i#1>(byte) 0) goto @1 -Succesful SSA optimization Pass2ConditionalJumpSimplification -CONTROL FLOW GRAPH -@BEGIN: from - to:@1 -@1: from @3 @BEGIN - (byte) s#3 ← phi( @3/(byte) s#5 @BEGIN/(byte) 0 ) - (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) 10 ) - if((byte) i#2>(byte) 5) goto @2 - to:@4 -@2: from @1 @5 - (byte) i#3 ← phi( @1/(byte) i#2 ) - (byte) s#2 ← phi( @1/(byte) s#3 ) - (byte) s#1 ← (byte) s#2 + (byte) i#3 - to:@3 -@4: from @1 - to:@3 -@3: from @2 @4 - (byte) s#5 ← phi( @2/(byte) s#1 @4/(byte) s#3 ) - (byte) i#4 ← phi( @2/(byte) i#3 @4/(byte) i#2 ) - (byte) i#1 ← -- (byte) i#4 - if((byte) i#1>(byte) 0) goto @1 - to:@END -@5: from - to:@2 -@END: from @3 - -Culled Empty Block (label) @4 -Culled Empty Block (label) @5 -Succesful SSA optimization Pass2CullEmptyBlocks -CONTROL FLOW GRAPH -@BEGIN: from - to:@1 -@1: from @3 @BEGIN - (byte) s#3 ← phi( @3/(byte) s#5 @BEGIN/(byte) 0 ) - (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) 10 ) - if((byte) i#2>(byte) 5) goto @2 to:@3 @2: from @1 (byte) i#3 ← phi( @1/(byte) i#2 ) (byte) s#2 ← phi( @1/(byte) s#3 ) - (byte) s#1 ← (byte) s#2 + (byte) i#3 + (byte~) $1 ← (byte) s#2 + (byte) i#3 + (byte) s#1 ← (byte~) $1 to:@3 @3: from @1 @2 - (byte) s#5 ← phi( @2/(byte) s#1 @1/(byte) s#3 ) - (byte) i#4 ← phi( @2/(byte) i#3 @1/(byte) i#2 ) + (byte) s#4 ← phi( @1/(byte) s#3 @2/(byte) s#1 ) + (byte) i#4 ← phi( @1/(byte) i#2 @2/(byte) i#3 ) (byte) i#1 ← -- (byte) i#4 - if((byte) i#1>(byte) 0) goto @1 + (boolean~) $2 ← (byte) i#1 > (byte) 0 + if((boolean~) $2) goto @1 to:@END @END: from @3 Alias (byte) s#2 = (byte) s#3 Alias (byte) i#2 = (byte) i#3 +Alias (byte) s#1 = (byte~) $1 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @BEGIN: from to:@1 @1: from @3 @BEGIN - (byte) s#2 ← phi( @3/(byte) s#5 @BEGIN/(byte) 0 ) + (byte) s#2 ← phi( @3/(byte) s#4 @BEGIN/(byte) 0 ) (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) 10 ) - if((byte) i#2>(byte) 5) goto @2 + (boolean~) $0 ← (byte) i#2 > (byte) 5 + if((boolean~) $0) goto @2 to:@3 @2: from @1 (byte) s#1 ← (byte) s#2 + (byte) i#2 to:@3 @3: from @1 @2 - (byte) s#5 ← phi( @2/(byte) s#1 @1/(byte) s#2 ) - (byte) i#4 ← phi( @2/(byte) i#2 @1/(byte) i#2 ) + (byte) s#4 ← phi( @1/(byte) s#2 @2/(byte) s#1 ) + (byte) i#4 ← phi( @1/(byte) i#2 @2/(byte) i#2 ) (byte) i#1 ← -- (byte) i#4 - if((byte) i#1>(byte) 0) goto @1 + (boolean~) $2 ← (byte) i#1 > (byte) 0 + if((boolean~) $2) goto @1 to:@END @END: from @3 @@ -374,7 +213,30 @@ CONTROL FLOW GRAPH @BEGIN: from to:@1 @1: from @3 @BEGIN - (byte) s#2 ← phi( @3/(byte) s#5 @BEGIN/(byte) 0 ) + (byte) s#2 ← phi( @3/(byte) s#4 @BEGIN/(byte) 0 ) + (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) 10 ) + (boolean~) $0 ← (byte) i#2 > (byte) 5 + if((boolean~) $0) goto @2 + to:@3 +@2: from @1 + (byte) s#1 ← (byte) s#2 + (byte) i#2 + to:@3 +@3: from @1 @2 + (byte) s#4 ← phi( @1/(byte) s#2 @2/(byte) s#1 ) + (byte) i#1 ← -- (byte) i#2 + (boolean~) $2 ← (byte) i#1 > (byte) 0 + if((boolean~) $2) goto @1 + to:@END +@END: from @3 + +Simple Condition (boolean~) $0 if((byte) i#2>(byte) 5) goto @2 +Simple Condition (boolean~) $2 if((byte) i#1>(byte) 0) goto @1 +Succesful SSA optimization Pass2ConditionalJumpSimplification +CONTROL FLOW GRAPH +@BEGIN: from + to:@1 +@1: from @3 @BEGIN + (byte) s#2 ← phi( @3/(byte) s#4 @BEGIN/(byte) 0 ) (byte) i#2 ← phi( @3/(byte) i#1 @BEGIN/(byte) 10 ) if((byte) i#2>(byte) 5) goto @2 to:@3 @@ -382,7 +244,7 @@ CONTROL FLOW GRAPH (byte) s#1 ← (byte) s#2 + (byte) i#2 to:@3 @3: from @1 @2 - (byte) s#5 ← phi( @2/(byte) s#1 @1/(byte) s#2 ) + (byte) s#4 ← phi( @1/(byte) s#2 @2/(byte) s#1 ) (byte) i#1 ← -- (byte) i#2 if((byte) i#1>(byte) 0) goto @1 to:@END @@ -399,7 +261,7 @@ B1_from_BBEGIN: sta 4 jmp B1 B1_from_B3: - // (byte) s#2 = (byte) s#5 // zpby1=zpby2 + // (byte) s#2 = (byte) s#4 // zpby1=zpby2 lda 6 sta 5 // (byte) i#2 = (byte) i#1 // zpby1=zpby2 @@ -414,7 +276,7 @@ B1: bcs B2 !: B3_from_B1: - // (byte) s#5 = (byte) s#2 // zpby1=zpby2 + // (byte) s#4 = (byte) s#2 // zpby1=zpby2 lda 5 sta 6 jmp B3 @@ -435,7 +297,7 @@ B2: adc 4 sta 2 B3_from_B2: - // (byte) s#5 = (byte) s#1 // zpby1=zpby2 + // (byte) s#4 = (byte) s#1 // zpby1=zpby2 lda 2 sta 6 jmp B3 @@ -455,7 +317,7 @@ B1_from_BBEGIN: sta 4 jmp B1 B1_from_B3: - // (byte) s#2 = (byte) s#5 // zpby1=zpby2 + // (byte) s#2 = (byte) s#4 // zpby1=zpby2 lda 6 sta 5 // (byte) i#2 = (byte) i#1 // zpby1=zpby2 @@ -469,7 +331,7 @@ B1: bcs B2 !: B3_from_B1: - // (byte) s#5 = (byte) s#2 // zpby1=zpby2 + // (byte) s#4 = (byte) s#2 // zpby1=zpby2 lda 5 sta 6 B3: @@ -488,7 +350,7 @@ B2: adc 4 sta 2 B3_from_B2: - // (byte) s#5 = (byte) s#1 // zpby1=zpby2 + // (byte) s#4 = (byte) s#1 // zpby1=zpby2 lda 2 sta 6 jmp B3 @@ -505,7 +367,7 @@ FINAL SYMBOL TABLE (byte) s (byte) s#1 zp byte:2 (byte) s#2 zp byte:5 -(byte) s#5 zp byte:6 +(byte) s#4 zp byte:6 FINAL CODE BBEGIN: @@ -518,7 +380,7 @@ B1_from_BBEGIN: sta 4 jmp B1 B1_from_B3: - // (byte) s#2 = (byte) s#5 // zpby1=zpby2 + // (byte) s#2 = (byte) s#4 // zpby1=zpby2 lda 6 sta 5 // (byte) i#2 = (byte) i#1 // zpby1=zpby2 @@ -532,7 +394,7 @@ B1: bcs B2 !: B3_from_B1: - // (byte) s#5 = (byte) s#2 // zpby1=zpby2 + // (byte) s#4 = (byte) s#2 // zpby1=zpby2 lda 5 sta 6 B3: @@ -551,7 +413,7 @@ B2: adc 4 sta 2 B3_from_B2: - // (byte) s#5 = (byte) s#1 // zpby1=zpby2 + // (byte) s#4 = (byte) s#1 // zpby1=zpby2 lda 2 sta 6 jmp B3 diff --git a/src/dk/camelot64/kickc/test/ref/loopmin.sym b/src/dk/camelot64/kickc/test/ref/loopmin.sym index e81ee1a82..9fc44cfe5 100644 --- a/src/dk/camelot64/kickc/test/ref/loopmin.sym +++ b/src/dk/camelot64/kickc/test/ref/loopmin.sym @@ -9,4 +9,4 @@ (byte) s (byte) s#1 zp byte:2 (byte) s#2 zp byte:5 -(byte) s#5 zp byte:6 +(byte) s#4 zp byte:6 diff --git a/src/dk/camelot64/kickc/test/ref/minus.log b/src/dk/camelot64/kickc/test/ref/minus.log index 355564315..894ee61f0 100644 --- a/src/dk/camelot64/kickc/test/ref/minus.log +++ b/src/dk/camelot64/kickc/test/ref/minus.log @@ -44,6 +44,22 @@ INITIAL CONTROL FLOW GRAPH to:@END @END: from @2 +Removing empty block @2 +@BEGIN: from + (byte[16]) p ← (word) 4352 + (byte) i ← (byte) 5 + to:@1 +@1: from @1 @BEGIN + (byte~) $0 ← (byte) 2 + (byte) i + (byte~) $1 ← (byte~) $0 + (byte) 2 + *((byte[16]) p + (byte) i) ← (byte~) $1 + (byte~) $2 ← (byte) i + (byte) 1 + (byte) i ← (byte~) $2 + (boolean~) $3 ← (byte) i < (byte) 10 + if((boolean~) $3) goto @1 + to:@END +@END: from @1 + CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @BEGIN: from (byte[16]) p ← (word) 4352 @@ -57,10 +73,8 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL (byte) i ← (byte~) $2 (boolean~) $3 ← (byte) i < (byte) 10 if((boolean~) $3) goto @1 - to:@2 -@2: from @1 to:@END -@END: from @2 +@END: from @1 Completing Phi functions... CONTROL FLOW GRAPH SSA @@ -78,34 +92,10 @@ CONTROL FLOW GRAPH SSA (byte) i#1 ← (byte~) $2 (boolean~) $3 ← (byte) i#1 < (byte) 10 if((boolean~) $3) goto @1 - to:@2 -@2: from @1 to:@END -@END: from @2 +@END: from @1 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN -@BEGIN: from - (byte[16]) p#0 ← (word) 4352 - (byte) i#0 ← (byte) 5 - to:@1 -@1: from @1 @BEGIN - (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) i#0 ) - (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:@2 -@2: from @1 - to:@END -@END: from @2 - -Culled Empty Block (label) @2 -Succesful SSA optimization Pass2CullEmptyBlocks -CONTROL FLOW GRAPH @BEGIN: from (byte[16]) p#0 ← (word) 4352 (byte) i#0 ← (byte) 5 diff --git a/src/dk/camelot64/kickc/test/ref/summin.log b/src/dk/camelot64/kickc/test/ref/summin.log index 0030bbb2d..d42ec0cbb 100644 --- a/src/dk/camelot64/kickc/test/ref/summin.log +++ b/src/dk/camelot64/kickc/test/ref/summin.log @@ -52,6 +52,24 @@ sum::@1: from to:@END @END: from @1 +Removing empty block sum::@1 +Removing empty block @1 +@BEGIN: from + (byte~) $0 ← call sum (byte) 1 (byte) 2 + (byte) s1 ← (byte~) $0 + (byte~) $1 ← call sum (byte) 9 (byte) 13 + (byte) s2 ← (byte~) $1 + to:@END +sum: from + (byte~) sum::$0 ← (byte) sum::a + (byte) sum::b + (byte) sum::return ← (byte~) sum::$0 + to:sum::@return +sum::@return: from sum + (byte) sum::return ← (byte) sum::return + return (byte) sum::return + to:@RETURN +@END: from @BEGIN + CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @BEGIN: from (byte) sum::a ← (byte) 1 @@ -68,22 +86,17 @@ CONTROL FLOW GRAPH WITH ASSIGNMENT CALL @3: from @2 (byte~) $1 ← (byte) sum::return (byte) s2 ← (byte~) $1 - to:@1 + to:@END sum: from @2 @BEGIN (byte~) sum::$0 ← (byte) sum::a + (byte) sum::b (byte) sum::return ← (byte~) sum::$0 to:sum::@return -sum::@return: from sum sum::@1 +sum::@return: from sum (byte) sum::return ← (byte) sum::return return (byte) sum::return to:@RETURN -sum::@1: from - to:sum::@return -@1: from @3 - to:@END -@END: from @1 +@END: from @3 -Completing Phi functions... Completing Phi functions... CONTROL FLOW GRAPH SSA @BEGIN: from @@ -103,67 +116,21 @@ CONTROL FLOW GRAPH SSA (byte) sum::return#5 ← phi( @2/(byte) sum::return#1 ) (byte~) $1 ← (byte) sum::return#5 (byte) s2#0 ← (byte~) $1 - to:@1 + to:@END sum: from @2 @BEGIN (byte) sum::b#2 ← phi( @2/(byte) sum::b#1 @BEGIN/(byte) sum::b#0 ) (byte) sum::a#2 ← phi( @2/(byte) sum::a#1 @BEGIN/(byte) sum::a#0 ) (byte~) sum::$0 ← (byte) sum::a#2 + (byte) sum::b#2 (byte) sum::return#2 ← (byte~) sum::$0 to:sum::@return -sum::@return: from sum sum::@1 - (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) +sum::@return: from sum + (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 ) (byte) sum::return#3 ← (byte) sum::return#6 return (byte) sum::return#3 to:@RETURN -sum::@1: from - (byte) sum::return#7 ← phi( ) - to:sum::@return -@1: from @3 - to:@END -@END: from @1 +@END: from @3 CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN -@BEGIN: from - (byte) sum::a#0 ← (byte) 1 - (byte) sum::b#0 ← (byte) 2 - call sum param-assignment - (byte) sum::return#0 ← (byte) sum::return#3 - to:@2 -@2: from @BEGIN - (byte) sum::return#4 ← phi( @BEGIN/(byte) sum::return#0 ) - (byte~) $0 ← (byte) sum::return#4 - (byte) s1#0 ← (byte~) $0 - (byte) sum::a#1 ← (byte) 9 - (byte) sum::b#1 ← (byte) 13 - call sum param-assignment - (byte) sum::return#1 ← (byte) sum::return#3 - to:@3 -@3: from @2 - (byte) sum::return#5 ← phi( @2/(byte) sum::return#1 ) - (byte~) $1 ← (byte) sum::return#5 - (byte) s2#0 ← (byte~) $1 - to:@1 -sum: from @2 @BEGIN - (byte) sum::b#2 ← phi( @2/(byte) sum::b#1 @BEGIN/(byte) sum::b#0 ) - (byte) sum::a#2 ← phi( @2/(byte) sum::a#1 @BEGIN/(byte) sum::a#0 ) - (byte~) sum::$0 ← (byte) sum::a#2 + (byte) sum::b#2 - (byte) sum::return#2 ← (byte~) sum::$0 - to:sum::@return -sum::@return: from sum sum::@1 - (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) - (byte) sum::return#3 ← (byte) sum::return#6 - return (byte) sum::return#3 - to:@RETURN -sum::@1: from - (byte) sum::return#7 ← phi( ) - to:sum::@return -@1: from @3 - to:@END -@END: from @1 - -Culled Empty Block (label) @1 -Succesful SSA optimization Pass2CullEmptyBlocks -CONTROL FLOW GRAPH @BEGIN: from (byte) sum::a#0 ← (byte) 1 (byte) sum::b#0 ← (byte) 2 @@ -190,14 +157,11 @@ sum: from @2 @BEGIN (byte~) sum::$0 ← (byte) sum::a#2 + (byte) sum::b#2 (byte) sum::return#2 ← (byte~) sum::$0 to:sum::@return -sum::@return: from sum sum::@1 - (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) +sum::@return: from sum + (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 ) (byte) sum::return#3 ← (byte) sum::return#6 return (byte) sum::return#3 to:@RETURN -sum::@1: from - (byte) sum::return#7 ← phi( ) - to:sum::@return @END: from @3 Constant (byte) sum::a#0 (byte) 1 @@ -228,18 +192,14 @@ sum: from @2 @BEGIN (byte~) sum::$0 ← (byte) sum::a#2 + (byte) sum::b#2 (byte) sum::return#2 ← (byte~) sum::$0 to:sum::@return -sum::@return: from sum sum::@1 - (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) +sum::@return: from sum + (byte) sum::return#6 ← phi( sum/(byte) sum::return#2 ) (byte) sum::return#3 ← (byte) sum::return#6 return (byte) sum::return#3 to:@RETURN -sum::@1: from - (byte) sum::return#7 ← phi( ) - to:sum::@return @END: from @3 -Alias (byte) s1#0 = (byte) sum::return#0 (byte) sum::return#3 (byte) sum::return#4 (byte~) $0 (byte) sum::return#1 (byte) sum::return#5 (byte~) $1 (byte) s2#0 (byte) sum::return#6 -Alias (byte) sum::return#2 = (byte~) sum::$0 +Alias (byte) s1#0 = (byte) sum::return#0 (byte) sum::return#3 (byte) sum::return#4 (byte~) $0 (byte) sum::return#1 (byte) sum::return#5 (byte~) $1 (byte) s2#0 (byte) sum::return#2 (byte~) sum::$0 (byte) sum::return#6 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @BEGIN: from @@ -253,65 +213,16 @@ CONTROL FLOW GRAPH sum: from @2 @BEGIN (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) - (byte) sum::return#2 ← (byte) sum::a#2 + (byte) sum::b#2 + (byte) s1#0 ← (byte) sum::a#2 + (byte) sum::b#2 to:sum::@return -sum::@return: from sum sum::@1 - (byte) s1#0 ← phi( sum/(byte) sum::return#2 sum::@1/(byte) sum::return#7 ) +sum::@return: from sum return (byte) s1#0 to:@RETURN -sum::@1: from - (byte) sum::return#7 ← phi( ) - to:sum::@return -@END: from @3 - -Redundant Phi (byte) sum::return#7 VOID -Succesful SSA optimization Pass2RedundantPhiElimination -CONTROL FLOW GRAPH -@BEGIN: from - call sum param-assignment - to:@2 -@2: from @BEGIN - call sum param-assignment - to:@3 -@3: from @2 - to:@END -sum: from @2 @BEGIN - (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) - (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) - (byte) sum::return#2 ← (byte) sum::a#2 + (byte) sum::b#2 - to:sum::@return -sum::@return: from sum sum::@1 - (byte) s1#0 ← phi( sum/(byte) sum::return#2 ) - return (byte) s1#0 - to:@RETURN -sum::@1: from - to:sum::@return @END: from @3 Culled Empty Block (label) @3 -Culled Empty Block (label) sum::@1 Succesful SSA optimization Pass2CullEmptyBlocks CONTROL FLOW GRAPH -@BEGIN: from - call sum param-assignment - to:@2 -@2: from @BEGIN - call sum param-assignment - to:@END -sum: from @2 @BEGIN - (byte) sum::b#2 ← phi( @2/(byte) 13 @BEGIN/(byte) 2 ) - (byte) sum::a#2 ← phi( @2/(byte) 9 @BEGIN/(byte) 1 ) - (byte) sum::return#2 ← (byte) sum::a#2 + (byte) sum::b#2 - to:sum::@return -sum::@return: from sum - (byte) s1#0 ← phi( sum/(byte) sum::return#2 ) - return (byte) s1#0 - to:@RETURN -@END: from @2 - -Alias (byte) s1#0 = (byte) sum::return#2 -Succesful SSA optimization Pass2AliasElimination -CONTROL FLOW GRAPH @BEGIN: from call sum param-assignment to:@2