
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::i = 3
  to:main::@1
main::@1: scope:[main]  from main main::@2
  main::$0 = main::i < 7
  if(main::$0) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  SCREEN[main::i] = main::i
  main::i = ++ main::i
  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
__constant char * const SCREEN = (char *)$400
void __start()
void main()
bool main::$0
__loadstore char main::i // !zp[-1]:2

Adding number conversion cast (unumber) 7 in main::$0 = main::i < 7
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 7
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 7
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition main::$0 [2] if(main::i<7) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
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
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] main::i = 3
  to:main::@1
main::@1: scope:[main]  from main main::@2
  [1] if(main::i<7) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@1
  [2] return 
  to:@return
main::@2: scope:[main]  from main::@1
  [3] SCREEN[main::i] = main::i
  [4] main::i = ++ main::i
  to:main::@1


VARIABLE REGISTER WEIGHTS
void main()
__loadstore char main::i // !zp[-1]:2 14.25

Initial phi equivalence classes
Added variable main::i to live range equivalence class [ main::i ]
Complete equivalence classes
[ main::i ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] main::i = 3 [ main::i ] (  [ main::i ] { }  ) always clobbers reg byte a 
Statement [1] if(main::i<7) goto main::@2 [ main::i ] (  [ main::i ] { }  ) always clobbers reg byte a 
Statement [3] SCREEN[main::i] = main::i [ main::i ] (  [ main::i ] { }  ) always clobbers reg byte a reg byte y 
Potential registers zp[1]:2 [ main::i ] : zp[1]:2 , 

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

Uplifting [main] best 299 combination zp[1]:2 [ main::i ] 
Uplifting [] best 299 combination 
Attempting to uplift remaining variables inzp[1]:2 [ main::i ]
Uplifting [main] best 299 combination zp[1]:2 [ main::i ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test that address vars are turned into load/store and located at hardcoded addresses
// Hard-coded zero-page address - local variable
  // Upstart
  // Commodore 64 PRG executable file
.file [name="address-1.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
  .label SCREEN = $400
.segment Code
  // main
main: {
    .label i = 2
    // [0] main::i = 3 -- vbuz1=vbuc1 
    lda #3
    sta.z i
    jmp __b1
    // main::@1
  __b1:
    // [1] if(main::i<7) goto main::@2 -- vbuz1_lt_vbuc1_then_la1 
    lda.z i
    cmp #7
    bcc __b2
    jmp __breturn
    // main::@return
  __breturn:
    // [2] return 
    rts
    // main::@2
  __b2:
    // [3] SCREEN[main::i] = main::i -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy.z i
    tya
    sta SCREEN,y
    // [4] main::i = ++ main::i -- vbuz1=_inc_vbuz1 
    inc.z i
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const SCREEN = (char *) 1024
void main()
__loadstore char main::i // !zp[-1]:2 zp[1]:2 14.25

zp[1]:2 [ main::i ]


FINAL ASSEMBLER
Score: 266

  // File Comments
// Test that address vars are turned into load/store and located at hardcoded addresses
// Hard-coded zero-page address - local variable
  // Upstart
  // Commodore 64 PRG executable file
.file [name="address-1.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
  .label SCREEN = $400
.segment Code
  // main
main: {
    .label i = 2
    // char __address(0x02) i = 3
    // [0] main::i = 3 -- vbuz1=vbuc1 
    lda #3
    sta.z i
    // main::@1
  __b1:
    // while(i<7)
    // [1] if(main::i<7) goto main::@2 -- vbuz1_lt_vbuc1_then_la1 
    lda.z i
    cmp #7
    bcc __b2
    // main::@return
    // }
    // [2] return 
    rts
    // main::@2
  __b2:
    // SCREEN[i++] = i
    // [3] SCREEN[main::i] = main::i -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy.z i
    tya
    sta SCREEN,y
    // SCREEN[i++] = i;
    // [4] main::i = ++ main::i -- vbuz1=_inc_vbuz1 
    inc.z i
    jmp __b1
}
  // File Data

