
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::screen = (char *)$400
  main::i = 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  *main::screen = 'a'
  main::screen = ++ main::screen
  main::i = main::i + rangenext(0,5)
  main::$0 = main::i != rangelast(0,5)
  if(main::$0) 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::$0
__loadstore char main::i
__loadstore char *main::screen

Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Simple Condition main::$0 [6] if(main::i!=rangelast(0,5)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Resolved ranged next value [4] main::i = ++ main::i to ++
Resolved ranged comparison value [6] if(main::i!=rangelast(0,5)) goto main::@1 to 6
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) 6 in [5] if(main::i!=6) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 6
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 6
Successful SSA optimization PassNFinalizeNumberTypeConversions
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::screen = (char *) 1024
  [1] main::i = 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [2] *main::screen = 'a'
  [3] main::screen = ++ main::screen
  [4] main::i = ++ main::i
  [5] if(main::i!=6) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  [6] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
__loadstore char main::i // 7.000000000000001
__loadstore char *main::screen // 5.833333333333333

Initial phi equivalence classes
Added variable main::screen to live range equivalence class [ main::screen ]
Added variable main::i to live range equivalence class [ main::i ]
Complete equivalence classes
[ main::screen ]
[ main::i ]
Allocated mem[1] [ main::i ]
Allocated mem[2] [ main::screen ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] main::screen = (char *) 1024 [ main::screen ] (  [ main::screen ] { }  ) always clobbers reg byte a 
Statement [1] main::i = 0 [ main::screen main::i ] (  [ main::screen main::i ] { }  ) always clobbers reg byte a 
Statement [2] *main::screen = 'a' [ main::screen main::i ] (  [ main::screen main::i ] { }  ) always clobbers reg byte a reg byte y 
Statement [5] if(main::i!=6) goto main::@1 [ main::screen main::i ] (  [ main::screen main::i ] { }  ) always clobbers reg byte a 
Potential registers mem[2] [ main::screen ] : mem[2] , 
Potential registers mem[1] [ main::i ] : mem[1] , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 7: mem[1] [ main::i ] 5.83: mem[2] [ main::screen ] 
Uplift Scope [] 

Uplifting [main] best 587 combination mem[1] [ main::i ] mem[2] [ main::screen ] 
Uplifting [] best 587 combination 
Attempting to uplift remaining variables inmem[1] [ main::i ]
Uplifting [main] best 587 combination mem[1] [ main::i ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test memory model multiple-assignment/main memory for all variables (here  local variables)
  // Upstart
  // Commodore 64 PRG executable file
.file [name="varmodel-ma_mem.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: {
    // [0] main::screen = (char *) 1024 -- pbum1=pbuc1 
    // A local pointer 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
    // [1] main::i = 0 -- vbum1=vbuc1 
    lda #0
    sta i
    jmp __b1
  // A local counter
    // main::@1
  __b1:
    // [2] *main::screen = 'a' -- _deref_pbum1=vbuc1 
    lda #'a'
    ldy screen
    sty.z $fe
    ldy screen+1
    sty.z $ff
    ldy #0
    sta ($fe),y
    // [3] main::screen = ++ main::screen -- pbum1=_inc_pbum1 
    inc screen
    bne !+
    inc screen+1
  !:
    // [4] main::i = ++ main::i -- vbum1=_inc_vbum1 
    inc i
    // [5] if(main::i!=6) goto main::@1 -- vbum1_neq_vbuc1_then_la1 
    lda #6
    cmp i
    bne __b1
    jmp __breturn
    // main::@return
  __breturn:
    // [6] return 
    rts
  .segment Data
    screen: .word 0
    i: .byte 0
}
  // 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
void main()
__loadstore char main::i // mem[1] 7.000000000000001
__loadstore char *main::screen // mem[2] 5.833333333333333

mem[2] [ main::screen ]
mem[1] [ main::i ]


FINAL ASSEMBLER
Score: 554

  // File Comments
// Test memory model multiple-assignment/main memory for all variables (here  local variables)
  // Upstart
  // Commodore 64 PRG executable file
.file [name="varmodel-ma_mem.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: {
    // char* screen = (char*)0x0400
    // [0] main::screen = (char *) 1024 -- pbum1=pbuc1 
    // A local pointer 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
    // for( char i: 0..5 )
    // [1] main::i = 0 -- vbum1=vbuc1 
    lda #0
    sta i
  // A local counter
    // main::@1
  __b1:
    // *(screen++) = 'a'
    // [2] *main::screen = 'a' -- _deref_pbum1=vbuc1 
    lda #'a'
    ldy screen
    sty.z $fe
    ldy screen+1
    sty.z $ff
    ldy #0
    sta ($fe),y
    // *(screen++) = 'a';
    // [3] main::screen = ++ main::screen -- pbum1=_inc_pbum1 
    inc screen
    bne !+
    inc screen+1
  !:
    // for( char i: 0..5 )
    // [4] main::i = ++ main::i -- vbum1=_inc_vbum1 
    inc i
    // [5] if(main::i!=6) goto main::@1 -- vbum1_neq_vbuc1_then_la1 
    lda #6
    cmp i
    bne __b1
    // main::@return
    // }
    // [6] return 
    rts
  .segment Data
    screen: .word 0
    i: .byte 0
}
  // File Data

