Inlined call vicSelectGfxBank::$0 = call toDd00(vicSelectGfxBank::gfx)
Inlined call call vicSelectGfxBank(main::PLAYFIELD_CHARSET)

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::vicSelectGfxBank1_gfx#0 = main::PLAYFIELD_CHARSET
  to:main::vicSelectGfxBank1
main::vicSelectGfxBank1: scope:[main]  from main
  main::vicSelectGfxBank1_gfx#1 = phi( main/main::vicSelectGfxBank1_gfx#0 )
  *((char *)CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR) = 3
  main::vicSelectGfxBank1_toDd001_gfx#0 = main::vicSelectGfxBank1_gfx#1
  to:main::vicSelectGfxBank1_toDd001
main::vicSelectGfxBank1_toDd001: scope:[main]  from main::vicSelectGfxBank1
  main::vicSelectGfxBank1_toDd001_gfx#1 = phi( main::vicSelectGfxBank1/main::vicSelectGfxBank1_toDd001_gfx#0 )
  main::vicSelectGfxBank1_toDd001_$0 = byte1  (unsigned int)main::vicSelectGfxBank1_toDd001_gfx#1
  main::vicSelectGfxBank1_toDd001_$1 = main::vicSelectGfxBank1_toDd001_$0 / $40
  main::vicSelectGfxBank1_toDd001_$2 = 3 ^ main::vicSelectGfxBank1_toDd001_$1
  main::vicSelectGfxBank1_toDd001_return#0 = main::vicSelectGfxBank1_toDd001_$2
  to:main::vicSelectGfxBank1_toDd001_@return
main::vicSelectGfxBank1_toDd001_@return: scope:[main]  from main::vicSelectGfxBank1_toDd001
  main::vicSelectGfxBank1_toDd001_return#2 = phi( main::vicSelectGfxBank1_toDd001/main::vicSelectGfxBank1_toDd001_return#0 )
  main::vicSelectGfxBank1_toDd001_return#1 = main::vicSelectGfxBank1_toDd001_return#2
  to:main::vicSelectGfxBank1_@1
main::vicSelectGfxBank1_@1: scope:[main]  from main::vicSelectGfxBank1_toDd001_@return
  main::vicSelectGfxBank1_toDd001_return#3 = phi( main::vicSelectGfxBank1_toDd001_@return/main::vicSelectGfxBank1_toDd001_return#1 )
  main::vicSelectGfxBank1_$0 = main::vicSelectGfxBank1_toDd001_return#3
  *((char *)CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A) = main::vicSelectGfxBank1_$0
  to:main::@return
main::@return: scope:[main]  from main::vicSelectGfxBank1_@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 struct MOS6526_CIA * const CIA2 = (struct MOS6526_CIA *)$dd00
__constant char OFFSET_STRUCT_MOS6526_CIA_PORT_A = 0
__constant char OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
void __start()
void main()
__constant char * const main::PLAYFIELD_CHARSET = (char *)$2800
char main::vicSelectGfxBank1_$0
char *main::vicSelectGfxBank1_gfx
char *main::vicSelectGfxBank1_gfx#0
char *main::vicSelectGfxBank1_gfx#1
char main::vicSelectGfxBank1_toDd001_$0
number main::vicSelectGfxBank1_toDd001_$1
number main::vicSelectGfxBank1_toDd001_$2
char *main::vicSelectGfxBank1_toDd001_gfx
char *main::vicSelectGfxBank1_toDd001_gfx#0
char *main::vicSelectGfxBank1_toDd001_gfx#1
char main::vicSelectGfxBank1_toDd001_return
char main::vicSelectGfxBank1_toDd001_return#0
char main::vicSelectGfxBank1_toDd001_return#1
char main::vicSelectGfxBank1_toDd001_return#2
char main::vicSelectGfxBank1_toDd001_return#3

Adding number conversion cast (unumber) 3 in *((char *)CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR) = 3
Adding number conversion cast (unumber) $40 in main::vicSelectGfxBank1_toDd001_$1 = main::vicSelectGfxBank1_toDd001_$0 / $40
Adding number conversion cast (unumber) main::vicSelectGfxBank1_toDd001_$1 in main::vicSelectGfxBank1_toDd001_$1 = main::vicSelectGfxBank1_toDd001_$0 / (unumber)$40
Adding number conversion cast (unumber) 3 in main::vicSelectGfxBank1_toDd001_$2 = 3 ^ main::vicSelectGfxBank1_toDd001_$1
Adding number conversion cast (unumber) main::vicSelectGfxBank1_toDd001_$2 in main::vicSelectGfxBank1_toDd001_$2 = (unumber)3 ^ main::vicSelectGfxBank1_toDd001_$1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((char *)CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR) = (unumber)3
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (struct MOS6526_CIA *) 56576
Simplifying constant pointer cast (char *) 10240
Simplifying constant integer cast 3
Simplifying constant integer cast $40
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) $40
Finalized unsigned number type (char) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in main::vicSelectGfxBank1_toDd001_$1 = main::vicSelectGfxBank1_toDd001_$0 / $40
Inferred type updated to char in main::vicSelectGfxBank1_toDd001_$2 = 3 ^ main::vicSelectGfxBank1_toDd001_$1
Alias main::vicSelectGfxBank1_gfx#0 = main::vicSelectGfxBank1_gfx#1 main::vicSelectGfxBank1_toDd001_gfx#0 main::vicSelectGfxBank1_toDd001_gfx#1 
Alias main::vicSelectGfxBank1_toDd001_return#0 = main::vicSelectGfxBank1_toDd001_$2 main::vicSelectGfxBank1_toDd001_return#2 main::vicSelectGfxBank1_toDd001_return#1 main::vicSelectGfxBank1_toDd001_return#3 main::vicSelectGfxBank1_$0 
Successful SSA optimization Pass2AliasElimination
Constant main::vicSelectGfxBank1_gfx#0 = main::PLAYFIELD_CHARSET
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (unsigned int)main::vicSelectGfxBank1_gfx#0 in [2] main::vicSelectGfxBank1_toDd001_$0 = byte1  (unsigned int)main::vicSelectGfxBank1_gfx#0
Successful SSA optimization Pass2ConstantValues
Simplifying expression containing zero (char *)CIA2 in [5] *((char *)CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A) = main::vicSelectGfxBank1_toDd001_return#0
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_MOS6526_CIA_PORT_A
Successful SSA optimization PassNEliminateUnusedVars
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
Constant right-side identified [1] main::vicSelectGfxBank1_toDd001_$0 = byte1  (unsigned int)main::vicSelectGfxBank1_gfx#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::vicSelectGfxBank1_toDd001_$0 = byte1 (unsigned int)main::vicSelectGfxBank1_gfx#0
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [1] main::vicSelectGfxBank1_toDd001_$1 = main::vicSelectGfxBank1_toDd001_$0 / $40
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::vicSelectGfxBank1_toDd001_$1 = main::vicSelectGfxBank1_toDd001_$0/$40
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero main::vicSelectGfxBank1_toDd001_$0/$40 in 
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero 3 in [2] main::vicSelectGfxBank1_toDd001_return#0 = 3 ^ main::vicSelectGfxBank1_toDd001_$1
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant main::vicSelectGfxBank1_toDd001_$0
Eliminating unused constant main::vicSelectGfxBank1_toDd001_$1
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant main::vicSelectGfxBank1_gfx#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant main::PLAYFIELD_CHARSET
Successful SSA optimization PassNEliminateUnusedVars
Constant main::vicSelectGfxBank1_toDd001_return#0 = 3
Successful SSA optimization Pass2ConstantIdentification
Adding NOP phi() at start of main
Adding NOP phi() at start of main::vicSelectGfxBank1_toDd001
Adding NOP phi() at start of main::vicSelectGfxBank1_toDd001_@return
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block label main::vicSelectGfxBank1_toDd001_@return
Adding NOP phi() at start of main
Adding NOP phi() at start of main::vicSelectGfxBank1_toDd001

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::vicSelectGfxBank1
main::vicSelectGfxBank1: scope:[main]  from main
  [1] *((char *)CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR) = 3
  to:main::vicSelectGfxBank1_toDd001
main::vicSelectGfxBank1_toDd001: scope:[main]  from main::vicSelectGfxBank1
  [2] phi()
  to:main::vicSelectGfxBank1_@1
main::vicSelectGfxBank1_@1: scope:[main]  from main::vicSelectGfxBank1_toDd001
  [3] *((char *)CIA2) = main::vicSelectGfxBank1_toDd001_return#0
  to:main::@return
main::@return: scope:[main]  from main::vicSelectGfxBank1_@1
  [4] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char *main::vicSelectGfxBank1_gfx
char *main::vicSelectGfxBank1_toDd001_gfx
char main::vicSelectGfxBank1_toDd001_return

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] *((char *)CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR) = 3 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [3] *((char *)CIA2) = main::vicSelectGfxBank1_toDd001_return#0 [ ] (  [ ] { }  ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [MOS6526_CIA] 
Uplift Scope [MOS6569_VICII] 
Uplift Scope [MOS6581_SID] 
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [MOS6526_CIA] best 84 combination 
Uplifting [MOS6569_VICII] best 84 combination 
Uplifting [MOS6581_SID] best 84 combination 
Uplifting [main] best 84 combination 
Uplifting [] best 84 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test minimization of constants
  // Upstart
  // Commodore 64 PRG executable file
.file [name="gfxbank.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
  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
  /// The CIA#2: Serial bus, RS-232, VIC memory bank
  .label CIA2 = $dd00
.segment Code
  // main
main: {
    .const vicSelectGfxBank1_toDd001_return = 3
    jmp vicSelectGfxBank1
    // main::vicSelectGfxBank1
  vicSelectGfxBank1:
    // [1] *((char *)CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR) = 3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR
    // [2] phi from main::vicSelectGfxBank1 to main::vicSelectGfxBank1_toDd001 [phi:main::vicSelectGfxBank1->main::vicSelectGfxBank1_toDd001]
  vicSelectGfxBank1_toDd001_from_vicSelectGfxBank1:
    jmp vicSelectGfxBank1_toDd001
    // main::vicSelectGfxBank1_toDd001
  vicSelectGfxBank1_toDd001:
    jmp vicSelectGfxBank1___b1
    // main::vicSelectGfxBank1_@1
  vicSelectGfxBank1___b1:
    // [3] *((char *)CIA2) = main::vicSelectGfxBank1_toDd001_return#0 -- _deref_pbuc1=vbuc2 
    lda #vicSelectGfxBank1_toDd001_return
    sta CIA2
    jmp __breturn
    // main::@return
  __breturn:
    // [4] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp vicSelectGfxBank1
Removing instruction jmp vicSelectGfxBank1_toDd001
Removing instruction jmp vicSelectGfxBank1___b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction vicSelectGfxBank1_toDd001_from_vicSelectGfxBank1:
Removing instruction vicSelectGfxBank1_toDd001:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction vicSelectGfxBank1:
Removing instruction vicSelectGfxBank1___b1:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant struct MOS6526_CIA * const CIA2 = (struct MOS6526_CIA *) 56576
__constant char OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
void main()
char *main::vicSelectGfxBank1_gfx
char *main::vicSelectGfxBank1_toDd001_gfx
char main::vicSelectGfxBank1_toDd001_return
__constant char main::vicSelectGfxBank1_toDd001_return#0 = 3 // vicSelectGfxBank1_toDd001_return



FINAL ASSEMBLER
Score: 18

  // File Comments
// Test minimization of constants
  // Upstart
  // Commodore 64 PRG executable file
.file [name="gfxbank.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
  .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2
  /// The CIA#2: Serial bus, RS-232, VIC memory bank
  .label CIA2 = $dd00
.segment Code
  // main
main: {
    .const vicSelectGfxBank1_toDd001_return = 3
    // main::vicSelectGfxBank1
    // CIA2->PORT_A_DDR = %00000011
    // [1] *((char *)CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR) = 3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR
    // [2] phi from main::vicSelectGfxBank1 to main::vicSelectGfxBank1_toDd001 [phi:main::vicSelectGfxBank1->main::vicSelectGfxBank1_toDd001]
    // main::vicSelectGfxBank1_toDd001
    // main::vicSelectGfxBank1_@1
    // CIA2->PORT_A = toDd00(gfx)
    // [3] *((char *)CIA2) = main::vicSelectGfxBank1_toDd001_return#0 -- _deref_pbuc1=vbuc2 
    lda #vicSelectGfxBank1_toDd001_return
    sta CIA2
    // main::@return
    // }
    // [4] return 
    rts
}
  // File Data

