Culled Empty Block (label) main::@2

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

(void()) main()
main: scope:[main]  from @1
  (byte*) main::screen ← (byte*)(number) $400
  (byte) main::i ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  *((byte*) main::screen) ← (byte) 'a'
  (byte*) main::screen ← ++ (byte*) main::screen
  (byte) main::i ← (byte) main::i + rangenext(0,5)
  (bool~) main::$0 ← (byte) main::i != rangelast(0,5)
  if((bool~) main::$0) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  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
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@return
(byte) main::i loadstore
(byte*) main::screen loadstore

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

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end

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] (byte*) main::screen ← (byte*) 1024
  [5] (byte) main::i ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [6] *((byte*) main::screen) ← (byte) 'a'
  [7] (byte*) main::screen ← ++ (byte*) main::screen
  [8] (byte) main::i ← ++ (byte) main::i
  [9] if((byte) main::i!=(byte) 6) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::i loadstore 7.000000000000001
(byte*) main::screen loadstore 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 zp[2]:2 [ main::screen ]
Allocated mem[1] [ main::i ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Test memory model multiple-assignment/main memory for all non-pointer variables
  // 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 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label screen = 2
    // [4] (byte*) main::screen ← (byte*) 1024 -- pbuz1=pbuc1 
    // A local pointer 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    // [5] (byte) main::i ← (byte) 0 -- vbum1=vbuc1 
    lda #0
    sta i
    jmp __b1
  // A local counter
    // main::@1
  __b1:
    // [6] *((byte*) main::screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    // [7] (byte*) main::screen ← ++ (byte*) main::screen -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // [8] (byte) main::i ← ++ (byte) main::i -- vbum1=_inc_vbum1 
    inc i
    // [9] if((byte) main::i!=(byte) 6) goto main::@1 -- vbum1_neq_vbuc1_then_la1 
    lda #6
    cmp i
    bne __b1
    jmp __breturn
    // main::@return
  __breturn:
    // [10] return 
    rts
    i: .byte 0
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] (byte*) main::screen ← (byte*) 1024 [ main::screen ] ( main:2 [ main::screen ] ) always clobbers reg byte a 
Statement [5] (byte) main::i ← (byte) 0 [ main::screen main::i ] ( main:2 [ main::screen main::i ] ) always clobbers reg byte a 
Statement [6] *((byte*) main::screen) ← (byte) 'a' [ main::screen main::i ] ( main:2 [ main::screen main::i ] ) always clobbers reg byte a reg byte y 
Statement [9] if((byte) main::i!=(byte) 6) goto main::@1 [ main::screen main::i ] ( main:2 [ main::screen main::i ] ) always clobbers reg byte a 
Potential registers zp[2]:2 [ main::screen ] : zp[2]:2 , 
Potential registers mem[1] [ main::i ] : mem[1] , 

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

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

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test memory model multiple-assignment/main memory for all non-pointer variables
  // 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 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label screen = 2
    // [4] (byte*) main::screen ← (byte*) 1024 -- pbuz1=pbuc1 
    // A local pointer 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    // [5] (byte) main::i ← (byte) 0 -- vbum1=vbuc1 
    lda #0
    sta i
    jmp __b1
  // A local counter
    // main::@1
  __b1:
    // [6] *((byte*) main::screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    // [7] (byte*) main::screen ← ++ (byte*) main::screen -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // [8] (byte) main::i ← ++ (byte) main::i -- vbum1=_inc_vbum1 
    inc i
    // [9] if((byte) main::i!=(byte) 6) goto main::@1 -- vbum1_neq_vbuc1_then_la1 
    lda #6
    cmp i
    bne __b1
    jmp __breturn
    // main::@return
  __breturn:
    // [10] return 
    rts
    i: .byte 0
}
  // File Data

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

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@return
(byte) main::i loadstore mem[1] 7.000000000000001
(byte*) main::screen loadstore zp[2]:2 5.833333333333333

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


FINAL ASSEMBLER
Score: 392

  // File Comments
// Test memory model multiple-assignment/main memory for all non-pointer variables
  // 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 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label screen = 2
    // screen = 0x0400
    // [4] (byte*) main::screen ← (byte*) 1024 -- pbuz1=pbuc1 
    // A local pointer 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    // for( char i: 0..5 )
    // [5] (byte) main::i ← (byte) 0 -- vbum1=vbuc1 
    lda #0
    sta i
  // A local counter
    // main::@1
  __b1:
    // *(screen++) = 'a'
    // [6] *((byte*) main::screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    // *(screen++) = 'a';
    // [7] (byte*) main::screen ← ++ (byte*) main::screen -- pbuz1=_inc_pbuz1 
    inc.z screen
    bne !+
    inc.z screen+1
  !:
    // for( char i: 0..5 )
    // [8] (byte) main::i ← ++ (byte) main::i -- vbum1=_inc_vbum1 
    inc i
    // [9] if((byte) main::i!=(byte) 6) goto main::@1 -- vbum1_neq_vbuc1_then_la1 
    lda #6
    cmp i
    bne __b1
    // main::@return
    // }
    // [10] return 
    rts
    i: .byte 0
}
  // File Data

