Eliminating unused variable with no statement main::$2

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::lo#0 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@5
  main::lo#2 = phi( main/main::lo#0, main::@5/main::lo#1 )
  main::$0 = main::lo#2 < $64
  if(main::$0) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  main::lo#6 = phi( main::@1/main::lo#2 )
  main::hi#0 = 0
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@4
  main::lo#5 = phi( main::@2/main::lo#6, main::@4/main::lo#3 )
  main::hi#2 = phi( main::@2/main::hi#0, main::@4/main::hi#1 )
  main::$1 = main::hi#2 < $64
  if(main::$1) goto main::@4
  to:main::@5
main::@4: scope:[main]  from main::@3
  main::lo#3 = phi( main::@3/main::lo#5 )
  main::hi#3 = phi( main::@3/main::hi#2 )
  main::i#0 = main::hi#3 w= main::lo#3
  *main::SCREEN = main::i#0
  main::hi#1 = ++ main::hi#3
  to:main::@3
main::@5: scope:[main]  from main::@3
  main::lo#4 = phi( main::@3/main::lo#5 )
  main::lo#1 = ++ main::lo#4
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  call main
  to:__start::@1
__start::@1: scope:[__start]  from __start
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  return 
  to:@return

SYMBOL TABLE SSA
void __start()
void main()
bool main::$0
bool main::$1
__constant unsigned int * const main::SCREEN = (unsigned int *)$400
char main::hi
char main::hi#0
char main::hi#1
char main::hi#2
char main::hi#3
unsigned int main::i
unsigned int main::i#0
char main::lo
char main::lo#0
char main::lo#1
char main::lo#2
char main::lo#3
char main::lo#4
char main::lo#5
char main::lo#6

Adding number conversion cast (unumber) $64 in main::$0 = main::lo#2 < $64
Adding number conversion cast (unumber) $64 in main::$1 = main::hi#2 < $64
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (unsigned int *) 1024
Simplifying constant integer cast $64
Simplifying constant integer cast $64
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $64
Finalized unsigned number type (char) $64
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::lo#2 = main::lo#6 
Alias main::hi#2 = main::hi#3 
Alias main::lo#3 = main::lo#5 main::lo#4 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values main::lo#3 main::lo#2
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition main::$0 [3] if(main::lo#2<$64) goto main::@2
Simple Condition main::$1 [7] if(main::hi#2<$64) goto main::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::lo#0 = 0
Constant main::hi#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Inlining constant with var siblings main::lo#0
Inlining constant with var siblings main::hi#0
Constant inlined main::lo#0 = 0
Constant inlined main::hi#0 = 0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
CALL GRAPH

Created 2 initial phi equivalence classes
Coalesced [8] main::lo#7 = main::lo#1
Coalesced [12] main::hi#4 = main::hi#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block label main::@2
Renumbering block main::@3 to main::@2
Renumbering block main::@4 to main::@3
Renumbering block main::@5 to main::@4
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@4
  [1] main::lo#2 = phi( main/0, main::@4/main::lo#1 )
  [2] if(main::lo#2<$64) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@1
  [3] return 
  to:@return
main::@2: scope:[main]  from main::@1 main::@3
  [4] main::hi#2 = phi( main::@1/0, main::@3/main::hi#1 )
  [5] if(main::hi#2<$64) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@2
  [6] main::lo#1 = ++ main::lo#2
  to:main::@1
main::@3: scope:[main]  from main::@2
  [7] main::i#0 = main::hi#2 w= main::lo#2
  [8] *main::SCREEN = main::i#0
  [9] main::hi#1 = ++ main::hi#2
  to:main::@2


VARIABLE REGISTER WEIGHTS
void main()
char main::hi
char main::hi#1 // 202.0
char main::hi#2 // 101.0
unsigned int main::i
unsigned int main::i#0 // 202.0
char main::lo
char main::lo#1 // 22.0
char main::lo#2 // 19.142857142857142

Initial phi equivalence classes
[ main::lo#2 main::lo#1 ]
[ main::hi#2 main::hi#1 ]
Added variable main::i#0 to live range equivalence class [ main::i#0 ]
Complete equivalence classes
[ main::lo#2 main::lo#1 ]
[ main::hi#2 main::hi#1 ]
[ main::i#0 ]
Allocated zp[1]:2 [ main::hi#2 main::hi#1 ]
Allocated zp[2]:3 [ main::i#0 ]
Allocated zp[1]:5 [ main::lo#2 main::lo#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [8] *main::SCREEN = main::i#0 [ main::lo#2 main::hi#2 ] (  [ main::lo#2 main::hi#2 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::lo#2 main::lo#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::hi#2 main::hi#1 ]
Statement [8] *main::SCREEN = main::i#0 [ main::lo#2 main::hi#2 ] (  [ main::lo#2 main::hi#2 ] { }  ) always clobbers reg byte a 
Potential registers zp[1]:5 [ main::lo#2 main::lo#1 ] : zp[1]:5 , reg byte x , reg byte y , 
Potential registers zp[1]:2 [ main::hi#2 main::hi#1 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[2]:3 [ main::i#0 ] : zp[2]:3 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 303: zp[1]:2 [ main::hi#2 main::hi#1 ] 202: zp[2]:3 [ main::i#0 ] 41.14: zp[1]:5 [ main::lo#2 main::lo#1 ] 
Uplift Scope [] 

Uplifting [main] best 3931 combination reg byte y [ main::hi#2 main::hi#1 ] zp[2]:3 [ main::i#0 ] reg byte x [ main::lo#2 main::lo#1 ] 
Uplifting [] best 3931 combination 
Allocated (was zp[2]:3) zp[2]:2 [ main::i#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test MAKEWORD()
  // Upstart
  // Commodore 64 PRG executable file
.file [name="makeword-0.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
.segment Code
  // main
main: {
    .label SCREEN = $400
    .label i = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::lo#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // main::@1
  __b1:
    // [2] if(main::lo#2<$64) goto main::@2 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$64
    bcc __b2_from___b1
    jmp __breturn
    // main::@return
  __breturn:
    // [3] return 
    rts
    // [4] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [4] phi main::hi#2 = 0 [phi:main::@1->main::@2#0] -- vbuyy=vbuc1 
    ldy #0
    jmp __b2
    // main::@2
  __b2:
    // [5] if(main::hi#2<$64) goto main::@3 -- vbuyy_lt_vbuc1_then_la1 
    cpy #$64
    bcc __b3
    jmp __b4
    // main::@4
  __b4:
    // [6] main::lo#1 = ++ main::lo#2 -- vbuxx=_inc_vbuxx 
    inx
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  __b1_from___b4:
    // [1] phi main::lo#2 = main::lo#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp __b1
    // main::@3
  __b3:
    // [7] main::i#0 = main::hi#2 w= main::lo#2 -- vwuz1=vbuyy_word_vbuxx 
    sty.z i+1
    stx.z i
    // [8] *main::SCREEN = main::i#0 -- _deref_pwuc1=vwuz1 
    lda.z i
    sta SCREEN
    lda.z i+1
    sta SCREEN+1
    // [9] main::hi#1 = ++ main::hi#2 -- vbuyy=_inc_vbuyy 
    iny
    // [4] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  __b2_from___b3:
    // [4] phi main::hi#2 = main::hi#1 [phi:main::@3->main::@2#0] -- register_copy 
    jmp __b2
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b2
Removing instruction jmp __b4
Succesful ASM optimization Pass5NextJumpElimination
Replacing instruction lda.z i with TXA
Replacing instruction lda.z i+1 with TYA
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b4:
Removing instruction __b1_from___b4:
Removing instruction __b2_from___b3:
Succesful ASM optimization Pass5UnusedLabelElimination
Relabelling long label __b2_from___b1 to __b4
Succesful ASM optimization Pass5RelabelLongLabels

FINAL SYMBOL TABLE
void main()
__constant unsigned int * const main::SCREEN = (unsigned int *) 1024
char main::hi
char main::hi#1 // reg byte y 202.0
char main::hi#2 // reg byte y 101.0
unsigned int main::i
unsigned int main::i#0 // i zp[2]:2 202.0
char main::lo
char main::lo#1 // reg byte x 22.0
char main::lo#2 // reg byte x 19.142857142857142

reg byte x [ main::lo#2 main::lo#1 ]
reg byte y [ main::hi#2 main::hi#1 ]
zp[2]:2 [ main::i#0 ]


FINAL ASSEMBLER
Score: 3071

  // File Comments
// Test MAKEWORD()
  // Upstart
  // Commodore 64 PRG executable file
.file [name="makeword-0.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
.segment Code
  // main
main: {
    .label SCREEN = $400
    .label i = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::lo#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // main::@1
  __b1:
    // for(char lo=0;lo<100;lo++)
    // [2] if(main::lo#2<$64) goto main::@2 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$64
    bcc __b4
    // main::@return
    // }
    // [3] return 
    rts
    // [4] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b4:
    // [4] phi main::hi#2 = 0 [phi:main::@1->main::@2#0] -- vbuyy=vbuc1 
    ldy #0
    // main::@2
  __b2:
    // for(char hi=0;hi<100;hi++)
    // [5] if(main::hi#2<$64) goto main::@3 -- vbuyy_lt_vbuc1_then_la1 
    cpy #$64
    bcc __b3
    // main::@4
    // for(char lo=0;lo<100;lo++)
    // [6] main::lo#1 = ++ main::lo#2 -- vbuxx=_inc_vbuxx 
    inx
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
    // [1] phi main::lo#2 = main::lo#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp __b1
    // main::@3
  __b3:
    // unsigned int i = MAKEWORD(hi, lo)
    // [7] main::i#0 = main::hi#2 w= main::lo#2 -- vwuz1=vbuyy_word_vbuxx 
    sty.z i+1
    stx.z i
    // *SCREEN = i
    // [8] *main::SCREEN = main::i#0 -- _deref_pwuc1=vwuz1 
    txa
    sta SCREEN
    tya
    sta SCREEN+1
    // for(char hi=0;hi<100;hi++)
    // [9] main::hi#1 = ++ main::hi#2 -- vbuyy=_inc_vbuyy 
    iny
    // [4] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
    // [4] phi main::hi#2 = main::hi#1 [phi:main::@3->main::@2#0] -- register_copy 
    jmp __b2
}
  // File Data

