Inlined call call line (number) 2 (number) $40 (number) $a (byte) '*' Inlined call call plot (byte~) main::line1_$1 (byte) main::line1_ch Inlined call call line (number) 4 (number) $80 (number) $f (byte) '.' Inlined call call plot (byte~) main::line2_$1 (byte) main::line2_ch Inlined call call plot (byte~) line::$1 (byte) line::ch CONTROL FLOW GRAPH SSA @begin: scope:[] from to:@1 (void()) main() main: scope:[main] from @2 (byte*) main::sc#0 ← (byte*)(number) $400 to:main::@1 main::@1: scope:[main] from main main::@2 (byte*) main::sc#2 ← phi( main/(byte*) main::sc#0 main::@2/(byte*) main::sc#1 ) (bool~) main::$2 ← (byte*) main::sc#2 < (number) $400+(number) $3e8 if((bool~) main::$2) goto main::@2 to:main::@3 main::@2: scope:[main] from main::@1 (byte*) main::sc#3 ← phi( main::@1/(byte*) main::sc#2 ) *((byte*) main::sc#3) ← (byte) ' ' (byte*) main::sc#1 ← ++ (byte*) main::sc#3 to:main::@1 main::@3: scope:[main] from main::@1 (byte) main::line1_xpos#0 ← (number) 2 (byte) main::line1_xadd#0 ← (number) $40 (byte) main::line1_ysize#0 ← (number) $a (byte) main::line1_ch#0 ← (byte) '*' to:main::line1 main::line1: scope:[main] from main::@3 (byte) main::line1_xadd#5 ← phi( main::@3/(byte) main::line1_xadd#0 ) (byte) main::line1_ch#4 ← phi( main::@3/(byte) main::line1_ch#0 ) (byte) main::line1_ysize#3 ← phi( main::@3/(byte) main::line1_ysize#0 ) (byte) main::line1_xpos#1 ← phi( main::@3/(byte) main::line1_xpos#0 ) (byte*) cur_line#0 ← ((byte*)) (number) $400 (word) main::line1_pos#0 ← (word){ (byte) main::line1_xpos#1, (byte) 0 } (byte) main::line1_i#0 ← (byte) 0 to:main::line1_@1 main::line1_@1: scope:[main] from main::@5 main::line1 (byte) main::line1_xadd#4 ← phi( main::@5/(byte) main::line1_xadd#1 main::line1/(byte) main::line1_xadd#5 ) (byte*) cur_line#17 ← phi( main::@5/(byte*) cur_line#1 main::line1/(byte*) cur_line#0 ) (byte) main::line1_ch#2 ← phi( main::@5/(byte) main::line1_ch#3 main::line1/(byte) main::line1_ch#4 ) (word) main::line1_pos#4 ← phi( main::@5/(word) main::line1_pos#1 main::line1/(word) main::line1_pos#0 ) (byte) main::line1_ysize#1 ← phi( main::@5/(byte) main::line1_ysize#2 main::line1/(byte) main::line1_ysize#3 ) (byte) main::line1_i#2 ← phi( main::@5/(byte) main::line1_i#1 main::line1/(byte) main::line1_i#0 ) (bool~) main::line1_$0 ← (byte) main::line1_i#2 < (byte) main::line1_ysize#1 if((bool~) main::line1_$0) goto main::line1_@2 to:main::@4 main::line1_@2: scope:[main] from main::line1_@1 (byte) main::line1_ysize#5 ← phi( main::line1_@1/(byte) main::line1_ysize#1 ) (byte) main::line1_i#5 ← phi( main::line1_@1/(byte) main::line1_i#2 ) (byte) main::line1_xadd#3 ← phi( main::line1_@1/(byte) main::line1_xadd#4 ) (byte*) cur_line#13 ← phi( main::line1_@1/(byte*) cur_line#17 ) (byte) main::line1_ch#1 ← phi( main::line1_@1/(byte) main::line1_ch#2 ) (word) main::line1_pos#2 ← phi( main::line1_@1/(word) main::line1_pos#4 ) (byte~) main::line1_$1 ← > (word) main::line1_pos#2 (byte) main::plot1_xpos#0 ← (byte~) main::line1_$1 (byte) main::plot1_ch#0 ← (byte) main::line1_ch#1 to:main::plot1 main::plot1: scope:[main] from main::line1_@2 (byte) main::line1_ch#5 ← phi( main::line1_@2/(byte) main::line1_ch#1 ) (byte) main::line1_ysize#4 ← phi( main::line1_@2/(byte) main::line1_ysize#5 ) (byte) main::line1_i#4 ← phi( main::line1_@2/(byte) main::line1_i#5 ) (byte) main::line1_xadd#2 ← phi( main::line1_@2/(byte) main::line1_xadd#3 ) (word) main::line1_pos#5 ← phi( main::line1_@2/(word) main::line1_pos#2 ) (byte) main::plot1_ch#1 ← phi( main::line1_@2/(byte) main::plot1_ch#0 ) (byte) main::plot1_xpos#1 ← phi( main::line1_@2/(byte) main::plot1_xpos#0 ) (byte*) cur_line#7 ← phi( main::line1_@2/(byte*) cur_line#13 ) (byte*~) main::plot1_$0 ← (byte*) cur_line#7 + (byte) main::plot1_xpos#1 *((byte*~) main::plot1_$0) ← (byte) main::plot1_ch#1 to:main::@5 main::@5: scope:[main] from main::plot1 (byte) main::line1_ch#3 ← phi( main::plot1/(byte) main::line1_ch#5 ) (byte) main::line1_ysize#2 ← phi( main::plot1/(byte) main::line1_ysize#4 ) (byte) main::line1_i#3 ← phi( main::plot1/(byte) main::line1_i#4 ) (byte*) cur_line#8 ← phi( main::plot1/(byte*) cur_line#7 ) (byte) main::line1_xadd#1 ← phi( main::plot1/(byte) main::line1_xadd#2 ) (word) main::line1_pos#3 ← phi( main::plot1/(word) main::line1_pos#5 ) (word) main::line1_pos#1 ← (word) main::line1_pos#3 + (byte) main::line1_xadd#1 (byte*) cur_line#1 ← (byte*) cur_line#8 + (number) $28 (byte) main::line1_i#1 ← ++ (byte) main::line1_i#3 to:main::line1_@1 main::@4: scope:[main] from main::line1_@1 (byte) main::line2_xpos#0 ← (number) 4 (byte) main::line2_xadd#0 ← (number) $80 (byte) main::line2_ysize#0 ← (number) $f (byte) main::line2_ch#0 ← (byte) '.' to:main::line2 main::line2: scope:[main] from main::@4 (byte) main::line2_xadd#5 ← phi( main::@4/(byte) main::line2_xadd#0 ) (byte) main::line2_ch#4 ← phi( main::@4/(byte) main::line2_ch#0 ) (byte) main::line2_ysize#3 ← phi( main::@4/(byte) main::line2_ysize#0 ) (byte) main::line2_xpos#1 ← phi( main::@4/(byte) main::line2_xpos#0 ) (byte*) cur_line#2 ← ((byte*)) (number) $400 (word) main::line2_pos#0 ← (word){ (byte) main::line2_xpos#1, (byte) 0 } (byte) main::line2_i#0 ← (byte) 0 to:main::line2_@1 main::line2_@1: scope:[main] from main::@6 main::line2 (byte) main::line2_xadd#4 ← phi( main::@6/(byte) main::line2_xadd#1 main::line2/(byte) main::line2_xadd#5 ) (byte*) cur_line#15 ← phi( main::@6/(byte*) cur_line#3 main::line2/(byte*) cur_line#2 ) (byte) main::line2_ch#2 ← phi( main::@6/(byte) main::line2_ch#3 main::line2/(byte) main::line2_ch#4 ) (word) main::line2_pos#4 ← phi( main::@6/(word) main::line2_pos#1 main::line2/(word) main::line2_pos#0 ) (byte) main::line2_ysize#1 ← phi( main::@6/(byte) main::line2_ysize#2 main::line2/(byte) main::line2_ysize#3 ) (byte) main::line2_i#2 ← phi( main::@6/(byte) main::line2_i#1 main::line2/(byte) main::line2_i#0 ) (bool~) main::line2_$0 ← (byte) main::line2_i#2 < (byte) main::line2_ysize#1 if((bool~) main::line2_$0) goto main::line2_@2 to:main::@return main::line2_@2: scope:[main] from main::line2_@1 (byte) main::line2_ysize#5 ← phi( main::line2_@1/(byte) main::line2_ysize#1 ) (byte) main::line2_i#5 ← phi( main::line2_@1/(byte) main::line2_i#2 ) (byte) main::line2_xadd#3 ← phi( main::line2_@1/(byte) main::line2_xadd#4 ) (byte*) cur_line#14 ← phi( main::line2_@1/(byte*) cur_line#15 ) (byte) main::line2_ch#1 ← phi( main::line2_@1/(byte) main::line2_ch#2 ) (word) main::line2_pos#2 ← phi( main::line2_@1/(word) main::line2_pos#4 ) (byte~) main::line2_$1 ← > (word) main::line2_pos#2 (byte) main::plot2_xpos#0 ← (byte~) main::line2_$1 (byte) main::plot2_ch#0 ← (byte) main::line2_ch#1 to:main::plot2 main::plot2: scope:[main] from main::line2_@2 (byte) main::line2_ch#5 ← phi( main::line2_@2/(byte) main::line2_ch#1 ) (byte) main::line2_ysize#4 ← phi( main::line2_@2/(byte) main::line2_ysize#5 ) (byte) main::line2_i#4 ← phi( main::line2_@2/(byte) main::line2_i#5 ) (byte) main::line2_xadd#2 ← phi( main::line2_@2/(byte) main::line2_xadd#3 ) (word) main::line2_pos#5 ← phi( main::line2_@2/(word) main::line2_pos#2 ) (byte) main::plot2_ch#1 ← phi( main::line2_@2/(byte) main::plot2_ch#0 ) (byte) main::plot2_xpos#1 ← phi( main::line2_@2/(byte) main::plot2_xpos#0 ) (byte*) cur_line#9 ← phi( main::line2_@2/(byte*) cur_line#14 ) (byte*~) main::plot2_$0 ← (byte*) cur_line#9 + (byte) main::plot2_xpos#1 *((byte*~) main::plot2_$0) ← (byte) main::plot2_ch#1 to:main::@6 main::@6: scope:[main] from main::plot2 (byte) main::line2_ch#3 ← phi( main::plot2/(byte) main::line2_ch#5 ) (byte) main::line2_ysize#2 ← phi( main::plot2/(byte) main::line2_ysize#4 ) (byte) main::line2_i#3 ← phi( main::plot2/(byte) main::line2_i#4 ) (byte*) cur_line#10 ← phi( main::plot2/(byte*) cur_line#9 ) (byte) main::line2_xadd#1 ← phi( main::plot2/(byte) main::line2_xadd#2 ) (word) main::line2_pos#3 ← phi( main::plot2/(word) main::line2_pos#5 ) (word) main::line2_pos#1 ← (word) main::line2_pos#3 + (byte) main::line2_xadd#1 (byte*) cur_line#3 ← (byte*) cur_line#10 + (number) $28 (byte) main::line2_i#1 ← ++ (byte) main::line2_i#3 to:main::line2_@1 main::@return: scope:[main] from main::line2_@1 (byte*) cur_line#11 ← phi( main::line2_@1/(byte*) cur_line#15 ) (byte*) cur_line#4 ← (byte*) cur_line#11 return to:@return @1: scope:[] from @begin (byte*) cur_line#5 ← (byte*)(number) $400 to:@2 @2: scope:[] from @1 (byte*) cur_line#16 ← phi( @1/(byte*) cur_line#5 ) call main to:@3 @3: scope:[] from @2 (byte*) cur_line#12 ← phi( @2/(byte*) cur_line#4 ) (byte*) cur_line#6 ← (byte*) cur_line#12 to:@end @end: scope:[] from @3 SYMBOL TABLE SSA (label) @1 (label) @2 (label) @3 (label) @begin (label) @end (byte*) cur_line (byte*) cur_line#0 (byte*) cur_line#1 (byte*) cur_line#10 (byte*) cur_line#11 (byte*) cur_line#12 (byte*) cur_line#13 (byte*) cur_line#14 (byte*) cur_line#15 (byte*) cur_line#16 (byte*) cur_line#17 (byte*) cur_line#2 (byte*) cur_line#3 (byte*) cur_line#4 (byte*) cur_line#5 (byte*) cur_line#6 (byte*) cur_line#7 (byte*) cur_line#8 (byte*) cur_line#9 (void()) main() (bool~) main::$2 (label) main::@1 (label) main::@2 (label) main::@3 (label) main::@4 (label) main::@5 (label) main::@6 (label) main::@return (label) main::line1 (bool~) main::line1_$0 (byte~) main::line1_$1 (label) main::line1_@1 (label) main::line1_@2 (byte) main::line1_ch (byte) main::line1_ch#0 (byte) main::line1_ch#1 (byte) main::line1_ch#2 (byte) main::line1_ch#3 (byte) main::line1_ch#4 (byte) main::line1_ch#5 (byte) main::line1_i (byte) main::line1_i#0 (byte) main::line1_i#1 (byte) main::line1_i#2 (byte) main::line1_i#3 (byte) main::line1_i#4 (byte) main::line1_i#5 (word) main::line1_pos (word) main::line1_pos#0 (word) main::line1_pos#1 (word) main::line1_pos#2 (word) main::line1_pos#3 (word) main::line1_pos#4 (word) main::line1_pos#5 (byte) main::line1_xadd (byte) main::line1_xadd#0 (byte) main::line1_xadd#1 (byte) main::line1_xadd#2 (byte) main::line1_xadd#3 (byte) main::line1_xadd#4 (byte) main::line1_xadd#5 (byte) main::line1_xpos (byte) main::line1_xpos#0 (byte) main::line1_xpos#1 (byte) main::line1_ysize (byte) main::line1_ysize#0 (byte) main::line1_ysize#1 (byte) main::line1_ysize#2 (byte) main::line1_ysize#3 (byte) main::line1_ysize#4 (byte) main::line1_ysize#5 (label) main::line2 (bool~) main::line2_$0 (byte~) main::line2_$1 (label) main::line2_@1 (label) main::line2_@2 (byte) main::line2_ch (byte) main::line2_ch#0 (byte) main::line2_ch#1 (byte) main::line2_ch#2 (byte) main::line2_ch#3 (byte) main::line2_ch#4 (byte) main::line2_ch#5 (byte) main::line2_i (byte) main::line2_i#0 (byte) main::line2_i#1 (byte) main::line2_i#2 (byte) main::line2_i#3 (byte) main::line2_i#4 (byte) main::line2_i#5 (word) main::line2_pos (word) main::line2_pos#0 (word) main::line2_pos#1 (word) main::line2_pos#2 (word) main::line2_pos#3 (word) main::line2_pos#4 (word) main::line2_pos#5 (byte) main::line2_xadd (byte) main::line2_xadd#0 (byte) main::line2_xadd#1 (byte) main::line2_xadd#2 (byte) main::line2_xadd#3 (byte) main::line2_xadd#4 (byte) main::line2_xadd#5 (byte) main::line2_xpos (byte) main::line2_xpos#0 (byte) main::line2_xpos#1 (byte) main::line2_ysize (byte) main::line2_ysize#0 (byte) main::line2_ysize#1 (byte) main::line2_ysize#2 (byte) main::line2_ysize#3 (byte) main::line2_ysize#4 (byte) main::line2_ysize#5 (label) main::plot1 (byte*~) main::plot1_$0 (byte) main::plot1_ch (byte) main::plot1_ch#0 (byte) main::plot1_ch#1 (byte) main::plot1_xpos (byte) main::plot1_xpos#0 (byte) main::plot1_xpos#1 (label) main::plot2 (byte*~) main::plot2_$0 (byte) main::plot2_ch (byte) main::plot2_ch#0 (byte) main::plot2_ch#1 (byte) main::plot2_xpos (byte) main::plot2_xpos#0 (byte) main::plot2_xpos#1 (byte*) main::sc (byte*) main::sc#0 (byte*) main::sc#1 (byte*) main::sc#2 (byte*) main::sc#3 Fixing inline constructor with main::$3 ← (byte)main::line1_xpos#1 w= (byte)0 Fixing inline constructor with main::$4 ← (byte)main::line2_xpos#1 w= (byte)0 Successful SSA optimization Pass2FixInlineConstructors Adding number conversion cast (unumber) $400+$3e8 in (bool~) main::$2 ← (byte*) main::sc#2 < (number) $400+(number) $3e8 Adding number conversion cast (unumber) 2 in (byte) main::line1_xpos#0 ← (number) 2 Adding number conversion cast (unumber) $40 in (byte) main::line1_xadd#0 ← (number) $40 Adding number conversion cast (unumber) $a in (byte) main::line1_ysize#0 ← (number) $a Adding number conversion cast (unumber) $28 in (byte*) cur_line#1 ← (byte*) cur_line#8 + (number) $28 Adding number conversion cast (unumber) 4 in (byte) main::line2_xpos#0 ← (number) 4 Adding number conversion cast (unumber) $80 in (byte) main::line2_xadd#0 ← (number) $80 Adding number conversion cast (unumber) $f in (byte) main::line2_ysize#0 ← (number) $f Adding number conversion cast (unumber) $28 in (byte*) cur_line#3 ← (byte*) cur_line#10 + (number) $28 Successful SSA optimization PassNAddNumberTypeConversions Inlining cast (byte) main::line1_xpos#0 ← (unumber)(number) 2 Inlining cast (byte) main::line1_xadd#0 ← (unumber)(number) $40 Inlining cast (byte) main::line1_ysize#0 ← (unumber)(number) $a Inlining cast (byte*) cur_line#0 ← (byte*)(number) $400 Inlining cast (byte) main::line2_xpos#0 ← (unumber)(number) 4 Inlining cast (byte) main::line2_xadd#0 ← (unumber)(number) $80 Inlining cast (byte) main::line2_ysize#0 ← (unumber)(number) $f Inlining cast (byte*) cur_line#2 ← (byte*)(number) $400 Successful SSA optimization Pass2InlineCast Simplifying constant pointer cast (byte*) 1024 Simplifying constant integer cast 2 Simplifying constant integer cast $40 Simplifying constant integer cast $a Simplifying constant pointer cast (byte*) 1024 Simplifying constant integer cast (byte) main::line1_xpos#1 Simplifying constant integer cast (byte) 0 Simplifying constant integer cast $28 Simplifying constant integer cast 4 Simplifying constant integer cast $80 Simplifying constant integer cast $f Simplifying constant pointer cast (byte*) 1024 Simplifying constant integer cast (byte) main::line2_xpos#1 Simplifying constant integer cast (byte) 0 Simplifying constant integer cast $28 Simplifying constant pointer cast (byte*) 1024 Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) 2 Finalized unsigned number type (byte) $40 Finalized unsigned number type (byte) $a Finalized unsigned number type (byte) $28 Finalized unsigned number type (byte) 4 Finalized unsigned number type (byte) $80 Finalized unsigned number type (byte) $f Finalized unsigned number type (byte) $28 Successful SSA optimization PassNFinalizeNumberTypeConversions Alias main::sc#2 = main::sc#3 Alias main::line1_xpos#0 = main::line1_xpos#1 Alias main::line1_ysize#0 = main::line1_ysize#3 Alias main::line1_ch#0 = main::line1_ch#4 Alias main::line1_xadd#0 = main::line1_xadd#5 Alias main::line1_pos#0 = main::$3 Alias main::line1_pos#2 = main::line1_pos#4 main::line1_pos#5 main::line1_pos#3 Alias main::line1_ch#1 = main::line1_ch#2 main::plot1_ch#0 main::plot1_ch#1 main::line1_ch#5 main::line1_ch#3 Alias cur_line#13 = cur_line#17 cur_line#7 cur_line#8 Alias main::line1_xadd#1 = main::line1_xadd#3 main::line1_xadd#4 main::line1_xadd#2 Alias main::line1_i#2 = main::line1_i#5 main::line1_i#4 main::line1_i#3 Alias main::line1_ysize#1 = main::line1_ysize#5 main::line1_ysize#4 main::line1_ysize#2 Alias main::plot1_xpos#0 = main::line1_$1 main::plot1_xpos#1 Alias main::line2_xpos#0 = main::line2_xpos#1 Alias main::line2_ysize#0 = main::line2_ysize#3 Alias main::line2_ch#0 = main::line2_ch#4 Alias main::line2_xadd#0 = main::line2_xadd#5 Alias main::line2_pos#0 = main::$4 Alias main::line2_pos#2 = main::line2_pos#4 main::line2_pos#5 main::line2_pos#3 Alias main::line2_ch#1 = main::line2_ch#2 main::plot2_ch#0 main::plot2_ch#1 main::line2_ch#5 main::line2_ch#3 Alias cur_line#10 = cur_line#14 cur_line#15 cur_line#9 cur_line#11 cur_line#4 Alias main::line2_xadd#1 = main::line2_xadd#3 main::line2_xadd#4 main::line2_xadd#2 Alias main::line2_i#2 = main::line2_i#5 main::line2_i#4 main::line2_i#3 Alias main::line2_ysize#1 = main::line2_ysize#5 main::line2_ysize#4 main::line2_ysize#2 Alias main::plot2_xpos#0 = main::line2_$1 main::plot2_xpos#1 Alias cur_line#16 = cur_line#5 Alias cur_line#12 = cur_line#6 Successful SSA optimization Pass2AliasElimination Identical Phi Values (byte) main::line1_ysize#1 (byte) main::line1_ysize#0 Identical Phi Values (byte) main::line1_ch#1 (byte) main::line1_ch#0 Identical Phi Values (byte) main::line1_xadd#1 (byte) main::line1_xadd#0 Identical Phi Values (byte) main::line2_ysize#1 (byte) main::line2_ysize#0 Identical Phi Values (byte) main::line2_ch#1 (byte) main::line2_ch#0 Identical Phi Values (byte) main::line2_xadd#1 (byte) main::line2_xadd#0 Identical Phi Values (byte*) cur_line#12 (byte*) cur_line#10 Successful SSA optimization Pass2IdenticalPhiElimination Simple Condition (bool~) main::$2 [3] if((byte*) main::sc#2<(word)(number) $400+(number) $3e8) goto main::@2 Simple Condition (bool~) main::line1_$0 [15] if((byte) main::line1_i#2<(byte) main::line1_ysize#0) goto main::line1_@2 Simple Condition (bool~) main::line2_$0 [31] if((byte) main::line2_i#2<(byte) main::line2_ysize#0) goto main::line2_@2 Successful SSA optimization Pass2ConditionalJumpSimplification Constant (const byte*) main::sc#0 = (byte*) 1024 Constant (const byte) main::line1_xpos#0 = 2 Constant (const byte) main::line1_xadd#0 = $40 Constant (const byte) main::line1_ysize#0 = $a Constant (const byte) main::line1_ch#0 = '*' Constant (const byte*) cur_line#0 = (byte*) 1024 Constant (const byte) main::line1_i#0 = 0 Constant (const byte) main::line2_xpos#0 = 4 Constant (const byte) main::line2_xadd#0 = $80 Constant (const byte) main::line2_ysize#0 = $f Constant (const byte) main::line2_ch#0 = '.' Constant (const byte*) cur_line#2 = (byte*) 1024 Constant (const byte) main::line2_i#0 = 0 Constant (const byte*) cur_line#16 = (byte*) 1024 Successful SSA optimization Pass2ConstantIdentification Converting *(pointer+n) to pointer[n] [18] *((byte*~) main::plot1_$0) ← (const byte) main::line1_ch#0 -- *(cur_line#13 + main::plot1_xpos#0) Converting *(pointer+n) to pointer[n] [34] *((byte*~) main::plot2_$0) ← (const byte) main::line2_ch#0 -- *(cur_line#10 + main::plot2_xpos#0) Successful SSA optimization Pass2InlineDerefIdx Eliminating unused variable (byte*~) main::plot1_$0 and assignment [8] (byte*~) main::plot1_$0 ← (byte*) cur_line#13 + (byte) main::plot1_xpos#0 Eliminating unused variable (byte*~) main::plot2_$0 and assignment [17] (byte*~) main::plot2_$0 ← (byte*) cur_line#10 + (byte) main::plot2_xpos#0 Eliminating unused constant (const byte*) cur_line#16 Successful SSA optimization PassNEliminateUnusedVars Constant right-side identified [4] (word) main::line1_pos#0 ← (const byte) main::line1_xpos#0 w= (byte) 0 Constant right-side identified [12] (word) main::line2_pos#0 ← (const byte) main::line2_xpos#0 w= (byte) 0 Successful SSA optimization Pass2ConstantRValueConsolidation Simplifying expression containing zero main::line1_xpos#0*$100 in [4] (word) main::line1_pos#0 ← (const byte) main::line1_xpos#0*(number) $100+(byte) 0 Simplifying expression containing zero main::line2_xpos#0*$100 in [12] (word) main::line2_pos#0 ← (const byte) main::line2_xpos#0*(number) $100+(byte) 0 Successful SSA optimization PassNSimplifyExpressionWithZero Adding number conversion cast (unumber) main::line1_xpos#0*$100 in (word) main::line1_pos#0 ← (const byte) main::line1_xpos#0*(number) $100 Adding number conversion cast (unumber) $100 in (word) main::line1_pos#0 ← ((unumber)) (const byte) main::line1_xpos#0*(number) $100 Adding number conversion cast (unumber) main::line2_xpos#0*$100 in (word) main::line2_pos#0 ← (const byte) main::line2_xpos#0*(number) $100 Adding number conversion cast (unumber) $100 in (word) main::line2_pos#0 ← ((unumber)) (const byte) main::line2_xpos#0*(number) $100 Successful SSA optimization PassNAddNumberTypeConversions Inlining cast (word) main::line1_pos#0 ← (unumber)(const byte) main::line1_xpos#0*(unumber)(number) $100 Inlining cast (word) main::line2_pos#0 ← (unumber)(const byte) main::line2_xpos#0*(unumber)(number) $100 Successful SSA optimization Pass2InlineCast Simplifying constant integer cast (const byte) main::line1_xpos#0*(unumber)(number) $100 Simplifying constant integer cast $100 Simplifying constant integer cast (const byte) main::line2_xpos#0*(unumber)(number) $100 Simplifying constant integer cast $100 Successful SSA optimization PassNCastSimplification Finalized unsigned number type (word) $100 Finalized unsigned number type (word) $100 Successful SSA optimization PassNFinalizeNumberTypeConversions Constant (const word) main::line1_pos#0 = main::line1_xpos#0*$100 Constant (const word) main::line2_pos#0 = main::line2_xpos#0*$100 Successful SSA optimization Pass2ConstantIdentification Inlining constant with var siblings (const byte*) main::sc#0 Inlining constant with var siblings (const byte) main::line1_i#0 Inlining constant with var siblings (const byte) main::line2_i#0 Inlining constant with var siblings (const word) main::line1_pos#0 Inlining constant with var siblings (const word) main::line2_pos#0 Inlining constant with var siblings (const byte*) cur_line#0 Inlining constant with var siblings (const byte*) cur_line#2 Constant inlined main::line2_i#0 = (byte) 0 Constant inlined main::line1_i#0 = (byte) 0 Constant inlined main::line2_pos#0 = (const byte) main::line2_xpos#0*(word) $100 Constant inlined cur_line#0 = (byte*) 1024 Constant inlined main::sc#0 = (byte*) 1024 Constant inlined cur_line#2 = (byte*) 1024 Constant inlined main::line1_pos#0 = (const byte) main::line1_xpos#0*(word) $100 Successful SSA optimization Pass2ConstantInlining Adding NOP phi() at start of @begin Adding NOP phi() at start of @1 Adding NOP phi() at start of @2 Adding NOP phi() at start of @3 Adding NOP phi() at start of @end Adding NOP phi() at start of main Adding NOP phi() at start of main::@3 Adding NOP phi() at start of main::line1 Adding NOP phi() at start of main::@4 Adding NOP phi() at start of main::line2 CALL GRAPH Calls in [] to main:3 Created 7 initial phi equivalence classes Coalesced [23] main::line2_i#6 ← main::line2_i#1 Coalesced [24] main::line2_pos#6 ← main::line2_pos#1 Coalesced [25] cur_line#19 ← cur_line#3 Coalesced [31] main::line1_i#6 ← main::line1_i#1 Coalesced [32] main::line1_pos#6 ← main::line1_pos#1 Coalesced [33] cur_line#18 ← cur_line#1 Coalesced [36] main::sc#4 ← main::sc#1 Coalesced down to 7 phi equivalence classes Culled Empty Block (label) @1 Culled Empty Block (label) @3 Culled Empty Block (label) main::@3 Culled Empty Block (label) main::@4 Renumbering block @2 to @1 Renumbering block main::@5 to main::@3 Renumbering block main::@6 to main::@4 Adding NOP phi() at start of @begin Adding NOP phi() at start of @1 Adding NOP phi() at start of @end Adding NOP phi() at start of main Adding NOP phi() at start of main::line1 Adding NOP phi() at start of main::line2 FINAL CONTROL FLOW GRAPH @begin: scope:[] from [0] phi() to:@1 @1: scope:[] from @begin [1] phi() [2] call main to:@end @end: scope:[] from @1 [3] phi() (void()) main() main: scope:[main] from @1 [4] phi() to:main::@1 main::@1: scope:[main] from main main::@2 [5] (byte*) main::sc#2 ← phi( main/(byte*) 1024 main::@2/(byte*) main::sc#1 ) [6] if((byte*) main::sc#2<(word)(number) $400+(number) $3e8) goto main::@2 to:main::line1 main::line1: scope:[main] from main::@1 [7] phi() to:main::line1_@1 main::line1_@1: scope:[main] from main::@3 main::line1 [8] (byte*) cur_line#13 ← phi( main::@3/(byte*) cur_line#1 main::line1/(byte*) 1024 ) [8] (word) main::line1_pos#2 ← phi( main::@3/(word) main::line1_pos#1 main::line1/(const byte) main::line1_xpos#0*(word) $100 ) [8] (byte) main::line1_i#2 ← phi( main::@3/(byte) main::line1_i#1 main::line1/(byte) 0 ) [9] if((byte) main::line1_i#2<(const byte) main::line1_ysize#0) goto main::line1_@2 to:main::line2 main::line2: scope:[main] from main::line1_@1 [10] phi() to:main::line2_@1 main::line2_@1: scope:[main] from main::@4 main::line2 [11] (byte*) cur_line#10 ← phi( main::@4/(byte*) cur_line#3 main::line2/(byte*) 1024 ) [11] (word) main::line2_pos#2 ← phi( main::@4/(word) main::line2_pos#1 main::line2/(const byte) main::line2_xpos#0*(word) $100 ) [11] (byte) main::line2_i#2 ← phi( main::@4/(byte) main::line2_i#1 main::line2/(byte) 0 ) [12] if((byte) main::line2_i#2<(const byte) main::line2_ysize#0) goto main::line2_@2 to:main::@return main::@return: scope:[main] from main::line2_@1 [13] return to:@return main::line2_@2: scope:[main] from main::line2_@1 [14] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 to:main::plot2 main::plot2: scope:[main] from main::line2_@2 [15] *((byte*) cur_line#10 + (byte) main::plot2_xpos#0) ← (const byte) main::line2_ch#0 to:main::@4 main::@4: scope:[main] from main::plot2 [16] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [17] (byte*) cur_line#3 ← (byte*) cur_line#10 + (byte) $28 [18] (byte) main::line2_i#1 ← ++ (byte) main::line2_i#2 to:main::line2_@1 main::line1_@2: scope:[main] from main::line1_@1 [19] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 to:main::plot1 main::plot1: scope:[main] from main::line1_@2 [20] *((byte*) cur_line#13 + (byte) main::plot1_xpos#0) ← (const byte) main::line1_ch#0 to:main::@3 main::@3: scope:[main] from main::plot1 [21] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [22] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte) $28 [23] (byte) main::line1_i#1 ← ++ (byte) main::line1_i#2 to:main::line1_@1 main::@2: scope:[main] from main::@1 [24] *((byte*) main::sc#2) ← (byte) ' ' [25] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 to:main::@1 VARIABLE REGISTER WEIGHTS (byte*) cur_line (byte*) cur_line#1 101.0 (byte*) cur_line#10 60.599999999999994 (byte*) cur_line#13 60.599999999999994 (byte*) cur_line#3 101.0 (void()) main() (byte) main::line1_ch (byte) main::line1_i (byte) main::line1_i#1 202.0 (byte) main::line1_i#2 50.5 (word) main::line1_pos (word) main::line1_pos#1 67.33333333333333 (word) main::line1_pos#2 75.75 (byte) main::line1_xadd (byte) main::line1_xpos (byte) main::line1_ysize (byte) main::line2_ch (byte) main::line2_i (byte) main::line2_i#1 202.0 (byte) main::line2_i#2 50.5 (word) main::line2_pos (word) main::line2_pos#1 67.33333333333333 (word) main::line2_pos#2 75.75 (byte) main::line2_xadd (byte) main::line2_xpos (byte) main::line2_ysize (byte) main::plot1_ch (byte) main::plot1_xpos (byte) main::plot1_xpos#0 202.0 (byte) main::plot2_ch (byte) main::plot2_xpos (byte) main::plot2_xpos#0 202.0 (byte*) main::sc (byte*) main::sc#1 202.0 (byte*) main::sc#2 134.66666666666666 Initial phi equivalence classes [ main::sc#2 main::sc#1 ] [ main::line1_i#2 main::line1_i#1 ] [ main::line1_pos#2 main::line1_pos#1 ] [ cur_line#13 cur_line#1 ] [ main::line2_i#2 main::line2_i#1 ] [ main::line2_pos#2 main::line2_pos#1 ] [ cur_line#10 cur_line#3 ] Added variable main::plot2_xpos#0 to live range equivalence class [ main::plot2_xpos#0 ] Added variable main::plot1_xpos#0 to live range equivalence class [ main::plot1_xpos#0 ] Complete equivalence classes [ main::sc#2 main::sc#1 ] [ main::line1_i#2 main::line1_i#1 ] [ main::line1_pos#2 main::line1_pos#1 ] [ cur_line#13 cur_line#1 ] [ main::line2_i#2 main::line2_i#1 ] [ main::line2_pos#2 main::line2_pos#1 ] [ cur_line#10 cur_line#3 ] [ main::plot2_xpos#0 ] [ main::plot1_xpos#0 ] Allocated zp[2]:2 [ main::sc#2 main::sc#1 ] Allocated zp[1]:4 [ main::line1_i#2 main::line1_i#1 ] Allocated zp[2]:5 [ main::line1_pos#2 main::line1_pos#1 ] Allocated zp[2]:7 [ cur_line#13 cur_line#1 ] Allocated zp[1]:9 [ main::line2_i#2 main::line2_i#1 ] Allocated zp[2]:10 [ main::line2_pos#2 main::line2_pos#1 ] Allocated zp[2]:12 [ cur_line#10 cur_line#3 ] Allocated zp[1]:14 [ main::plot2_xpos#0 ] Allocated zp[1]:15 [ main::plot1_xpos#0 ] INITIAL ASM Target platform is c64basic / MOS6502X // File Comments // Inline functions in two levels // Upstart .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" // Global Constants & labels .label cur_line = 7 .label cur_line_1 = $c // @begin __bbegin: // [1] phi from @begin to @1 [phi:@begin->@1] __b1_from___bbegin: jmp __b1 // @1 __b1: // [2] call main // [4] phi from @1 to main [phi:@1->main] main_from___b1: jsr main // [3] phi from @1 to @end [phi:@1->@end] __bend_from___b1: jmp __bend // @end __bend: // main main: { .const line1_xpos = 2 .const line1_xadd = $40 .const line1_ysize = $a .const line1_ch = '*' .const line2_xpos = 4 .const line2_xadd = $80 .const line2_ysize = $f .const line2_ch = '.' .label sc = 2 .label plot1_xpos = $f .label line1_pos = 5 .label line1_i = 4 .label plot2_xpos = $e .label line2_pos = $a .label line2_i = 9 // [5] phi from main to main::@1 [phi:main->main::@1] __b1_from_main: // [5] phi (byte*) main::sc#2 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 lda #<$400 sta.z sc lda #>$400 sta.z sc+1 jmp __b1 // main::@1 __b1: // [6] if((byte*) main::sc#2<(word)(number) $400+(number) $3e8) goto main::@2 -- pbuz1_lt_vwuc1_then_la1 lda.z sc+1 cmp #>$400+$3e8 bcc __b2 bne !+ lda.z sc cmp #<$400+$3e8 bcc __b2 !: // [7] phi from main::@1 to main::line1 [phi:main::@1->main::line1] line1_from___b1: jmp line1 // main::line1 line1: // [8] phi from main::line1 to main::line1_@1 [phi:main::line1->main::line1_@1] line1___b1_from_line1: // [8] phi (byte*) cur_line#13 = (byte*) 1024 [phi:main::line1->main::line1_@1#0] -- pbuz1=pbuc1 lda #<$400 sta.z cur_line lda #>$400 sta.z cur_line+1 // [8] phi (word) main::line1_pos#2 = (const byte) main::line1_xpos#0*(word) $100 [phi:main::line1->main::line1_@1#1] -- vwuz1=vwuc1 lda #line1_xpos*$100 sta.z line1_pos+1 // [8] phi (byte) main::line1_i#2 = (byte) 0 [phi:main::line1->main::line1_@1#2] -- vbuz1=vbuc1 lda #0 sta.z line1_i jmp line1___b1 // main::line1_@1 line1___b1: // [9] if((byte) main::line1_i#2<(const byte) main::line1_ysize#0) goto main::line1_@2 -- vbuz1_lt_vbuc1_then_la1 lda.z line1_i cmp #line1_ysize bcc line1___b2 // [10] phi from main::line1_@1 to main::line2 [phi:main::line1_@1->main::line2] line2_from_line1___b1: jmp line2 // main::line2 line2: // [11] phi from main::line2 to main::line2_@1 [phi:main::line2->main::line2_@1] line2___b1_from_line2: // [11] phi (byte*) cur_line#10 = (byte*) 1024 [phi:main::line2->main::line2_@1#0] -- pbuz1=pbuc1 lda #<$400 sta.z cur_line_1 lda #>$400 sta.z cur_line_1+1 // [11] phi (word) main::line2_pos#2 = (const byte) main::line2_xpos#0*(word) $100 [phi:main::line2->main::line2_@1#1] -- vwuz1=vwuc1 lda #line2_xpos*$100 sta.z line2_pos+1 // [11] phi (byte) main::line2_i#2 = (byte) 0 [phi:main::line2->main::line2_@1#2] -- vbuz1=vbuc1 lda #0 sta.z line2_i jmp line2___b1 // main::line2_@1 line2___b1: // [12] if((byte) main::line2_i#2<(const byte) main::line2_ysize#0) goto main::line2_@2 -- vbuz1_lt_vbuc1_then_la1 lda.z line2_i cmp #line2_ysize bcc line2___b2 jmp __breturn // main::@return __breturn: // [13] return rts // main::line2_@2 line2___b2: // [14] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 -- vbuz1=_hi_vwuz2 lda.z line2_pos+1 sta.z plot2_xpos jmp plot2 // main::plot2 plot2: // [15] *((byte*) cur_line#10 + (byte) main::plot2_xpos#0) ← (const byte) main::line2_ch#0 -- pbuz1_derefidx_vbuz2=vbuc1 lda #line2_ch ldy.z plot2_xpos sta (cur_line_1),y jmp __b4 // main::@4 __b4: // [16] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 -- vwuz1=vwuz1_plus_vbuc1 lda #line2_xadd clc adc.z line2_pos sta.z line2_pos bcc !+ inc.z line2_pos+1 !: // [17] (byte*) cur_line#3 ← (byte*) cur_line#10 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 lda #$28 clc adc.z cur_line_1 sta.z cur_line_1 bcc !+ inc.z cur_line_1+1 !: // [18] (byte) main::line2_i#1 ← ++ (byte) main::line2_i#2 -- vbuz1=_inc_vbuz1 inc.z line2_i // [11] phi from main::@4 to main::line2_@1 [phi:main::@4->main::line2_@1] line2___b1_from___b4: // [11] phi (byte*) cur_line#10 = (byte*) cur_line#3 [phi:main::@4->main::line2_@1#0] -- register_copy // [11] phi (word) main::line2_pos#2 = (word) main::line2_pos#1 [phi:main::@4->main::line2_@1#1] -- register_copy // [11] phi (byte) main::line2_i#2 = (byte) main::line2_i#1 [phi:main::@4->main::line2_@1#2] -- register_copy jmp line2___b1 // main::line1_@2 line1___b2: // [19] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 -- vbuz1=_hi_vwuz2 lda.z line1_pos+1 sta.z plot1_xpos jmp plot1 // main::plot1 plot1: // [20] *((byte*) cur_line#13 + (byte) main::plot1_xpos#0) ← (const byte) main::line1_ch#0 -- pbuz1_derefidx_vbuz2=vbuc1 lda #line1_ch ldy.z plot1_xpos sta (cur_line),y jmp __b3 // main::@3 __b3: // [21] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 -- vwuz1=vwuz1_plus_vbuc1 lda #line1_xadd clc adc.z line1_pos sta.z line1_pos bcc !+ inc.z line1_pos+1 !: // [22] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 lda #$28 clc adc.z cur_line sta.z cur_line bcc !+ inc.z cur_line+1 !: // [23] (byte) main::line1_i#1 ← ++ (byte) main::line1_i#2 -- vbuz1=_inc_vbuz1 inc.z line1_i // [8] phi from main::@3 to main::line1_@1 [phi:main::@3->main::line1_@1] line1___b1_from___b3: // [8] phi (byte*) cur_line#13 = (byte*) cur_line#1 [phi:main::@3->main::line1_@1#0] -- register_copy // [8] phi (word) main::line1_pos#2 = (word) main::line1_pos#1 [phi:main::@3->main::line1_@1#1] -- register_copy // [8] phi (byte) main::line1_i#2 = (byte) main::line1_i#1 [phi:main::@3->main::line1_@1#2] -- register_copy jmp line1___b1 // main::@2 __b2: // [24] *((byte*) main::sc#2) ← (byte) ' ' -- _deref_pbuz1=vbuc1 lda #' ' ldy #0 sta (sc),y // [25] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 inc.z sc bne !+ inc.z sc+1 !: // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] __b1_from___b2: // [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@2->main::@1#0] -- register_copy jmp __b1 } // File Data REGISTER UPLIFT POTENTIAL REGISTERS Statement [6] if((byte*) main::sc#2<(word)(number) $400+(number) $3e8) goto main::@2 [ main::sc#2 ] ( main:2 [ main::sc#2 ] { } ) always clobbers reg byte a Statement [15] *((byte*) cur_line#10 + (byte) main::plot2_xpos#0) ← (const byte) main::line2_ch#0 [ main::line2_i#2 main::line2_pos#2 cur_line#10 ] ( main:2 [ main::line2_i#2 main::line2_pos#2 cur_line#10 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:9 [ main::line2_i#2 main::line2_i#1 ] Statement [16] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [ main::line2_i#2 cur_line#10 main::line2_pos#1 ] ( main:2 [ main::line2_i#2 cur_line#10 main::line2_pos#1 ] { } ) always clobbers reg byte a Statement [17] (byte*) cur_line#3 ← (byte*) cur_line#10 + (byte) $28 [ main::line2_i#2 main::line2_pos#1 cur_line#3 ] ( main:2 [ main::line2_i#2 main::line2_pos#1 cur_line#3 ] { } ) always clobbers reg byte a Statement [20] *((byte*) cur_line#13 + (byte) main::plot1_xpos#0) ← (const byte) main::line1_ch#0 [ main::line1_i#2 main::line1_pos#2 cur_line#13 ] ( main:2 [ main::line1_i#2 main::line1_pos#2 cur_line#13 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:4 [ main::line1_i#2 main::line1_i#1 ] Statement [21] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [ main::line1_i#2 cur_line#13 main::line1_pos#1 ] ( main:2 [ main::line1_i#2 cur_line#13 main::line1_pos#1 ] { } ) always clobbers reg byte a Statement [22] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte) $28 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ( main:2 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] { } ) always clobbers reg byte a Statement [24] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] { } ) always clobbers reg byte a reg byte y Statement [6] if((byte*) main::sc#2<(word)(number) $400+(number) $3e8) goto main::@2 [ main::sc#2 ] ( main:2 [ main::sc#2 ] { } ) always clobbers reg byte a Statement [15] *((byte*) cur_line#10 + (byte) main::plot2_xpos#0) ← (const byte) main::line2_ch#0 [ main::line2_i#2 main::line2_pos#2 cur_line#10 ] ( main:2 [ main::line2_i#2 main::line2_pos#2 cur_line#10 ] { } ) always clobbers reg byte a Statement [16] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [ main::line2_i#2 cur_line#10 main::line2_pos#1 ] ( main:2 [ main::line2_i#2 cur_line#10 main::line2_pos#1 ] { } ) always clobbers reg byte a Statement [17] (byte*) cur_line#3 ← (byte*) cur_line#10 + (byte) $28 [ main::line2_i#2 main::line2_pos#1 cur_line#3 ] ( main:2 [ main::line2_i#2 main::line2_pos#1 cur_line#3 ] { } ) always clobbers reg byte a Statement [20] *((byte*) cur_line#13 + (byte) main::plot1_xpos#0) ← (const byte) main::line1_ch#0 [ main::line1_i#2 main::line1_pos#2 cur_line#13 ] ( main:2 [ main::line1_i#2 main::line1_pos#2 cur_line#13 ] { } ) always clobbers reg byte a Statement [21] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [ main::line1_i#2 cur_line#13 main::line1_pos#1 ] ( main:2 [ main::line1_i#2 cur_line#13 main::line1_pos#1 ] { } ) always clobbers reg byte a Statement [22] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte) $28 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ( main:2 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] { } ) always clobbers reg byte a Statement [24] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] { } ) always clobbers reg byte a reg byte y Potential registers zp[2]:2 [ main::sc#2 main::sc#1 ] : zp[2]:2 , Potential registers zp[1]:4 [ main::line1_i#2 main::line1_i#1 ] : zp[1]:4 , reg byte x , reg byte y , Potential registers zp[2]:5 [ main::line1_pos#2 main::line1_pos#1 ] : zp[2]:5 , Potential registers zp[2]:7 [ cur_line#13 cur_line#1 ] : zp[2]:7 , Potential registers zp[1]:9 [ main::line2_i#2 main::line2_i#1 ] : zp[1]:9 , reg byte x , reg byte y , Potential registers zp[2]:10 [ main::line2_pos#2 main::line2_pos#1 ] : zp[2]:10 , Potential registers zp[2]:12 [ cur_line#10 cur_line#3 ] : zp[2]:12 , Potential registers zp[1]:14 [ main::plot2_xpos#0 ] : zp[1]:14 , reg byte a , reg byte x , reg byte y , Potential registers zp[1]:15 [ main::plot1_xpos#0 ] : zp[1]:15 , reg byte a , reg byte x , reg byte y , REGISTER UPLIFT SCOPES Uplift Scope [main] 336.67: zp[2]:2 [ main::sc#2 main::sc#1 ] 252.5: zp[1]:4 [ main::line1_i#2 main::line1_i#1 ] 252.5: zp[1]:9 [ main::line2_i#2 main::line2_i#1 ] 202: zp[1]:14 [ main::plot2_xpos#0 ] 202: zp[1]:15 [ main::plot1_xpos#0 ] 143.08: zp[2]:5 [ main::line1_pos#2 main::line1_pos#1 ] 143.08: zp[2]:10 [ main::line2_pos#2 main::line2_pos#1 ] Uplift Scope [] 161.6: zp[2]:7 [ cur_line#13 cur_line#1 ] 161.6: zp[2]:12 [ cur_line#10 cur_line#3 ] Uplifting [main] best 2364 combination zp[2]:2 [ main::sc#2 main::sc#1 ] reg byte x [ main::line1_i#2 main::line1_i#1 ] reg byte x [ main::line2_i#2 main::line2_i#1 ] reg byte y [ main::plot2_xpos#0 ] reg byte a [ main::plot1_xpos#0 ] zp[2]:5 [ main::line1_pos#2 main::line1_pos#1 ] zp[2]:10 [ main::line2_pos#2 main::line2_pos#1 ] Limited combination testing to 100 combinations of 144 possible. Uplifting [] best 2364 combination zp[2]:7 [ cur_line#13 cur_line#1 ] zp[2]:12 [ cur_line#10 cur_line#3 ] Coalescing zero page register [ zp[2]:7 [ cur_line#13 cur_line#1 ] ] with [ zp[2]:2 [ main::sc#2 main::sc#1 ] ] Coalescing zero page register [ zp[2]:12 [ cur_line#10 cur_line#3 ] ] with [ zp[2]:5 [ main::line1_pos#2 main::line1_pos#1 ] ] Allocated (was zp[2]:7) zp[2]:2 [ cur_line#13 cur_line#1 main::sc#2 main::sc#1 ] Allocated (was zp[2]:10) zp[2]:4 [ main::line2_pos#2 main::line2_pos#1 ] Allocated (was zp[2]:12) zp[2]:6 [ cur_line#10 cur_line#3 main::line1_pos#2 main::line1_pos#1 ] ASSEMBLER BEFORE OPTIMIZATION // File Comments // Inline functions in two levels // Upstart .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" // Global Constants & labels .label cur_line = 2 .label cur_line_1 = 6 // @begin __bbegin: // [1] phi from @begin to @1 [phi:@begin->@1] __b1_from___bbegin: jmp __b1 // @1 __b1: // [2] call main // [4] phi from @1 to main [phi:@1->main] main_from___b1: jsr main // [3] phi from @1 to @end [phi:@1->@end] __bend_from___b1: jmp __bend // @end __bend: // main main: { .const line1_xpos = 2 .const line1_xadd = $40 .const line1_ysize = $a .const line1_ch = '*' .const line2_xpos = 4 .const line2_xadd = $80 .const line2_ysize = $f .const line2_ch = '.' .label sc = 2 .label line1_pos = 6 .label line2_pos = 4 // [5] phi from main to main::@1 [phi:main->main::@1] __b1_from_main: // [5] phi (byte*) main::sc#2 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 lda #<$400 sta.z sc lda #>$400 sta.z sc+1 jmp __b1 // main::@1 __b1: // [6] if((byte*) main::sc#2<(word)(number) $400+(number) $3e8) goto main::@2 -- pbuz1_lt_vwuc1_then_la1 lda.z sc+1 cmp #>$400+$3e8 bcc __b2 bne !+ lda.z sc cmp #<$400+$3e8 bcc __b2 !: // [7] phi from main::@1 to main::line1 [phi:main::@1->main::line1] line1_from___b1: jmp line1 // main::line1 line1: // [8] phi from main::line1 to main::line1_@1 [phi:main::line1->main::line1_@1] line1___b1_from_line1: // [8] phi (byte*) cur_line#13 = (byte*) 1024 [phi:main::line1->main::line1_@1#0] -- pbuz1=pbuc1 lda #<$400 sta.z cur_line lda #>$400 sta.z cur_line+1 // [8] phi (word) main::line1_pos#2 = (const byte) main::line1_xpos#0*(word) $100 [phi:main::line1->main::line1_@1#1] -- vwuz1=vwuc1 lda #line1_xpos*$100 sta.z line1_pos+1 // [8] phi (byte) main::line1_i#2 = (byte) 0 [phi:main::line1->main::line1_@1#2] -- vbuxx=vbuc1 ldx #0 jmp line1___b1 // main::line1_@1 line1___b1: // [9] if((byte) main::line1_i#2<(const byte) main::line1_ysize#0) goto main::line1_@2 -- vbuxx_lt_vbuc1_then_la1 cpx #line1_ysize bcc line1___b2 // [10] phi from main::line1_@1 to main::line2 [phi:main::line1_@1->main::line2] line2_from_line1___b1: jmp line2 // main::line2 line2: // [11] phi from main::line2 to main::line2_@1 [phi:main::line2->main::line2_@1] line2___b1_from_line2: // [11] phi (byte*) cur_line#10 = (byte*) 1024 [phi:main::line2->main::line2_@1#0] -- pbuz1=pbuc1 lda #<$400 sta.z cur_line_1 lda #>$400 sta.z cur_line_1+1 // [11] phi (word) main::line2_pos#2 = (const byte) main::line2_xpos#0*(word) $100 [phi:main::line2->main::line2_@1#1] -- vwuz1=vwuc1 lda #line2_xpos*$100 sta.z line2_pos+1 // [11] phi (byte) main::line2_i#2 = (byte) 0 [phi:main::line2->main::line2_@1#2] -- vbuxx=vbuc1 ldx #0 jmp line2___b1 // main::line2_@1 line2___b1: // [12] if((byte) main::line2_i#2<(const byte) main::line2_ysize#0) goto main::line2_@2 -- vbuxx_lt_vbuc1_then_la1 cpx #line2_ysize bcc line2___b2 jmp __breturn // main::@return __breturn: // [13] return rts // main::line2_@2 line2___b2: // [14] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 -- vbuyy=_hi_vwuz1 ldy.z line2_pos+1 jmp plot2 // main::plot2 plot2: // [15] *((byte*) cur_line#10 + (byte) main::plot2_xpos#0) ← (const byte) main::line2_ch#0 -- pbuz1_derefidx_vbuyy=vbuc1 lda #line2_ch sta (cur_line_1),y jmp __b4 // main::@4 __b4: // [16] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 -- vwuz1=vwuz1_plus_vbuc1 lda #line2_xadd clc adc.z line2_pos sta.z line2_pos bcc !+ inc.z line2_pos+1 !: // [17] (byte*) cur_line#3 ← (byte*) cur_line#10 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 lda #$28 clc adc.z cur_line_1 sta.z cur_line_1 bcc !+ inc.z cur_line_1+1 !: // [18] (byte) main::line2_i#1 ← ++ (byte) main::line2_i#2 -- vbuxx=_inc_vbuxx inx // [11] phi from main::@4 to main::line2_@1 [phi:main::@4->main::line2_@1] line2___b1_from___b4: // [11] phi (byte*) cur_line#10 = (byte*) cur_line#3 [phi:main::@4->main::line2_@1#0] -- register_copy // [11] phi (word) main::line2_pos#2 = (word) main::line2_pos#1 [phi:main::@4->main::line2_@1#1] -- register_copy // [11] phi (byte) main::line2_i#2 = (byte) main::line2_i#1 [phi:main::@4->main::line2_@1#2] -- register_copy jmp line2___b1 // main::line1_@2 line1___b2: // [19] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 -- vbuaa=_hi_vwuz1 lda.z line1_pos+1 jmp plot1 // main::plot1 plot1: // [20] *((byte*) cur_line#13 + (byte) main::plot1_xpos#0) ← (const byte) main::line1_ch#0 -- pbuz1_derefidx_vbuaa=vbuc1 tay lda #line1_ch sta (cur_line),y jmp __b3 // main::@3 __b3: // [21] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 -- vwuz1=vwuz1_plus_vbuc1 lda #line1_xadd clc adc.z line1_pos sta.z line1_pos bcc !+ inc.z line1_pos+1 !: // [22] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 lda #$28 clc adc.z cur_line sta.z cur_line bcc !+ inc.z cur_line+1 !: // [23] (byte) main::line1_i#1 ← ++ (byte) main::line1_i#2 -- vbuxx=_inc_vbuxx inx // [8] phi from main::@3 to main::line1_@1 [phi:main::@3->main::line1_@1] line1___b1_from___b3: // [8] phi (byte*) cur_line#13 = (byte*) cur_line#1 [phi:main::@3->main::line1_@1#0] -- register_copy // [8] phi (word) main::line1_pos#2 = (word) main::line1_pos#1 [phi:main::@3->main::line1_@1#1] -- register_copy // [8] phi (byte) main::line1_i#2 = (byte) main::line1_i#1 [phi:main::@3->main::line1_@1#2] -- register_copy jmp line1___b1 // main::@2 __b2: // [24] *((byte*) main::sc#2) ← (byte) ' ' -- _deref_pbuz1=vbuc1 lda #' ' ldy #0 sta (sc),y // [25] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 inc.z sc bne !+ inc.z sc+1 !: // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] __b1_from___b2: // [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@2->main::@1#0] -- register_copy jmp __b1 } // File Data ASSEMBLER OPTIMIZATIONS Removing instruction jmp __b1 Removing instruction jmp __bend Removing instruction jmp __b1 Removing instruction jmp line1 Removing instruction jmp line1___b1 Removing instruction jmp line2 Removing instruction jmp line2___b1 Removing instruction jmp __breturn Removing instruction jmp plot2 Removing instruction jmp __b4 Removing instruction jmp plot1 Removing instruction jmp __b3 Succesful ASM optimization Pass5NextJumpElimination Removing instruction __b1_from___bbegin: Removing instruction __b1: Removing instruction main_from___b1: Removing instruction __bend_from___b1: Removing instruction line1_from___b1: Removing instruction line1___b1_from_line1: Removing instruction line2_from_line1___b1: Removing instruction line2___b1_from_line2: Succesful ASM optimization Pass5RedundantLabelElimination Removing instruction __bbegin: Removing instruction __bend: Removing instruction __b1_from_main: Removing instruction line1: Removing instruction line2: Removing instruction __breturn: Removing instruction plot2: Removing instruction __b4: Removing instruction line2___b1_from___b4: Removing instruction plot1: Removing instruction __b3: Removing instruction line1___b1_from___b3: Removing instruction __b1_from___b2: Succesful ASM optimization Pass5UnusedLabelElimination Removing instruction jsr main Succesful ASM optimization Pass5SkipBegin FINAL SYMBOL TABLE (label) @1 (label) @begin (label) @end (byte*) cur_line (byte*) cur_line#1 cur_line zp[2]:2 101.0 (byte*) cur_line#10 cur_line_1 zp[2]:6 60.599999999999994 (byte*) cur_line#13 cur_line zp[2]:2 60.599999999999994 (byte*) cur_line#3 cur_line_1 zp[2]:6 101.0 (void()) main() (label) main::@1 (label) main::@2 (label) main::@3 (label) main::@4 (label) main::@return (label) main::line1 (label) main::line1_@1 (label) main::line1_@2 (byte) main::line1_ch (const byte) main::line1_ch#0 line1_ch = (byte) '*' (byte) main::line1_i (byte) main::line1_i#1 reg byte x 202.0 (byte) main::line1_i#2 reg byte x 50.5 (word) main::line1_pos (word) main::line1_pos#1 line1_pos zp[2]:6 67.33333333333333 (word) main::line1_pos#2 line1_pos zp[2]:6 75.75 (byte) main::line1_xadd (const byte) main::line1_xadd#0 line1_xadd = (byte) $40 (byte) main::line1_xpos (const byte) main::line1_xpos#0 line1_xpos = (byte) 2 (byte) main::line1_ysize (const byte) main::line1_ysize#0 line1_ysize = (byte) $a (label) main::line2 (label) main::line2_@1 (label) main::line2_@2 (byte) main::line2_ch (const byte) main::line2_ch#0 line2_ch = (byte) '.' (byte) main::line2_i (byte) main::line2_i#1 reg byte x 202.0 (byte) main::line2_i#2 reg byte x 50.5 (word) main::line2_pos (word) main::line2_pos#1 line2_pos zp[2]:4 67.33333333333333 (word) main::line2_pos#2 line2_pos zp[2]:4 75.75 (byte) main::line2_xadd (const byte) main::line2_xadd#0 line2_xadd = (byte) $80 (byte) main::line2_xpos (const byte) main::line2_xpos#0 line2_xpos = (byte) 4 (byte) main::line2_ysize (const byte) main::line2_ysize#0 line2_ysize = (byte) $f (label) main::plot1 (byte) main::plot1_ch (byte) main::plot1_xpos (byte) main::plot1_xpos#0 reg byte a 202.0 (label) main::plot2 (byte) main::plot2_ch (byte) main::plot2_xpos (byte) main::plot2_xpos#0 reg byte y 202.0 (byte*) main::sc (byte*) main::sc#1 sc zp[2]:2 202.0 (byte*) main::sc#2 sc zp[2]:2 134.66666666666666 reg byte x [ main::line1_i#2 main::line1_i#1 ] zp[2]:2 [ cur_line#13 cur_line#1 main::sc#2 main::sc#1 ] reg byte x [ main::line2_i#2 main::line2_i#1 ] zp[2]:4 [ main::line2_pos#2 main::line2_pos#1 ] zp[2]:6 [ cur_line#10 cur_line#3 main::line1_pos#2 main::line1_pos#1 ] reg byte y [ main::plot2_xpos#0 ] reg byte a [ main::plot1_xpos#0 ] FINAL ASSEMBLER Score: 2106 // File Comments // Inline functions in two levels // Upstart .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" // Global Constants & labels .label cur_line = 2 .label cur_line_1 = 6 // @begin // [1] phi from @begin to @1 [phi:@begin->@1] // @1 // [2] call main // [4] phi from @1 to main [phi:@1->main] // [3] phi from @1 to @end [phi:@1->@end] // @end // main main: { .const line1_xpos = 2 .const line1_xadd = $40 .const line1_ysize = $a .const line1_ch = '*' .const line2_xpos = 4 .const line2_xadd = $80 .const line2_ysize = $f .const line2_ch = '.' .label sc = 2 .label line1_pos = 6 .label line2_pos = 4 // [5] phi from main to main::@1 [phi:main->main::@1] // [5] phi (byte*) main::sc#2 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 lda #<$400 sta.z sc lda #>$400 sta.z sc+1 // main::@1 __b1: // for(byte* sc = $400;sc<$400+1000;sc++) // [6] if((byte*) main::sc#2<(word)(number) $400+(number) $3e8) goto main::@2 -- pbuz1_lt_vwuc1_then_la1 lda.z sc+1 cmp #>$400+$3e8 bcc __b2 bne !+ lda.z sc cmp #<$400+$3e8 bcc __b2 !: // [7] phi from main::@1 to main::line1 [phi:main::@1->main::line1] // main::line1 // [8] phi from main::line1 to main::line1_@1 [phi:main::line1->main::line1_@1] // [8] phi (byte*) cur_line#13 = (byte*) 1024 [phi:main::line1->main::line1_@1#0] -- pbuz1=pbuc1 lda #<$400 sta.z cur_line lda #>$400 sta.z cur_line+1 // [8] phi (word) main::line1_pos#2 = (const byte) main::line1_xpos#0*(word) $100 [phi:main::line1->main::line1_@1#1] -- vwuz1=vwuc1 lda #line1_xpos*$100 sta.z line1_pos+1 // [8] phi (byte) main::line1_i#2 = (byte) 0 [phi:main::line1->main::line1_@1#2] -- vbuxx=vbuc1 ldx #0 // main::line1_@1 line1___b1: // for( byte i=0;imain::line2] // main::line2 // [11] phi from main::line2 to main::line2_@1 [phi:main::line2->main::line2_@1] // [11] phi (byte*) cur_line#10 = (byte*) 1024 [phi:main::line2->main::line2_@1#0] -- pbuz1=pbuc1 lda #<$400 sta.z cur_line_1 lda #>$400 sta.z cur_line_1+1 // [11] phi (word) main::line2_pos#2 = (const byte) main::line2_xpos#0*(word) $100 [phi:main::line2->main::line2_@1#1] -- vwuz1=vwuc1 lda #line2_xpos*$100 sta.z line2_pos+1 // [11] phi (byte) main::line2_i#2 = (byte) 0 [phi:main::line2->main::line2_@1#2] -- vbuxx=vbuc1 ldx #0 // main::line2_@1 line2___b1: // for( byte i=0;ipos, ch) // [14] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 -- vbuyy=_hi_vwuz1 ldy.z line2_pos+1 // main::plot2 // *(cur_line+xpos) = ch // [15] *((byte*) cur_line#10 + (byte) main::plot2_xpos#0) ← (const byte) main::line2_ch#0 -- pbuz1_derefidx_vbuyy=vbuc1 lda #line2_ch sta (cur_line_1),y // main::@4 // pos += xadd // [16] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 -- vwuz1=vwuz1_plus_vbuc1 lda #line2_xadd clc adc.z line2_pos sta.z line2_pos bcc !+ inc.z line2_pos+1 !: // cur_line += 40 // [17] (byte*) cur_line#3 ← (byte*) cur_line#10 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 lda #$28 clc adc.z cur_line_1 sta.z cur_line_1 bcc !+ inc.z cur_line_1+1 !: // for( byte i=0;imain::line2_@1] // [11] phi (byte*) cur_line#10 = (byte*) cur_line#3 [phi:main::@4->main::line2_@1#0] -- register_copy // [11] phi (word) main::line2_pos#2 = (word) main::line2_pos#1 [phi:main::@4->main::line2_@1#1] -- register_copy // [11] phi (byte) main::line2_i#2 = (byte) main::line2_i#1 [phi:main::@4->main::line2_@1#2] -- register_copy jmp line2___b1 // main::line1_@2 line1___b2: // plot(>pos, ch) // [19] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 -- vbuaa=_hi_vwuz1 lda.z line1_pos+1 // main::plot1 // *(cur_line+xpos) = ch // [20] *((byte*) cur_line#13 + (byte) main::plot1_xpos#0) ← (const byte) main::line1_ch#0 -- pbuz1_derefidx_vbuaa=vbuc1 tay lda #line1_ch sta (cur_line),y // main::@3 // pos += xadd // [21] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 -- vwuz1=vwuz1_plus_vbuc1 lda #line1_xadd clc adc.z line1_pos sta.z line1_pos bcc !+ inc.z line1_pos+1 !: // cur_line += 40 // [22] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 lda #$28 clc adc.z cur_line sta.z cur_line bcc !+ inc.z cur_line+1 !: // for( byte i=0;imain::line1_@1] // [8] phi (byte*) cur_line#13 = (byte*) cur_line#1 [phi:main::@3->main::line1_@1#0] -- register_copy // [8] phi (word) main::line1_pos#2 = (word) main::line1_pos#1 [phi:main::@3->main::line1_@1#1] -- register_copy // [8] phi (byte) main::line1_i#2 = (byte) main::line1_i#1 [phi:main::@3->main::line1_@1#2] -- register_copy jmp line1___b1 // main::@2 __b2: // *sc = ' ' // [24] *((byte*) main::sc#2) ← (byte) ' ' -- _deref_pbuz1=vbuc1 lda #' ' ldy #0 sta (sc),y // for(byte* sc = $400;sc<$400+1000;sc++) // [25] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 inc.z sc bne !+ inc.z sc+1 !: // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] // [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@2->main::@1#0] -- register_copy jmp __b1 } // File Data