Culled Empty Block (label) main::@1

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1

(void()) main()
main: scope:[main]  from @1
  (byte) main::temp#0 ← (byte) 0
  (byte) main::i#0 ← (byte) 0
  to:main::@2
main::@2: scope:[main]  from main main::@3
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
  (bool~) main::$2 ← *((const byte*) ball_active + (byte) main::i#2) < (number) 0
  (bool~) main::$3 ← ! (bool~) main::$2
  if((bool~) main::$3) goto main::@3
  to:main::@4
main::@3: scope:[main]  from main::@2 main::@4
  (byte) main::i#3 ← phi( main::@2/(byte) main::i#2 main::@4/(byte) main::i#4 )
  (byte) main::temp#1 ← *((const byte*) ball_active + (byte) main::i#3)
  (byte) main::i#1 ← (byte) main::i#3 + rangenext(0,7)
  (bool~) main::$4 ← (byte) main::i#1 != rangelast(0,7)
  if((bool~) main::$4) goto main::@2
  to:main::@5
main::@4: scope:[main]  from main::@2
  (byte) main::i#4 ← phi( main::@2/(byte) main::i#2 )
  *((const byte*) main::screen + (byte) main::i#4) ← (byte) '-'
  to:main::@3
main::@5: scope:[main]  from main::@3
  (byte) main::temp#2 ← phi( main::@3/(byte) main::temp#1 )
  (bool~) main::$0 ← (byte) main::temp#2 < (number) 0
  (bool~) main::$1 ← ! (bool~) main::$0
  if((bool~) main::$1) goto main::@return
  to:main::@6
main::@6: scope:[main]  from main::@5
  (byte) main::temp#3 ← phi( main::@5/(byte) main::temp#2 )
  *((const byte*) main::screen + (number) $28) ← (byte) main::temp#3
  to:main::@return
main::@return: scope:[main]  from main::@5 main::@6
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte*) ball_active[(number) 8]  = { (byte) 0, (byte) 1, (byte) 0, (byte) 1, (byte) 0, (byte) 1, (byte) 1, (byte) 1 }
(void()) main()
(bool~) main::$0
(bool~) main::$1
(bool~) main::$2
(bool~) main::$3
(bool~) main::$4
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::i#4
(const byte*) main::screen = (byte*)(number) $400
(byte) main::temp
(byte) main::temp#0
(byte) main::temp#1
(byte) main::temp#2
(byte) main::temp#3

Adding number conversion cast (unumber) 0 in (bool~) main::$2 ← *((const byte*) ball_active + (byte) main::i#2) < (number) 0
Adding number conversion cast (unumber) 0 in (bool~) main::$0 ← (byte) main::temp#2 < (number) 0
Adding number conversion cast (unumber) $28 in *((const byte*) main::screen + (number) $28) ← (byte) main::temp#3
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast $28
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $28
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [4] (bool~) main::$3 ← *((const byte*) ball_active + (byte) main::i#2) >= (byte) 0 from [3] (bool~) main::$2 ← *((const byte*) ball_active + (byte) main::i#2) < (byte) 0
Inversing boolean not [15] (bool~) main::$1 ← (byte) main::temp#2 >= (byte) 0 from [14] (bool~) main::$0 ← (byte) main::temp#2 < (byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) main::i#2 = (byte) main::i#4 
Alias (byte) main::temp#1 = (byte) main::temp#2 (byte) main::temp#3 
Successful SSA optimization Pass2AliasElimination
Alias (byte) main::i#2 = (byte) main::i#3 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$3 [5] if(*((const byte*) ball_active + (byte) main::i#2)>=(byte) 0) goto main::@3
Simple Condition (bool~) main::$4 [10] if((byte) main::i#1!=rangelast(0,7)) goto main::@2
Simple Condition (bool~) main::$1 [16] if((byte) main::temp#1>=(byte) 0) goto main::@return
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::temp#0 = 0
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [5] if(*((const byte*) ball_active + (byte) main::i#2)>=(byte) 0) goto main::@3
if() condition always true - replacing block destination [16] if((byte) main::temp#1>=(byte) 0) goto main::@return
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [8] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [10] if(main::i#1!=rangelast(0,7)) goto main::@2 to (number) 8
Eliminating unused constant (const byte) main::temp#0
Successful SSA optimization PassNEliminateUnusedVars
Removing unused block main::@4
Removing unused block main::@6
Successful SSA optimization Pass2EliminateUnusedBlocks
Adding number conversion cast (unumber) 8 in if((byte) main::i#1!=(number) 8) goto main::@2
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 8
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Eliminating unused variable (byte) main::temp#1 and assignment [1] (byte) main::temp#1 ← *((const byte*) ball_active + (byte) main::i#2)
Eliminating unused constant (const byte*) main::screen
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const byte*) ball_active
Successful SSA optimization PassNEliminateUnusedVars
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@7(between main::@3 and main::@2)
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 @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@5
CALL GRAPH
Calls in [] to main:2 

Created 1 initial phi equivalence classes
Coalesced [11] main::i#5 ← main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@7
Renumbering block main::@2 to main::@1
Renumbering block main::@3 to main::@2
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

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::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1
  [6] (byte) main::i#1 ← ++ (byte) main::i#2
  [7] if((byte) main::i#1!=(byte) 8) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 22.0
(byte) main::temp

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Examples of unsigned comparisons to values outside the range of unsigned
// These should be optimized to constants
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @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: {
    .label i = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    jmp __b1
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    jmp __b2
    // main::@2
  __b2:
    // [6] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [7] if((byte) main::i#1!=(byte) 8) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z i
    bne __b1_from___b2
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 38.5: zp[1]:2 [ main::i#2 main::i#1 ] 
Uplift Scope [] 

Uplifting [main] best 223 combination reg byte x [ main::i#2 main::i#1 ] 
Uplifting [] best 223 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Examples of unsigned comparisons to values outside the range of unsigned
// These should be optimized to constants
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @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: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    jmp __b2
    // main::@2
  __b2:
    // [6] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [7] if((byte) main::i#1!=(byte) 8) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne __b1_from___b2
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b1 with __b2
Replacing label __b1_from___b2 with __b2
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b2:
Removing instruction __b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp __b2
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 22.0
(byte) main::temp

reg byte x [ main::i#2 main::i#1 ]


FINAL ASSEMBLER
Score: 91

  // File Comments
// Examples of unsigned comparisons to values outside the range of unsigned
// These should be optimized to constants
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  // @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: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy 
    // main::@1
    // main::@2
  __b2:
    // for( char i: 0..7)
    // [6] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [7] if((byte) main::i#1!=(byte) 8) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne __b2
    // main::@return
    // }
    // [8] return 
    rts
}
  // File Data

