Culled Empty Block (label) @1

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@2
main: scope:[main]  from @2
  (byte) puta::ph#0 ← (number) 4
  (byte) puta::pl#0 ← (number) 0
  call puta 
  to:main::@1
main::@1: scope:[main]  from main
  (byte) puta::ph#1 ← (number) 5
  (byte) puta::pl#1 ← (number) $18
  call puta 
  to:main::@2
main::@2: scope:[main]  from main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return
puta: scope:[puta]  from main main::@1
  (byte) puta::pl#2 ← phi( main/(byte) puta::pl#0 main::@1/(byte) puta::pl#1 )
  (byte) puta::ph#2 ← phi( main/(byte) puta::ph#0 main::@1/(byte) puta::ph#1 )
  (byte*~) puta::$0 ← ((byte*)) { (byte) puta::ph#2, (byte) puta::pl#2 }
  (byte*) puta::screen#0 ← (byte*~) puta::$0
  *((byte*) puta::screen#0) ← (byte) 'a'
  to:puta::@return
puta::@return: scope:[puta]  from puta
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(void()) puta((byte) puta::ph , (byte) puta::pl)
(byte*~) puta::$0
(label) puta::@return
(byte) puta::ph
(byte) puta::ph#0
(byte) puta::ph#1
(byte) puta::ph#2
(byte) puta::pl
(byte) puta::pl#0
(byte) puta::pl#1
(byte) puta::pl#2
(byte*) puta::screen
(byte*) puta::screen#0

Fixing inline constructor with puta::$1 ← (byte)puta::ph#2 w= (byte)puta::pl#2
Successful SSA optimization Pass2FixInlineConstructors
Adding number conversion cast (unumber) 4 in (byte) puta::ph#0 ← (number) 4
Adding number conversion cast (unumber) 0 in (byte) puta::pl#0 ← (number) 0
Adding number conversion cast (unumber) 5 in (byte) puta::ph#1 ← (number) 5
Adding number conversion cast (unumber) $18 in (byte) puta::pl#1 ← (number) $18
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) puta::ph#0 ← (unumber)(number) 4
Inlining cast (byte) puta::pl#0 ← (unumber)(number) 0
Inlining cast (byte) puta::ph#1 ← (unumber)(number) 5
Inlining cast (byte) puta::pl#1 ← (unumber)(number) $18
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 4
Simplifying constant integer cast 0
Simplifying constant integer cast 5
Simplifying constant integer cast $18
Simplifying constant integer cast (byte) puta::ph#2
Simplifying constant integer cast (byte) puta::pl#2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 5
Finalized unsigned number type (byte) $18
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding pointer type conversion cast (byte*) puta::$0 in (byte*~) puta::$0 ← (word~) puta::$1
Successful SSA optimization PassNAddTypeConversionAssignment
Alias (byte*) puta::screen#0 = (byte*~) puta::$0 
Successful SSA optimization Pass2AliasElimination
Constant (const byte) puta::ph#0 = 4
Constant (const byte) puta::pl#0 = 0
Constant (const byte) puta::ph#1 = 5
Constant (const byte) puta::pl#1 = $18
Successful SSA optimization Pass2ConstantIdentification
Inlining cast (byte*) puta::screen#0 ← (byte*)(word~) puta::$1
Successful SSA optimization Pass2InlineCast
Inlining Noop Cast [5] (byte*) puta::screen#0 ← (byte*)(word~) puta::$1 keeping puta::screen#0
Successful SSA optimization Pass2NopCastInlining
Inlining constant with var siblings (const byte) puta::ph#0
Inlining constant with var siblings (const byte) puta::pl#0
Inlining constant with var siblings (const byte) puta::ph#1
Inlining constant with var siblings (const byte) puta::pl#1
Constant inlined puta::pl#0 = (byte) 0
Constant inlined puta::ph#1 = (byte) 5
Constant inlined puta::ph#0 = (byte) 4
Constant inlined puta::pl#1 = (byte) $18
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@2
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to puta:6 puta:8 

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

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()
main: scope:[main]  from @1
  [4] phi()
  [5] call puta 
  to:main::@1
main::@1: scope:[main]  from main
  [6] phi()
  [7] call puta 
  to:main::@return
main::@return: scope:[main]  from main::@1
  [8] return 
  to:@return
puta: scope:[puta]  from main main::@1
  [9] (byte) puta::pl#2 ← phi( main/(byte) 0 main::@1/(byte) $18 )
  [9] (byte) puta::ph#2 ← phi( main/(byte) 4 main::@1/(byte) 5 )
  [10] (word) puta::screen#0 ← (byte) puta::ph#2 w= (byte) puta::pl#2
  [11] *((byte*)(word) puta::screen#0) ← (byte) 'a'
  to:puta::@return
puta::@return: scope:[puta]  from puta
  [12] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(void()) puta((byte) puta::ph , (byte) puta::pl)
(byte) puta::ph
(byte) puta::ph#2 2.0
(byte) puta::pl
(byte) puta::pl#2 2.0
(byte*) puta::screen
(word) puta::screen#0 2.0

Initial phi equivalence classes
[ puta::ph#2 ]
[ puta::pl#2 ]
Added variable puta::screen#0 to zero page equivalence class [ puta::screen#0 ]
Complete equivalence classes
[ puta::ph#2 ]
[ puta::pl#2 ]
[ puta::screen#0 ]
Allocated zp ZP_BYTE:2 [ puta::ph#2 ]
Allocated zp ZP_BYTE:3 [ puta::pl#2 ]
Allocated zp ZP_WORD:4 [ puta::screen#0 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
// Tests creating a literal pointer from two bytes
  // 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 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    // [5] call puta 
    // [9] phi from main to puta [phi:main->puta]
  puta_from_main:
    // [9] phi (byte) puta::pl#2 = (byte) 0 [phi:main->puta#0] -- vbuz1=vbuc1 
    lda #0
    sta.z puta.pl
    // [9] phi (byte) puta::ph#2 = (byte) 4 [phi:main->puta#1] -- vbuz1=vbuc1 
    lda #4
    sta.z puta.ph
    jsr puta
    // [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    jmp b1
    // main::@1
  b1:
    // [7] call puta 
    // [9] phi from main::@1 to puta [phi:main::@1->puta]
  puta_from_b1:
    // [9] phi (byte) puta::pl#2 = (byte) $18 [phi:main::@1->puta#0] -- vbuz1=vbuc1 
    lda #$18
    sta.z puta.pl
    // [9] phi (byte) puta::ph#2 = (byte) 5 [phi:main::@1->puta#1] -- vbuz1=vbuc1 
    lda #5
    sta.z puta.ph
    jsr puta
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // puta
// puta(byte zeropage(2) ph, byte zeropage(3) pl)
puta: {
    .label screen = 4
    .label ph = 2
    .label pl = 3
    // [10] (word) puta::screen#0 ← (byte) puta::ph#2 w= (byte) puta::pl#2 -- vwuz1=vbuz2_word_vbuz3 
    lda.z ph
    sta.z screen+1
    lda.z pl
    sta.z screen
    // [11] *((byte*)(word) puta::screen#0) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    jmp breturn
    // puta::@return
  breturn:
    // [12] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [11] *((byte*)(word) puta::screen#0) ← (byte) 'a' [ ] ( main:2::puta:5 [ ] main:2::puta:7 [ ] ) always clobbers reg byte a reg byte y 
Potential registers zp ZP_BYTE:2 [ puta::ph#2 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ puta::pl#2 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:4 [ puta::screen#0 ] : zp ZP_WORD:4 , 

REGISTER UPLIFT SCOPES
Uplift Scope [puta] 2: zp ZP_BYTE:2 [ puta::ph#2 ] 2: zp ZP_BYTE:3 [ puta::pl#2 ] 2: zp ZP_WORD:4 [ puta::screen#0 ] 
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [puta] best 69 combination reg byte a [ puta::ph#2 ] reg byte x [ puta::pl#2 ] zp ZP_WORD:4 [ puta::screen#0 ] 
Uplifting [main] best 69 combination 
Uplifting [] best 69 combination 
Allocated (was zp ZP_WORD:4) zp ZP_WORD:2 [ puta::screen#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests creating a literal pointer from two bytes
  // 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 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    // [5] call puta 
    // [9] phi from main to puta [phi:main->puta]
  puta_from_main:
    // [9] phi (byte) puta::pl#2 = (byte) 0 [phi:main->puta#0] -- vbuxx=vbuc1 
    ldx #0
    // [9] phi (byte) puta::ph#2 = (byte) 4 [phi:main->puta#1] -- vbuaa=vbuc1 
    lda #4
    jsr puta
    // [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    jmp b1
    // main::@1
  b1:
    // [7] call puta 
    // [9] phi from main::@1 to puta [phi:main::@1->puta]
  puta_from_b1:
    // [9] phi (byte) puta::pl#2 = (byte) $18 [phi:main::@1->puta#0] -- vbuxx=vbuc1 
    ldx #$18
    // [9] phi (byte) puta::ph#2 = (byte) 5 [phi:main::@1->puta#1] -- vbuaa=vbuc1 
    lda #5
    jsr puta
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // puta
// puta(byte register(A) ph, byte register(X) pl)
puta: {
    .label screen = 2
    // [10] (word) puta::screen#0 ← (byte) puta::ph#2 w= (byte) puta::pl#2 -- vwuz1=vbuaa_word_vbuxx 
    sta.z screen+1
    stx.z screen
    // [11] *((byte*)(word) puta::screen#0) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    jmp breturn
    // puta::@return
  breturn:
    // [12] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_main:
Removing instruction puta_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction puta_from_main:
Removing instruction b1:
Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@return
(void()) puta((byte) puta::ph , (byte) puta::pl)
(label) puta::@return
(byte) puta::ph
(byte) puta::ph#2 reg byte a 2.0
(byte) puta::pl
(byte) puta::pl#2 reg byte x 2.0
(byte*) puta::screen
(word) puta::screen#0 screen zp ZP_WORD:2 2.0

reg byte a [ puta::ph#2 ]
reg byte x [ puta::pl#2 ]
zp ZP_WORD:2 [ puta::screen#0 ]


FINAL ASSEMBLER
Score: 48

  // File Comments
// Tests creating a literal pointer from two bytes
  // 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 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // puta(4, 0x00)
    // [5] call puta 
    // [9] phi from main to puta [phi:main->puta]
    // [9] phi (byte) puta::pl#2 = (byte) 0 [phi:main->puta#0] -- vbuxx=vbuc1 
    ldx #0
    // [9] phi (byte) puta::ph#2 = (byte) 4 [phi:main->puta#1] -- vbuaa=vbuc1 
    lda #4
    jsr puta
    // [6] phi from main to main::@1 [phi:main->main::@1]
    // main::@1
    // puta(5, 0x18)
    // [7] call puta 
    // [9] phi from main::@1 to puta [phi:main::@1->puta]
    // [9] phi (byte) puta::pl#2 = (byte) $18 [phi:main::@1->puta#0] -- vbuxx=vbuc1 
    ldx #$18
    // [9] phi (byte) puta::ph#2 = (byte) 5 [phi:main::@1->puta#1] -- vbuaa=vbuc1 
    lda #5
    jsr puta
    // main::@return
    // }
    // [8] return 
    rts
}
  // puta
// puta(byte register(A) ph, byte register(X) pl)
puta: {
    .label screen = 2
    // (byte*) { ph, pl }
    // [10] (word) puta::screen#0 ← (byte) puta::ph#2 w= (byte) puta::pl#2 -- vwuz1=vbuaa_word_vbuxx 
    sta.z screen+1
    stx.z screen
    // *screen = 'a'
    // [11] *((byte*)(word) puta::screen#0) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    // puta::@return
    // }
    // [12] return 
    rts
}
  // File Data

