Eliminating unused variable with no statement main::$0

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::i#0 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  main::i#2 = phi( main/main::i#0, main::@1/main::i#1 )
  main::b#0 = main::a + main::i#2
  main::c#0 = (char)main::b#0
  main::SCREEN[main::i#2] = main::c#0
  main::i#1 = main::i#2 + rangenext(0,$64)
  main::$1 = main::i#1 != rangelast(0,$64)
  if(main::$1) goto main::@1
  to:main::@return
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::$1
__constant char * const main::SCREEN = (char *)$400
__constant unsigned long main::a = $ee6b2800
unsigned long main::b
unsigned long main::b#0
char main::c
char main::c#0
char main::i
char main::i#0
char main::i#1
char main::i#2

Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Simple Condition main::$1 [7] if(main::i#1!=rangelast(0,$64)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [5] main::i#1 = ++ main::i#2 to ++
Resolved ranged comparison value [7] if(main::i#1!=rangelast(0,$64)) goto main::@1 to $65
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
Adding number conversion cast (unumber) $65 in [5] if(main::i#1!=$65) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $65
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $65
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings main::i#0
Constant inlined main::i#0 = 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@2(between main::@1 and main::@1)
Adding NOP phi() at start of main
CALL GRAPH

Created 1 initial phi equivalence classes
Coalesced [8] main::i#3 = main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block label main::@2
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::@1
  [1] main::i#2 = phi( main/0, main::@1/main::i#1 )
  [2] main::b#0 = main::a + main::i#2
  [3] main::c#0 = (char)main::b#0
  [4] main::SCREEN[main::i#2] = main::c#0
  [5] main::i#1 = ++ main::i#2
  [6] if(main::i#1!=$65) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  [7] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
unsigned long main::b
unsigned long main::b#0 // 11.0
char main::c
char main::c#0 // 22.0
char main::i
char main::i#1 // 16.5
char main::i#2 // 11.0

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

REGISTER UPLIFT SCOPES
Uplift Scope [main] 27.5: zp[1]:2 [ main::i#2 main::i#1 ] 22: zp[1]:3 [ main::c#0 ] 11: zp[4]:4 [ main::b#0 ] 
Uplift Scope [] 

Uplifting [main] best 561 combination reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::c#0 ] zp[4]:4 [ main::b#0 ] 
Uplifting [] best 561 combination 
Allocated (was zp[4]:4) zp[4]:2 [ main::b#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="dword.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: {
    .const a = $ee6b2800
    .label SCREEN = $400
    .label b = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  __b1_from___b1:
    // [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [2] main::b#0 = main::a + main::i#2 -- vduz1=vduc1_plus_vbuxx 
    txa
    clc
    adc #<a
    sta.z b
    lda #>a
    adc #0
    sta.z b+1
    lda #<a>>$10
    adc #0
    sta.z b+2
    lda #>a>>$10
    adc #0
    sta.z b+3
    // [3] main::c#0 = (char)main::b#0 -- vbuaa=_byte_vduz1 
    lda.z b
    // [4] main::SCREEN[main::i#2] = main::c#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // [5] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [6] if(main::i#1!=$65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne __b1_from___b1
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b1 with __b1
Removing instruction __b1_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
void main()
__constant char * const main::SCREEN = (char *) 1024
__constant unsigned long main::a = $ee6b2800
unsigned long main::b
unsigned long main::b#0 // b zp[4]:2 11.0
char main::c
char main::c#0 // reg byte a 22.0
char main::i
char main::i#1 // reg byte x 16.5
char main::i#2 // reg byte x 11.0

reg byte x [ main::i#2 main::i#1 ]
zp[4]:2 [ main::b#0 ]
reg byte a [ main::c#0 ]


FINAL ASSEMBLER
Score: 471

  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="dword.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: {
    .const a = $ee6b2800
    .label SCREEN = $400
    .label b = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
    // [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // main::@1
  __b1:
    // dword b = a + i
    // [2] main::b#0 = main::a + main::i#2 -- vduz1=vduc1_plus_vbuxx 
    txa
    clc
    adc #<a
    sta.z b
    lda #>a
    adc #0
    sta.z b+1
    lda #<a>>$10
    adc #0
    sta.z b+2
    lda #>a>>$10
    adc #0
    sta.z b+3
    // byte c = (byte) b
    // [3] main::c#0 = (char)main::b#0 -- vbuaa=_byte_vduz1 
    lda.z b
    // SCREEN[i] = c
    // [4] main::SCREEN[main::i#2] = main::c#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // for( byte i: 0..100)
    // [5] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [6] if(main::i#1!=$65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne __b1
    // main::@return
    // }
    // [7] return 
    rts
}
  // File Data

