diff --git a/src/main/java/dk/camelot64/kickc/test/bresenham.kc b/src/main/java/dk/camelot64/kickc/test/bresenham.kc index f840da623..e6e4f3af7 100644 --- a/src/main/java/dk/camelot64/kickc/test/bresenham.kc +++ b/src/main/java/dk/camelot64/kickc/test/bresenham.kc @@ -1,23 +1,30 @@ byte STAR = 81; byte[40*25] SCREEN = $0400; -byte x0 = 0; -byte y0 = 0; -byte x1 = 39; -byte y1 = 24; -byte xd = x1-x0; -byte yd = y1-y0; -byte x = x0; -byte y = y0; -byte e = yd/2; -byte *cursor = SCREEN+y*40+x; -do { - *cursor = STAR; - x = x + 1; - cursor = cursor + 1; - e = e+yd; - if(xd$400 - sta $2+$1 -b1: - ldy #$0 - lda #$51 - sta ($2),y - inc $4 - inc $2 - bne !+ - inc $2+$1 -!: - txa - clc - adc #$18 - tax - cpx #$27 - bcc b2 - inc $5 - lda $2 - clc - adc #$28 - sta $2 - bcc !+ - inc $2+$1 -!: - txa - sec - sbc #$27 - tax -b2: - lda $4 - cmp #$28 - bcc b1 + jsr main +main: { + lda #$0 + sta $5 + ldx #$c + lda #$0 + sta $4 + lda #<$400 + sta $2 + lda #>$400 + sta $2+$1 + b1: + ldy #$0 + lda #$51 + sta ($2),y + inc $4 + inc $2 + bne !+ + inc $2+$1 + !: + txa + clc + adc #$18 + tax + cpx #$27 + bcc b2 + inc $5 + lda $2 + clc + adc #$28 + sta $2 + bcc !+ + inc $2+$1 + !: + txa + sec + sbc #$27 + tax + b2: + lda $4 + cmp #$28 + bcc b1 + rts +} diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.cfg b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.cfg index f3ff2347b..a67f2ed11 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.cfg +++ b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.cfg @@ -1,25 +1,31 @@ @begin: scope:[] from - to:@1 -@1: scope:[] from @2 @begin - [0] (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) [ cursor#3 x#2 e#3 y#2 ] - [0] (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) 12 ) [ cursor#3 x#2 e#3 y#2 ] - [0] (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) [ cursor#3 x#2 e#3 y#2 ] - [0] (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(word) 1024 ) [ cursor#3 x#2 e#3 y#2 ] - [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] - [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] - [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 y#2 cursor#1 ] - [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] - [5] if((byte) 39>=(byte) e#1) goto @2 [ x#1 e#1 y#2 cursor#1 ] - to:@3 -@3: scope:[] from @1 - [6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] - [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] - [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] - to:@2 -@2: scope:[] from @1 @3 - [9] (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) [ cursor#5 x#1 e#5 y#4 ] - [9] (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) [ cursor#5 x#1 e#5 y#4 ] - [9] (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) [ cursor#5 x#1 e#5 y#4 ] - [10] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] + [0] call main param-assignment [ ] to:@end -@end: scope:[] from @2 +@end: scope:[] from @begin +main: scope:[main] from @begin + to:main::@1 +main::@1: scope:[main] from main main::@2 + [1] (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [1] (byte) main::e#3 ← phi( main/(byte) 12 main::@2/(byte) main::e#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [1] (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [1] (byte*) main::cursor#3 ← phi( main/(word) 1024 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::x#1 main::cursor#3 main::e#3 main::y#2 ] + [4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::x#1 main::e#3 main::y#2 main::cursor#1 ] + [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] + [6] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] + to:main::@3 +main::@3: scope:[main] from main::@1 + [7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::e#1 main::cursor#1 main::y#1 ] + [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] + [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] + to:main::@2 +main::@2: scope:[main] from main::@1 main::@3 + [10] (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] + [10] (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] + [10] (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] + [11] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] + to:main::@return +main::@return: scope:[main] from main::@2 + [12] return [ ] + to:@return diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log index 76d4d417d..c3ba40e82 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.log @@ -1,198 +1,227 @@ byte STAR = 81; byte[40*25] SCREEN = $0400; -byte x0 = 0; -byte y0 = 0; -byte x1 = 39; -byte y1 = 24; -byte xd = x1-x0; -byte yd = y1-y0; -byte x = x0; -byte y = y0; -byte e = yd/2; -byte *cursor = SCREEN+y*40+x; -do { - *cursor = STAR; - x = x + 1; - cursor = cursor + 1; - e = e+yd; - if(xd= (byte) e#1 from (boolean~) $9 ← (byte) xd#1 < (byte) e#1 +Multiple usages for variable. Not optimizing sub-constant (byte) main::x1#1 +Inversing boolean not (boolean~) main::$10 ← (byte) main::xd#1 >= (byte) main::e#1 from (boolean~) main::$9 ← (byte) main::xd#1 < (byte) main::e#1 Succesful SSA optimization Pass2UnaryNotSimplification CONTROL FLOW GRAPH @begin: scope:[] from - (byte~) $0 ← (byte) 39 - (byte) 0 - (byte) xd#0 ← (byte~) $0 - (byte~) $1 ← (byte) 24 - (byte) 0 - (byte) yd#0 ← (byte~) $1 - (byte) x#0 ← (byte) 0 - (byte) y#0 ← (byte) 0 - (byte~) $2 ← (byte) yd#0 / (byte) 2 - (byte) e#0 ← (byte~) $2 - (byte~) $3 ← (byte) y#0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*~) $5 ← (byte*~) $4 + (byte) x#0 - (byte*) cursor#0 ← (byte*~) $5 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#3 ← phi( @2/(byte) y#4 @begin/(byte) y#0 ) - (byte) x1#2 ← phi( @2/(byte) x1#1 @begin/(byte) 39 ) - (byte) xd#1 ← phi( @2/(byte) xd#3 @begin/(byte) xd#0 ) - (byte) yd#1 ← phi( @2/(byte) yd#2 @begin/(byte) yd#0 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) - (byte) x#2 ← phi( @2/(byte) x#3 @begin/(byte) x#0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @2/(byte) STAR#2 @begin/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte~) $6 ← (byte) x#2 + (byte) 1 - (byte) x#1 ← (byte~) $6 - (byte*~) $7 ← (byte*) cursor#3 + (byte) 1 - (byte*) cursor#1 ← (byte*~) $7 - (byte~) $8 ← (byte) e#3 + (byte) yd#1 - (byte) e#1 ← (byte~) $8 - (boolean~) $10 ← (byte) xd#1 >= (byte) e#1 - if((boolean~) $10) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#3 @3/(byte) y#1 ) - (byte) xd#3 ← phi( @1/(byte) xd#1 @3/(byte) xd#2 ) - (byte) yd#2 ← phi( @1/(byte) yd#1 @3/(byte) yd#3 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - (byte) STAR#2 ← phi( @1/(byte) STAR#1 @3/(byte) STAR#3 ) - (byte) x#3 ← phi( @1/(byte) x#1 @3/(byte) x#4 ) - (byte) x1#1 ← phi( @1/(byte) x1#2 @3/(byte) x1#3 ) - (byte~) $14 ← (byte) x1#1 + (byte) 1 - (boolean~) $15 ← (byte) x#3 < (byte~) $14 - if((boolean~) $15) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) yd#3 ← phi( @1/(byte) yd#1 ) - (byte) STAR#3 ← phi( @1/(byte) STAR#1 ) - (byte) x#4 ← phi( @1/(byte) x#1 ) - (byte) x1#3 ← phi( @1/(byte) x1#2 ) - (byte) xd#2 ← phi( @1/(byte) xd#1 ) - (byte) e#4 ← phi( @1/(byte) e#1 ) - (byte*) cursor#4 ← phi( @1/(byte*) cursor#1 ) - (byte) y#2 ← phi( @1/(byte) y#3 ) - (byte~) $11 ← (byte) y#2 + (byte) 1 - (byte) y#1 ← (byte~) $11 - (byte*~) $12 ← (byte*) cursor#4 + (byte) 40 - (byte*) cursor#2 ← (byte*~) $12 - (byte~) $13 ← (byte) e#4 - (byte) xd#2 - (byte) e#2 ← (byte~) $13 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte) STAR#2 ← phi( @begin/(byte) 81 ) + (byte[1000]) SCREEN#1 ← phi( @begin/(word) 1024 ) + (byte~) main::$0 ← (byte) 39 - (byte) 0 + (byte) main::xd#0 ← (byte~) main::$0 + (byte~) main::$1 ← (byte) 24 - (byte) 0 + (byte) main::yd#0 ← (byte~) main::$1 + (byte) main::x#0 ← (byte) 0 + (byte) main::y#0 ← (byte) 0 + (byte~) main::$2 ← (byte) main::yd#0 / (byte) 2 + (byte) main::e#0 ← (byte~) main::$2 + (byte~) main::$3 ← (byte) main::y#0 * (byte) 40 + (byte*~) main::$4 ← (byte[1000]) SCREEN#1 + (byte~) main::$3 + (byte*~) main::$5 ← (byte*~) main::$4 + (byte) main::x#0 + (byte*) main::cursor#0 ← (byte*~) main::$5 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#3 ← phi( main/(byte) main::y#0 main::@2/(byte) main::y#4 ) + (byte) main::x1#2 ← phi( main/(byte) 39 main::@2/(byte) main::x1#1 ) + (byte) main::xd#1 ← phi( main/(byte) main::xd#0 main::@2/(byte) main::xd#3 ) + (byte) main::yd#1 ← phi( main/(byte) main::yd#0 main::@2/(byte) main::yd#2 ) + (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) main::x#0 main::@2/(byte) main::x#3 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + (byte) STAR#1 ← phi( main/(byte) STAR#2 main::@2/(byte) STAR#3 ) + *((byte*) main::cursor#3) ← (byte) STAR#1 + (byte~) main::$6 ← (byte) main::x#2 + (byte) 1 + (byte) main::x#1 ← (byte~) main::$6 + (byte*~) main::$7 ← (byte*) main::cursor#3 + (byte) 1 + (byte*) main::cursor#1 ← (byte*~) main::$7 + (byte~) main::$8 ← (byte) main::e#3 + (byte) main::yd#1 + (byte) main::e#1 ← (byte~) main::$8 + (boolean~) main::$10 ← (byte) main::xd#1 >= (byte) main::e#1 + if((boolean~) main::$10) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#3 main::@3/(byte) main::y#1 ) + (byte) main::xd#3 ← phi( main::@1/(byte) main::xd#1 main::@3/(byte) main::xd#2 ) + (byte) main::yd#2 ← phi( main::@1/(byte) main::yd#1 main::@3/(byte) main::yd#3 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + (byte) STAR#3 ← phi( main::@1/(byte) STAR#1 main::@3/(byte) STAR#4 ) + (byte) main::x#3 ← phi( main::@1/(byte) main::x#1 main::@3/(byte) main::x#4 ) + (byte) main::x1#1 ← phi( main::@1/(byte) main::x1#2 main::@3/(byte) main::x1#3 ) + (byte~) main::$14 ← (byte) main::x1#1 + (byte) 1 + (boolean~) main::$15 ← (byte) main::x#3 < (byte~) main::$14 + if((boolean~) main::$15) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::yd#3 ← phi( main::@1/(byte) main::yd#1 ) + (byte) STAR#4 ← phi( main::@1/(byte) STAR#1 ) + (byte) main::x#4 ← phi( main::@1/(byte) main::x#1 ) + (byte) main::x1#3 ← phi( main::@1/(byte) main::x1#2 ) + (byte) main::xd#2 ← phi( main::@1/(byte) main::xd#1 ) + (byte) main::e#4 ← phi( main::@1/(byte) main::e#1 ) + (byte*) main::cursor#4 ← phi( main::@1/(byte*) main::cursor#1 ) + (byte) main::y#2 ← phi( main::@1/(byte) main::y#3 ) + (byte~) main::$11 ← (byte) main::y#2 + (byte) 1 + (byte) main::y#1 ← (byte~) main::$11 + (byte*~) main::$12 ← (byte*) main::cursor#4 + (byte) 40 + (byte*) main::cursor#2 ← (byte*~) main::$12 + (byte~) main::$13 ← (byte) main::e#4 - (byte) main::xd#2 + (byte) main::e#2 ← (byte~) main::$13 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Alias (byte) xd#0 = (byte~) $0 -Alias (byte) yd#0 = (byte~) $1 -Alias (byte) e#0 = (byte~) $2 -Alias (byte*) cursor#0 = (byte*~) $5 -Alias (byte) x#1 = (byte~) $6 (byte) x#4 -Alias (byte*) cursor#1 = (byte*~) $7 (byte*) cursor#4 -Alias (byte) e#1 = (byte~) $8 (byte) e#4 -Alias (byte) y#2 = (byte) y#3 -Alias (byte) xd#1 = (byte) xd#2 -Alias (byte) x1#2 = (byte) x1#3 -Alias (byte) STAR#1 = (byte) STAR#3 -Alias (byte) yd#1 = (byte) yd#3 -Alias (byte) y#1 = (byte~) $11 -Alias (byte*) cursor#2 = (byte*~) $12 -Alias (byte) e#2 = (byte~) $13 +Alias (byte) main::xd#0 = (byte~) main::$0 +Alias (byte) main::yd#0 = (byte~) main::$1 +Alias (byte) main::e#0 = (byte~) main::$2 +Alias (byte*) main::cursor#0 = (byte*~) main::$5 +Alias (byte) main::x#1 = (byte~) main::$6 (byte) main::x#4 +Alias (byte*) main::cursor#1 = (byte*~) main::$7 (byte*) main::cursor#4 +Alias (byte) main::e#1 = (byte~) main::$8 (byte) main::e#4 +Alias (byte) main::y#2 = (byte) main::y#3 +Alias (byte) main::xd#1 = (byte) main::xd#2 +Alias (byte) main::x1#2 = (byte) main::x1#3 +Alias (byte) STAR#1 = (byte) STAR#4 +Alias (byte) main::yd#1 = (byte) main::yd#3 +Alias (byte) main::y#1 = (byte~) main::$11 +Alias (byte*) main::cursor#2 = (byte*~) main::$12 +Alias (byte) main::e#2 = (byte~) main::$13 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte) xd#0 ← (byte) 39 - (byte) 0 - (byte) yd#0 ← (byte) 24 - (byte) 0 - (byte) x#0 ← (byte) 0 - (byte) y#0 ← (byte) 0 - (byte) e#0 ← (byte) yd#0 / (byte) 2 - (byte~) $3 ← (byte) y#0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) x#0 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) y#0 ) - (byte) x1#2 ← phi( @2/(byte) x1#1 @begin/(byte) 39 ) - (byte) xd#1 ← phi( @2/(byte) xd#3 @begin/(byte) xd#0 ) - (byte) yd#1 ← phi( @2/(byte) yd#2 @begin/(byte) yd#0 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) - (byte) x#2 ← phi( @2/(byte) x#3 @begin/(byte) x#0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @2/(byte) STAR#2 @begin/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - (boolean~) $10 ← (byte) xd#1 >= (byte) e#1 - if((boolean~) $10) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) xd#3 ← phi( @1/(byte) xd#1 @3/(byte) xd#1 ) - (byte) yd#2 ← phi( @1/(byte) yd#1 @3/(byte) yd#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - (byte) STAR#2 ← phi( @1/(byte) STAR#1 @3/(byte) STAR#1 ) - (byte) x#3 ← phi( @1/(byte) x#1 @3/(byte) x#1 ) - (byte) x1#1 ← phi( @1/(byte) x1#2 @3/(byte) x1#2 ) - (byte~) $14 ← (byte) x1#1 + (byte) 1 - (boolean~) $15 ← (byte) x#3 < (byte~) $14 - if((boolean~) $15) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) xd#1 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte) STAR#2 ← phi( @begin/(byte) 81 ) + (byte[1000]) SCREEN#1 ← phi( @begin/(word) 1024 ) + (byte) main::xd#0 ← (byte) 39 - (byte) 0 + (byte) main::yd#0 ← (byte) 24 - (byte) 0 + (byte) main::x#0 ← (byte) 0 + (byte) main::y#0 ← (byte) 0 + (byte) main::e#0 ← (byte) main::yd#0 / (byte) 2 + (byte~) main::$3 ← (byte) main::y#0 * (byte) 40 + (byte*~) main::$4 ← (byte[1000]) SCREEN#1 + (byte~) main::$3 + (byte*) main::cursor#0 ← (byte*~) main::$4 + (byte) main::x#0 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) main::y#0 main::@2/(byte) main::y#4 ) + (byte) main::x1#2 ← phi( main/(byte) 39 main::@2/(byte) main::x1#1 ) + (byte) main::xd#1 ← phi( main/(byte) main::xd#0 main::@2/(byte) main::xd#3 ) + (byte) main::yd#1 ← phi( main/(byte) main::yd#0 main::@2/(byte) main::yd#2 ) + (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) main::x#0 main::@2/(byte) main::x#3 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + (byte) STAR#1 ← phi( main/(byte) STAR#2 main::@2/(byte) STAR#3 ) + *((byte*) main::cursor#3) ← (byte) STAR#1 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#1 + (boolean~) main::$10 ← (byte) main::xd#1 >= (byte) main::e#1 + if((boolean~) main::$10) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::xd#3 ← phi( main::@1/(byte) main::xd#1 main::@3/(byte) main::xd#1 ) + (byte) main::yd#2 ← phi( main::@1/(byte) main::yd#1 main::@3/(byte) main::yd#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + (byte) STAR#3 ← phi( main::@1/(byte) STAR#1 main::@3/(byte) STAR#1 ) + (byte) main::x#3 ← phi( main::@1/(byte) main::x#1 main::@3/(byte) main::x#1 ) + (byte) main::x1#1 ← phi( main::@1/(byte) main::x1#2 main::@3/(byte) main::x1#2 ) + (byte~) main::$14 ← (byte) main::x1#1 + (byte) 1 + (boolean~) main::$15 ← (byte) main::x#3 < (byte~) main::$14 + if((boolean~) main::$15) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#1 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Redundant Phi (byte) x1#1 (byte) x1#2 -Redundant Phi (byte) x#3 (byte) x#1 -Redundant Phi (byte) STAR#2 (byte) STAR#1 -Redundant Phi (byte) yd#2 (byte) yd#1 -Redundant Phi (byte) xd#3 (byte) xd#1 +Redundant Phi (byte[1000]) SCREEN#1 (word) 1024 +Redundant Phi (byte) STAR#2 (byte) 81 +Redundant Phi (byte) main::x1#1 (byte) main::x1#2 +Redundant Phi (byte) main::x#3 (byte) main::x#1 +Redundant Phi (byte) STAR#3 (byte) STAR#1 +Redundant Phi (byte) main::yd#2 (byte) main::yd#1 +Redundant Phi (byte) main::xd#3 (byte) main::xd#1 Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte) xd#0 ← (byte) 39 - (byte) 0 - (byte) yd#0 ← (byte) 24 - (byte) 0 - (byte) x#0 ← (byte) 0 - (byte) y#0 ← (byte) 0 - (byte) e#0 ← (byte) yd#0 / (byte) 2 - (byte~) $3 ← (byte) y#0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) x#0 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) y#0 ) - (byte) x1#2 ← phi( @2/(byte) x1#2 @begin/(byte) 39 ) - (byte) xd#1 ← phi( @2/(byte) xd#1 @begin/(byte) xd#0 ) - (byte) yd#1 ← phi( @2/(byte) yd#1 @begin/(byte) yd#0 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) - (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) x#0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @2/(byte) STAR#1 @begin/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - (boolean~) $10 ← (byte) xd#1 >= (byte) e#1 - if((boolean~) $10) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - (byte~) $14 ← (byte) x1#2 + (byte) 1 - (boolean~) $15 ← (byte) x#1 < (byte~) $14 - if((boolean~) $15) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) xd#1 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte) main::xd#0 ← (byte) 39 - (byte) 0 + (byte) main::yd#0 ← (byte) 24 - (byte) 0 + (byte) main::x#0 ← (byte) 0 + (byte) main::y#0 ← (byte) 0 + (byte) main::e#0 ← (byte) main::yd#0 / (byte) 2 + (byte~) main::$3 ← (byte) main::y#0 * (byte) 40 + (byte*~) main::$4 ← (word) 1024 + (byte~) main::$3 + (byte*) main::cursor#0 ← (byte*~) main::$4 + (byte) main::x#0 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) main::y#0 main::@2/(byte) main::y#4 ) + (byte) main::x1#2 ← phi( main/(byte) 39 main::@2/(byte) main::x1#2 ) + (byte) main::xd#1 ← phi( main/(byte) main::xd#0 main::@2/(byte) main::xd#1 ) + (byte) main::yd#1 ← phi( main/(byte) main::yd#0 main::@2/(byte) main::yd#1 ) + (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) main::x#0 main::@2/(byte) main::x#1 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + (byte) STAR#1 ← phi( main/(byte) 81 main::@2/(byte) STAR#1 ) + *((byte*) main::cursor#3) ← (byte) STAR#1 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#1 + (boolean~) main::$10 ← (byte) main::xd#1 >= (byte) main::e#1 + if((boolean~) main::$10) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + (byte~) main::$14 ← (byte) main::x1#2 + (byte) 1 + (boolean~) main::$15 ← (byte) main::x#1 < (byte~) main::$14 + if((boolean~) main::$15) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#1 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin Self Phi Eliminated (byte) STAR#1 -Self Phi Eliminated (byte) yd#1 -Self Phi Eliminated (byte) xd#1 -Self Phi Eliminated (byte) x1#2 +Self Phi Eliminated (byte) main::yd#1 +Self Phi Eliminated (byte) main::xd#1 +Self Phi Eliminated (byte) main::x1#2 Succesful SSA optimization Pass2SelfPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte) xd#0 ← (byte) 39 - (byte) 0 - (byte) yd#0 ← (byte) 24 - (byte) 0 - (byte) x#0 ← (byte) 0 - (byte) y#0 ← (byte) 0 - (byte) e#0 ← (byte) yd#0 / (byte) 2 - (byte~) $3 ← (byte) y#0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) x#0 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) y#0 ) - (byte) x1#2 ← phi( @begin/(byte) 39 ) - (byte) xd#1 ← phi( @begin/(byte) xd#0 ) - (byte) yd#1 ← phi( @begin/(byte) yd#0 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) - (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) x#0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @begin/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - (boolean~) $10 ← (byte) xd#1 >= (byte) e#1 - if((boolean~) $10) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - (byte~) $14 ← (byte) x1#2 + (byte) 1 - (boolean~) $15 ← (byte) x#1 < (byte~) $14 - if((boolean~) $15) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) xd#1 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte) main::xd#0 ← (byte) 39 - (byte) 0 + (byte) main::yd#0 ← (byte) 24 - (byte) 0 + (byte) main::x#0 ← (byte) 0 + (byte) main::y#0 ← (byte) 0 + (byte) main::e#0 ← (byte) main::yd#0 / (byte) 2 + (byte~) main::$3 ← (byte) main::y#0 * (byte) 40 + (byte*~) main::$4 ← (word) 1024 + (byte~) main::$3 + (byte*) main::cursor#0 ← (byte*~) main::$4 + (byte) main::x#0 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) main::y#0 main::@2/(byte) main::y#4 ) + (byte) main::x1#2 ← phi( main/(byte) 39 ) + (byte) main::xd#1 ← phi( main/(byte) main::xd#0 ) + (byte) main::yd#1 ← phi( main/(byte) main::yd#0 ) + (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) main::x#0 main::@2/(byte) main::x#1 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + (byte) STAR#1 ← phi( main/(byte) 81 ) + *((byte*) main::cursor#3) ← (byte) STAR#1 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#1 + (boolean~) main::$10 ← (byte) main::xd#1 >= (byte) main::e#1 + if((boolean~) main::$10) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + (byte~) main::$14 ← (byte) main::x1#2 + (byte) 1 + (boolean~) main::$15 ← (byte) main::x#1 < (byte~) main::$14 + if((boolean~) main::$15) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#1 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Simple Condition (boolean~) $10 if((byte) xd#1>=(byte) e#1) goto @2 -Simple Condition (boolean~) $15 if((byte) x#1<(byte~) $14) goto @1 +Simple Condition (boolean~) main::$10 if((byte) main::xd#1>=(byte) main::e#1) goto main::@2 +Simple Condition (boolean~) main::$15 if((byte) main::x#1<(byte~) main::$14) goto main::@1 Succesful SSA optimization Pass2ConditionalJumpSimplification CONTROL FLOW GRAPH @begin: scope:[] from - (byte) xd#0 ← (byte) 39 - (byte) 0 - (byte) yd#0 ← (byte) 24 - (byte) 0 - (byte) x#0 ← (byte) 0 - (byte) y#0 ← (byte) 0 - (byte) e#0 ← (byte) yd#0 / (byte) 2 - (byte~) $3 ← (byte) y#0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) x#0 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) y#0 ) - (byte) x1#2 ← phi( @begin/(byte) 39 ) - (byte) xd#1 ← phi( @begin/(byte) xd#0 ) - (byte) yd#1 ← phi( @begin/(byte) yd#0 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) - (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) x#0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - (byte) STAR#1 ← phi( @begin/(byte) 81 ) - *((byte*) cursor#3) ← (byte) STAR#1 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - if((byte) xd#1>=(byte) e#1) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - (byte~) $14 ← (byte) x1#2 + (byte) 1 - if((byte) x#1<(byte~) $14) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) xd#1 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte) main::xd#0 ← (byte) 39 - (byte) 0 + (byte) main::yd#0 ← (byte) 24 - (byte) 0 + (byte) main::x#0 ← (byte) 0 + (byte) main::y#0 ← (byte) 0 + (byte) main::e#0 ← (byte) main::yd#0 / (byte) 2 + (byte~) main::$3 ← (byte) main::y#0 * (byte) 40 + (byte*~) main::$4 ← (word) 1024 + (byte~) main::$3 + (byte*) main::cursor#0 ← (byte*~) main::$4 + (byte) main::x#0 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) main::y#0 main::@2/(byte) main::y#4 ) + (byte) main::x1#2 ← phi( main/(byte) 39 ) + (byte) main::xd#1 ← phi( main/(byte) main::xd#0 ) + (byte) main::yd#1 ← phi( main/(byte) main::yd#0 ) + (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) main::x#0 main::@2/(byte) main::x#1 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + (byte) STAR#1 ← phi( main/(byte) 81 ) + *((byte*) main::cursor#3) ← (byte) STAR#1 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#1 + if((byte) main::xd#1>=(byte) main::e#1) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + (byte~) main::$14 ← (byte) main::x1#2 + (byte) 1 + if((byte) main::x#1<(byte~) main::$14) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#1 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Constant (byte) xd#0 (byte) 39 -Constant (byte) yd#0 (byte) 24 -Constant (byte) x#0 (byte) 0 -Constant (byte) y#0 (byte) 0 +Constant (byte) main::xd#0 (byte) 39 +Constant (byte) main::yd#0 (byte) 24 +Constant (byte) main::x#0 (byte) 0 +Constant (byte) main::y#0 (byte) 0 Constant (byte) STAR#1 (byte) 81 -Constant (byte) x1#2 (byte) 39 +Constant (byte) main::x1#2 (byte) 39 Succesful SSA optimization Pass2ConstantPropagation CONTROL FLOW GRAPH @begin: scope:[] from - (byte) e#0 ← (byte) 24 / (byte) 2 - (byte~) $3 ← (byte) 0 * (byte) 40 - (byte*~) $4 ← (word) 1024 + (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (byte) 0 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) - (byte) xd#1 ← phi( @begin/(byte) 39 ) - (byte) yd#1 ← phi( @begin/(byte) 24 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) - (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - *((byte*) cursor#3) ← (byte) 81 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - if((byte) xd#1>=(byte) e#1) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - (byte~) $14 ← (byte) 39 + (byte) 1 - if((byte) x#1<(byte~) $14) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) xd#1 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte) main::e#0 ← (byte) 24 / (byte) 2 + (byte~) main::$3 ← (byte) 0 * (byte) 40 + (byte*~) main::$4 ← (word) 1024 + (byte~) main::$3 + (byte*) main::cursor#0 ← (byte*~) main::$4 + (byte) 0 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) + (byte) main::xd#1 ← phi( main/(byte) 39 ) + (byte) main::yd#1 ← phi( main/(byte) 24 ) + (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + *((byte*) main::cursor#3) ← (byte) 81 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#1 + if((byte) main::xd#1>=(byte) main::e#1) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + (byte~) main::$14 ← (byte) 39 + (byte) 1 + if((byte) main::x#1<(byte~) main::$14) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#1 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Consolidated constant in assignment cursor#0 -Multiple usages for variable. Not optimizing sub-constant (byte) y#2 -Multiple usages for variable. Not optimizing sub-constant (byte*) cursor#1 +Consolidated constant in assignment main::cursor#0 +Multiple usages for variable. Not optimizing sub-constant (byte) main::y#2 +Multiple usages for variable. Not optimizing sub-constant (byte*) main::cursor#1 Succesful SSA optimization Pass2ConstantAdditionElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte) e#0 ← (byte) 24 / (byte) 2 - (byte~) $3 ← (byte) 0 * (byte) 40 - (byte*~) $4 ← (byte~) $3 - (byte*) cursor#0 ← (byte*~) $4 + (word) 1024 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) - (byte) xd#1 ← phi( @begin/(byte) 39 ) - (byte) yd#1 ← phi( @begin/(byte) 24 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) - (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - *((byte*) cursor#3) ← (byte) 81 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - if((byte) xd#1>=(byte) e#1) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - (byte~) $14 ← (byte) 39 + (byte) 1 - if((byte) x#1<(byte~) $14) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) xd#1 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte) main::e#0 ← (byte) 24 / (byte) 2 + (byte~) main::$3 ← (byte) 0 * (byte) 40 + (byte*~) main::$4 ← (byte~) main::$3 + (byte*) main::cursor#0 ← (byte*~) main::$4 + (word) 1024 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) + (byte) main::xd#1 ← phi( main/(byte) 39 ) + (byte) main::yd#1 ← phi( main/(byte) 24 ) + (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + *((byte*) main::cursor#3) ← (byte) 81 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#1 + if((byte) main::xd#1>=(byte) main::e#1) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + (byte~) main::$14 ← (byte) 39 + (byte) 1 + if((byte) main::x#1<(byte~) main::$14) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#1 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Alias (byte~) $3 = (byte*~) $4 +Alias (byte~) main::$3 = (byte*~) main::$4 Succesful SSA optimization Pass2AliasElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte) e#0 ← (byte) 24 / (byte) 2 - (byte~) $3 ← (byte) 0 * (byte) 40 - (byte*) cursor#0 ← (byte~) $3 + (word) 1024 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) - (byte) xd#1 ← phi( @begin/(byte) 39 ) - (byte) yd#1 ← phi( @begin/(byte) 24 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) - (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - *((byte*) cursor#3) ← (byte) 81 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) yd#1 - if((byte) xd#1>=(byte) e#1) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - (byte~) $14 ← (byte) 39 + (byte) 1 - if((byte) x#1<(byte~) $14) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) xd#1 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte) main::e#0 ← (byte) 24 / (byte) 2 + (byte~) main::$3 ← (byte) 0 * (byte) 40 + (byte*) main::cursor#0 ← (byte~) main::$3 + (word) 1024 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) + (byte) main::xd#1 ← phi( main/(byte) 39 ) + (byte) main::yd#1 ← phi( main/(byte) 24 ) + (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + *((byte*) main::cursor#3) ← (byte) 81 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) main::yd#1 + if((byte) main::xd#1>=(byte) main::e#1) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + (byte~) main::$14 ← (byte) 39 + (byte) 1 + if((byte) main::x#1<(byte~) main::$14) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) main::xd#1 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Redundant Phi (byte) yd#1 (byte) 24 -Redundant Phi (byte) xd#1 (byte) 39 +Redundant Phi (byte) main::yd#1 (byte) 24 +Redundant Phi (byte) main::xd#1 (byte) 39 Succesful SSA optimization Pass2RedundantPhiElimination CONTROL FLOW GRAPH @begin: scope:[] from - (byte) e#0 ← (byte) 24 / (byte) 2 - (byte~) $3 ← (byte) 0 * (byte) 40 - (byte*) cursor#0 ← (byte~) $3 + (word) 1024 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) e#0 ) - (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - *((byte*) cursor#3) ← (byte) 81 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) 24 - if((byte) 39>=(byte) e#1) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - (byte~) $14 ← (byte) 39 + (byte) 1 - if((byte) x#1<(byte~) $14) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) 39 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte) main::e#0 ← (byte) 24 / (byte) 2 + (byte~) main::$3 ← (byte) 0 * (byte) 40 + (byte*) main::cursor#0 ← (byte~) main::$3 + (word) 1024 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) + (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + *((byte*) main::cursor#3) ← (byte) 81 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 + if((byte) 39>=(byte) main::e#1) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + (byte~) main::$14 ← (byte) 39 + (byte) 1 + if((byte) main::x#1<(byte~) main::$14) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Constant (byte) e#0 (byte) 12 -Constant (byte~) $3 (byte) 0 -Constant (byte~) $14 (byte) 40 +Constant (byte) main::e#0 (byte) 12 +Constant (byte~) main::$3 (byte) 0 +Constant (byte~) main::$14 (byte) 40 Succesful SSA optimization Pass2ConstantPropagation CONTROL FLOW GRAPH @begin: scope:[] from - (byte*) cursor#0 ← (byte) 0 + (word) 1024 - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) 12 ) - (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(byte*) cursor#0 ) - *((byte*) cursor#3) ← (byte) 81 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) 24 - if((byte) 39>=(byte) e#1) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - if((byte) x#1<(byte) 40) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) 39 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + (byte*) main::cursor#0 ← (byte) 0 + (word) 1024 + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) + (byte) main::e#3 ← phi( main/(byte) 12 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) + (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 ) + *((byte*) main::cursor#3) ← (byte) 81 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 + if((byte) 39>=(byte) main::e#1) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + if((byte) main::x#1<(byte) 40) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Multiple usages for variable. Not optimizing sub-constant (byte) y#2 -Multiple usages for variable. Not optimizing sub-constant (byte*) cursor#1 -Constant (byte*) cursor#0 (word) 1024 +Multiple usages for variable. Not optimizing sub-constant (byte) main::y#2 +Multiple usages for variable. Not optimizing sub-constant (byte*) main::cursor#1 +Constant (byte*) main::cursor#0 (word) 1024 Succesful SSA optimization Pass2ConstantPropagation CONTROL FLOW GRAPH @begin: scope:[] from - to:@1 -@1: scope:[] from @2 @begin - (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) - (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) 12 ) - (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) - (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(word) 1024 ) - *((byte*) cursor#3) ← (byte) 81 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) 24 - if((byte) 39>=(byte) e#1) goto @2 - to:@3 -@2: scope:[] from @1 @3 - (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) - (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) - (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) - if((byte) x#1<(byte) 40) goto @1 + call main param-assignment to:@end -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) 39 - to:@2 -@end: scope:[] from @2 +main: scope:[main] from @begin + to:main::@1 +main::@1: scope:[main] from main main::@2 + (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) + (byte) main::e#3 ← phi( main/(byte) 12 main::@2/(byte) main::e#5 ) + (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) + (byte*) main::cursor#3 ← phi( main/(word) 1024 main::@2/(byte*) main::cursor#5 ) + *((byte*) main::cursor#3) ← (byte) 81 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 + if((byte) 39>=(byte) main::e#1) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 main::@3 + (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) + (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) + (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) + if((byte) main::x#1<(byte) 40) goto main::@1 + to:main::@return +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 + to:main::@2 +main::@return: scope:[main] from main::@2 + return + to:@return +@end: scope:[] from @begin -Multiple usages for variable. Not optimizing sub-constant (byte) y#2 -Multiple usages for variable. Not optimizing sub-constant (byte*) cursor#1 -Multiple usages for variable. Not optimizing sub-constant (byte) y#2 -Multiple usages for variable. Not optimizing sub-constant (byte*) cursor#1 +Multiple usages for variable. Not optimizing sub-constant (byte) main::y#2 +Multiple usages for variable. Not optimizing sub-constant (byte*) main::cursor#1 +Multiple usages for variable. Not optimizing sub-constant (byte) main::y#2 +Multiple usages for variable. Not optimizing sub-constant (byte*) main::cursor#1 FINAL SYMBOL TABLE -(label) @1 -(label) @2 -(label) @3 (label) @begin (label) @end (byte[1000]) SCREEN (byte) STAR -(byte*) cursor -(byte*) cursor#1 -(byte*) cursor#2 -(byte*) cursor#3 -(byte*) cursor#5 -(byte) e -(byte) e#1 -(byte) e#2 -(byte) e#3 -(byte) e#5 -(byte) x -(byte) x#1 -(byte) x#2 -(byte) x0 -(byte) x1 -(byte) xd -(byte) y -(byte) y#1 -(byte) y#2 -(byte) y#4 -(byte) y0 -(byte) y1 -(byte) yd +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@return +(byte*) main::cursor +(byte*) main::cursor#1 +(byte*) main::cursor#2 +(byte*) main::cursor#3 +(byte*) main::cursor#5 +(byte) main::e +(byte) main::e#1 +(byte) main::e#2 +(byte) main::e#3 +(byte) main::e#5 +(byte) main::x +(byte) main::x#1 +(byte) main::x#2 +(byte) main::x0 +(byte) main::x1 +(byte) main::xd +(byte) main::y +(byte) main::y#1 +(byte) main::y#2 +(byte) main::y#4 +(byte) main::y0 +(byte) main::y1 +(byte) main::yd -Block Sequence Planned @begin @1 @3 @2 @end -Added new block during phi lifting @5(between @2 and @1) -Added new block during phi lifting @6(between @1 and @2) -Block Sequence Planned @begin @1 @3 @2 @end @5 @6 +Block Sequence Planned @begin @end main main::@1 main::@3 main::@2 main::@return +Added new block during phi lifting main::@5(between main::@2 and main::@1) +Added new block during phi lifting main::@6(between main::@1 and main::@2) +Block Sequence Planned @begin @end main main::@1 main::@3 main::@2 main::@return main::@5 main::@6 CONTROL FLOW GRAPH - PHI LIFTED @begin: scope:[] from - to:@1 -@1: scope:[] from @5 @begin - (byte) y#2 ← phi( @5/(byte~) y#5 @begin/(byte) 0 ) - (byte) e#3 ← phi( @5/(byte~) e#6 @begin/(byte) 12 ) - (byte) x#2 ← phi( @5/(byte~) x#5 @begin/(byte) 0 ) - (byte*) cursor#3 ← phi( @5/(byte*~) cursor#6 @begin/(word) 1024 ) - *((byte*) cursor#3) ← (byte) 81 - (byte) x#1 ← (byte) x#2 + (byte) 1 - (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 - (byte) e#1 ← (byte) e#3 + (byte) 24 - if((byte) 39>=(byte) e#1) goto @6 - to:@3 -@3: scope:[] from @1 - (byte) y#1 ← (byte) y#2 + (byte) 1 - (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 - (byte) e#2 ← (byte) e#1 - (byte) 39 - (byte*~) cursor#8 ← (byte*) cursor#2 - (byte~) e#8 ← (byte) e#2 - (byte~) y#7 ← (byte) y#1 - to:@2 -@2: scope:[] from @3 @6 - (byte) y#4 ← phi( @6/(byte~) y#6 @3/(byte~) y#7 ) - (byte) e#5 ← phi( @6/(byte~) e#7 @3/(byte~) e#8 ) - (byte*) cursor#5 ← phi( @6/(byte*~) cursor#7 @3/(byte*~) cursor#8 ) - if((byte) x#1<(byte) 40) goto @5 + call main param-assignment to:@end -@end: scope:[] from @2 -@5: scope:[] from @2 - (byte*~) cursor#6 ← (byte*) cursor#5 - (byte~) x#5 ← (byte) x#1 - (byte~) e#6 ← (byte) e#5 - (byte~) y#5 ← (byte) y#4 - to:@1 -@6: scope:[] from @1 - (byte*~) cursor#7 ← (byte*) cursor#1 - (byte~) e#7 ← (byte) e#1 - (byte~) y#6 ← (byte) y#2 - to:@2 +@end: scope:[] from @begin +main: scope:[main] from @begin + to:main::@1 +main::@1: scope:[main] from main main::@5 + (byte) main::y#2 ← phi( main/(byte) 0 main::@5/(byte~) main::y#5 ) + (byte) main::e#3 ← phi( main/(byte) 12 main::@5/(byte~) main::e#6 ) + (byte) main::x#2 ← phi( main/(byte) 0 main::@5/(byte~) main::x#5 ) + (byte*) main::cursor#3 ← phi( main/(word) 1024 main::@5/(byte*~) main::cursor#6 ) + *((byte*) main::cursor#3) ← (byte) 81 + (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 + (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 + (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 + if((byte) 39>=(byte) main::e#1) goto main::@6 + to:main::@3 +main::@3: scope:[main] from main::@1 + (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 + (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 + (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 + (byte*~) main::cursor#8 ← (byte*) main::cursor#2 + (byte~) main::e#8 ← (byte) main::e#2 + (byte~) main::y#7 ← (byte) main::y#1 + to:main::@2 +main::@2: scope:[main] from main::@3 main::@6 + (byte) main::y#4 ← phi( main::@6/(byte~) main::y#6 main::@3/(byte~) main::y#7 ) + (byte) main::e#5 ← phi( main::@6/(byte~) main::e#7 main::@3/(byte~) main::e#8 ) + (byte*) main::cursor#5 ← phi( main::@6/(byte*~) main::cursor#7 main::@3/(byte*~) main::cursor#8 ) + if((byte) main::x#1<(byte) 40) goto main::@5 + to:main::@return +main::@return: scope:[main] from main::@2 + return + to:@return +main::@5: scope:[main] from main::@2 + (byte*~) main::cursor#6 ← (byte*) main::cursor#5 + (byte~) main::x#5 ← (byte) main::x#1 + (byte~) main::e#6 ← (byte) main::e#5 + (byte~) main::y#5 ← (byte) main::y#4 + to:main::@1 +main::@6: scope:[main] from main::@1 + (byte*~) main::cursor#7 ← (byte*) main::cursor#1 + (byte~) main::e#7 ← (byte) main::e#1 + (byte~) main::y#6 ← (byte) main::y#2 + to:main::@2 Propagating live ranges... Propagating live ranges... @@ -1111,60 +1343,66 @@ Propagating live ranges... Propagating live ranges... CONTROL FLOW GRAPH - LIVE RANGES @begin: scope:[] from - to:@1 -@1: scope:[] from @5 @begin - [0] (byte) y#2 ← phi( @5/(byte~) y#5 @begin/(byte) 0 ) [ cursor#3 x#2 e#3 y#2 ] - [0] (byte) e#3 ← phi( @5/(byte~) e#6 @begin/(byte) 12 ) [ cursor#3 x#2 e#3 y#2 ] - [0] (byte) x#2 ← phi( @5/(byte~) x#5 @begin/(byte) 0 ) [ cursor#3 x#2 e#3 y#2 ] - [0] (byte*) cursor#3 ← phi( @5/(byte*~) cursor#6 @begin/(word) 1024 ) [ cursor#3 x#2 e#3 y#2 ] - [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] - [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ cursor#3 e#3 y#2 x#1 ] - [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ e#3 y#2 cursor#1 x#1 ] - [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ e#1 y#2 cursor#1 x#1 ] - [5] if((byte) 39>=(byte) e#1) goto @6 [ e#1 y#2 cursor#1 x#1 ] - to:@3 -@3: scope:[] from @1 - [6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ e#1 cursor#1 y#1 x#1 ] - [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ e#1 cursor#2 y#1 x#1 ] - [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ cursor#2 e#2 y#1 x#1 ] - [9] (byte*~) cursor#8 ← (byte*) cursor#2 [ e#2 y#1 cursor#8 x#1 ] - [10] (byte~) e#8 ← (byte) e#2 [ y#1 cursor#8 e#8 x#1 ] - [11] (byte~) y#7 ← (byte) y#1 [ cursor#8 e#8 y#7 x#1 ] - to:@2 -@2: scope:[] from @3 @6 - [12] (byte) y#4 ← phi( @6/(byte~) y#6 @3/(byte~) y#7 ) [ x#1 cursor#5 e#5 y#4 ] - [12] (byte) e#5 ← phi( @6/(byte~) e#7 @3/(byte~) e#8 ) [ x#1 cursor#5 e#5 y#4 ] - [12] (byte*) cursor#5 ← phi( @6/(byte*~) cursor#7 @3/(byte*~) cursor#8 ) [ x#1 cursor#5 e#5 y#4 ] - [13] if((byte) x#1<(byte) 40) goto @5 [ x#1 cursor#5 e#5 y#4 ] + [0] call main param-assignment [ ] to:@end -@end: scope:[] from @2 -@5: scope:[] from @2 - [14] (byte*~) cursor#6 ← (byte*) cursor#5 [ cursor#6 x#1 e#5 y#4 ] - [15] (byte~) x#5 ← (byte) x#1 [ cursor#6 x#5 e#5 y#4 ] - [16] (byte~) e#6 ← (byte) e#5 [ cursor#6 x#5 e#6 y#4 ] - [17] (byte~) y#5 ← (byte) y#4 [ cursor#6 x#5 e#6 y#5 ] - to:@1 -@6: scope:[] from @1 - [18] (byte*~) cursor#7 ← (byte*) cursor#1 [ e#1 y#2 cursor#7 x#1 ] - [19] (byte~) e#7 ← (byte) e#1 [ y#2 cursor#7 e#7 x#1 ] - [20] (byte~) y#6 ← (byte) y#2 [ cursor#7 e#7 y#6 x#1 ] - to:@2 +@end: scope:[] from @begin +main: scope:[main] from @begin + to:main::@1 +main::@1: scope:[main] from main main::@5 + [1] (byte) main::y#2 ← phi( main/(byte) 0 main::@5/(byte~) main::y#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [1] (byte) main::e#3 ← phi( main/(byte) 12 main::@5/(byte~) main::e#6 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [1] (byte) main::x#2 ← phi( main/(byte) 0 main::@5/(byte~) main::x#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [1] (byte*) main::cursor#3 ← phi( main/(word) 1024 main::@5/(byte*~) main::cursor#6 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] + [4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::e#3 main::y#2 main::cursor#1 main::x#1 ] + [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::e#1 main::y#2 main::cursor#1 main::x#1 ] + [6] if((byte) 39>=(byte) main::e#1) goto main::@6 [ main::e#1 main::y#2 main::cursor#1 main::x#1 ] + to:main::@3 +main::@3: scope:[main] from main::@1 + [7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::e#1 main::cursor#1 main::y#1 main::x#1 ] + [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::e#1 main::cursor#2 main::y#1 main::x#1 ] + [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::cursor#2 main::e#2 main::y#1 main::x#1 ] + [10] (byte*~) main::cursor#8 ← (byte*) main::cursor#2 [ main::e#2 main::y#1 main::cursor#8 main::x#1 ] + [11] (byte~) main::e#8 ← (byte) main::e#2 [ main::y#1 main::cursor#8 main::e#8 main::x#1 ] + [12] (byte~) main::y#7 ← (byte) main::y#1 [ main::cursor#8 main::e#8 main::y#7 main::x#1 ] + to:main::@2 +main::@2: scope:[main] from main::@3 main::@6 + [13] (byte) main::y#4 ← phi( main::@6/(byte~) main::y#6 main::@3/(byte~) main::y#7 ) [ main::x#1 main::cursor#5 main::e#5 main::y#4 ] + [13] (byte) main::e#5 ← phi( main::@6/(byte~) main::e#7 main::@3/(byte~) main::e#8 ) [ main::x#1 main::cursor#5 main::e#5 main::y#4 ] + [13] (byte*) main::cursor#5 ← phi( main::@6/(byte*~) main::cursor#7 main::@3/(byte*~) main::cursor#8 ) [ main::x#1 main::cursor#5 main::e#5 main::y#4 ] + [14] if((byte) main::x#1<(byte) 40) goto main::@5 [ main::x#1 main::cursor#5 main::e#5 main::y#4 ] + to:main::@return +main::@return: scope:[main] from main::@2 + [15] return [ ] + to:@return +main::@5: scope:[main] from main::@2 + [16] (byte*~) main::cursor#6 ← (byte*) main::cursor#5 [ main::cursor#6 main::x#1 main::e#5 main::y#4 ] + [17] (byte~) main::x#5 ← (byte) main::x#1 [ main::cursor#6 main::x#5 main::e#5 main::y#4 ] + [18] (byte~) main::e#6 ← (byte) main::e#5 [ main::cursor#6 main::x#5 main::e#6 main::y#4 ] + [19] (byte~) main::y#5 ← (byte) main::y#4 [ main::cursor#6 main::x#5 main::e#6 main::y#5 ] + to:main::@1 +main::@6: scope:[main] from main::@1 + [20] (byte*~) main::cursor#7 ← (byte*) main::cursor#1 [ main::e#1 main::y#2 main::cursor#7 main::x#1 ] + [21] (byte~) main::e#7 ← (byte) main::e#1 [ main::y#2 main::cursor#7 main::e#7 main::x#1 ] + [22] (byte~) main::y#6 ← (byte) main::y#2 [ main::cursor#7 main::e#7 main::y#6 main::x#1 ] + to:main::@2 Created 7 initial phi equivalence classes -Coalesced [9] cursor#8 ← cursor#2 -Coalesced [10] e#8 ← e#2 -Coalesced [11] y#7 ← y#1 -Coalesced [14] cursor#6 ← cursor#5 -Coalesced [15] x#5 ← x#1 -Coalesced [16] e#6 ← e#5 -Coalesced [17] y#5 ← y#4 -Coalesced [18] cursor#7 ← cursor#1 -Coalesced [19] e#7 ← e#1 -Coalesced (already) [20] y#6 ← y#2 +Coalesced [10] main::cursor#8 ← main::cursor#2 +Coalesced [11] main::e#8 ← main::e#2 +Coalesced [12] main::y#7 ← main::y#1 +Coalesced [16] main::cursor#6 ← main::cursor#5 +Coalesced [17] main::x#5 ← main::x#1 +Coalesced [18] main::e#6 ← main::e#5 +Coalesced [19] main::y#5 ← main::y#4 +Coalesced [20] main::cursor#7 ← main::cursor#1 +Coalesced [21] main::e#7 ← main::e#1 +Coalesced (already) [22] main::y#6 ← main::y#2 Coalesced down to 4 phi equivalence classes -Culled Empty Block (label) @5 -Culled Empty Block (label) @6 -Block Sequence Planned @begin @1 @3 @2 @end +Culled Empty Block (label) main::@5 +Culled Empty Block (label) main::@6 +Block Sequence Planned @begin @end main main::@1 main::@3 main::@2 main::@return Propagating live ranges... Propagating live ranges... Propagating live ranges... @@ -1173,646 +1411,716 @@ Propagating live ranges... Propagating live ranges... CONTROL FLOW GRAPH - PHI MEM COALESCED @begin: scope:[] from - to:@1 -@1: scope:[] from @2 @begin - [0] (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) [ cursor#3 x#2 e#3 y#2 ] - [0] (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) 12 ) [ cursor#3 x#2 e#3 y#2 ] - [0] (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) [ cursor#3 x#2 e#3 y#2 ] - [0] (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(word) 1024 ) [ cursor#3 x#2 e#3 y#2 ] - [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] - [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] - [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 y#2 cursor#1 ] - [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] - [5] if((byte) 39>=(byte) e#1) goto @2 [ x#1 e#1 y#2 cursor#1 ] - to:@3 -@3: scope:[] from @1 - [6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] - [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] - [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] - to:@2 -@2: scope:[] from @1 @3 - [9] (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) [ cursor#5 x#1 e#5 y#4 ] - [9] (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) [ cursor#5 x#1 e#5 y#4 ] - [9] (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) [ cursor#5 x#1 e#5 y#4 ] - [10] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] + [0] call main param-assignment [ ] to:@end -@end: scope:[] from @2 +@end: scope:[] from @begin +main: scope:[main] from @begin + to:main::@1 +main::@1: scope:[main] from main main::@2 + [1] (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [1] (byte) main::e#3 ← phi( main/(byte) 12 main::@2/(byte) main::e#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [1] (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [1] (byte*) main::cursor#3 ← phi( main/(word) 1024 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] + [3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::x#1 main::cursor#3 main::e#3 main::y#2 ] + [4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::x#1 main::e#3 main::y#2 main::cursor#1 ] + [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] + [6] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] + to:main::@3 +main::@3: scope:[main] from main::@1 + [7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::e#1 main::cursor#1 main::y#1 ] + [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] + [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] + to:main::@2 +main::@2: scope:[main] from main::@1 main::@3 + [10] (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] + [10] (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] + [10] (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] + [11] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] + to:main::@return +main::@return: scope:[main] from main::@2 + [12] return [ ] + to:@return CALL GRAPH +Calls in [] to 0:main DOMINATORS @begin dominated by @begin -@1 dominated by @1 @begin -@3 dominated by @1 @3 @begin -@2 dominated by @1 @2 @begin -@end dominated by @1 @2 @end @begin +@end dominated by @end @begin +main dominated by @begin main +main::@1 dominated by @begin main::@1 main +main::@3 dominated by @begin main::@1 main::@3 main +main::@2 dominated by @begin main::@2 main::@1 main +main::@return dominated by main::@return @begin main::@2 main::@1 main -Found back edge: Loop head: @1 tails: @2 blocks: null -Populated: Loop head: @1 tails: @2 blocks: @2 @1 @3 +Found back edge: Loop head: main::@1 tails: main::@2 blocks: null +Populated: Loop head: main::@1 tails: main::@2 blocks: main::@2 main::@1 main::@3 NATURAL LOOPS -Loop head: @1 tails: @2 blocks: @2 @1 @3 +Loop head: main::@1 tails: main::@2 blocks: main::@2 main::@1 main::@3 -Found 1 loops in scope [] - Loop head: @1 tails: @2 blocks: @2 @1 @3 +Found 0 loops in scope [] +Found 1 loops in scope [main] + Loop head: main::@1 tails: main::@2 blocks: main::@2 main::@1 main::@3 NATURAL LOOPS WITH DEPTH -Loop head: @1 tails: @2 blocks: @2 @1 @3 depth: 1 +Loop head: main::@1 tails: main::@2 blocks: main::@2 main::@1 main::@3 depth: 1 VARIABLE REGISTER WEIGHTS (byte[1000]) SCREEN (byte) STAR -(byte*) cursor -(byte*) cursor#1 8.25 -(byte*) cursor#2 11.0 -(byte*) cursor#3 11.0 -(byte*) cursor#5 16.5 -(byte) e -(byte) e#1 11.0 -(byte) e#2 22.0 -(byte) e#3 5.5 -(byte) e#5 16.5 -(byte) x -(byte) x#1 3.666666666666667 -(byte) x#2 11.0 -(byte) x0 -(byte) x1 -(byte) xd -(byte) y -(byte) y#1 7.333333333333333 -(byte) y#2 5.5 -(byte) y#4 16.5 -(byte) y0 -(byte) y1 -(byte) yd +(void()) main() +(byte*) main::cursor +(byte*) main::cursor#1 8.25 +(byte*) main::cursor#2 11.0 +(byte*) main::cursor#3 11.0 +(byte*) main::cursor#5 16.5 +(byte) main::e +(byte) main::e#1 11.0 +(byte) main::e#2 22.0 +(byte) main::e#3 5.5 +(byte) main::e#5 16.5 +(byte) main::x +(byte) main::x#1 3.666666666666667 +(byte) main::x#2 11.0 +(byte) main::x0 +(byte) main::x1 +(byte) main::xd +(byte) main::y +(byte) main::y#1 7.333333333333333 +(byte) main::y#2 5.5 +(byte) main::y#4 16.5 +(byte) main::y0 +(byte) main::y1 +(byte) main::yd Initial phi equivalence classes -[ cursor#3 cursor#5 cursor#1 cursor#2 ] -[ x#2 x#1 ] -[ e#3 e#5 e#1 e#2 ] -[ y#2 y#4 y#1 ] +[ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] +[ main::x#2 main::x#1 ] +[ main::e#3 main::e#5 main::e#1 main::e#2 ] +[ main::y#2 main::y#4 main::y#1 ] Complete equivalence classes -[ cursor#3 cursor#5 cursor#1 cursor#2 ] -[ x#2 x#1 ] -[ e#3 e#5 e#1 e#2 ] -[ y#2 y#4 y#1 ] -Allocated zp ptr byte:2 [ cursor#3 cursor#5 cursor#1 cursor#2 ] -Allocated zp byte:4 [ x#2 x#1 ] -Allocated zp byte:5 [ e#3 e#5 e#1 e#2 ] -Allocated zp byte:6 [ y#2 y#4 y#1 ] +[ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] +[ main::x#2 main::x#1 ] +[ main::e#3 main::e#5 main::e#1 main::e#2 ] +[ main::y#2 main::y#4 main::y#1 ] +Allocated zp ptr byte:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] +Allocated zp byte:4 [ main::x#2 main::x#1 ] +Allocated zp byte:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] +Allocated zp byte:6 [ main::y#2 main::y#4 main::y#1 ] INITIAL ASM //SEG0 @begin bbegin: -//SEG1 [0] phi from @begin to @1 -b1_from_bbegin: -//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $6 -//SEG3 [0] phi (byte) e#3 = (byte) 12 -- zpby1=coby1 - lda #$c - sta $5 -//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $4 -//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1 - lda #<$400 - sta $2 - lda #>$400 - sta $2+$1 - jmp b1 -//SEG6 [0] phi from @2 to @1 -b1_from_b2: -//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy -//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy -//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy -//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy - jmp b1 -//SEG11 @1 -b1: -//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1 - ldy #$0 - lda #$51 - sta ($2),y -//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1 - inc $4 -//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 y#2 cursor#1 ] -- zpptrby1=zpptrby1_plus_1 - inc $2 - bne !+ - inc $2+$1 -!: -//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] -- zpby1=zpby1_plus_coby1 - lda $5 - clc - adc #$18 - sta $5 -//SEG16 [5] if((byte) 39>=(byte) e#1) goto @2 [ x#1 e#1 y#2 cursor#1 ] -- coby1_ge_zpby1_then_la1 - lda #$27 - cmp $5 - bcs b2_from_b1 - jmp b3 -//SEG17 @3 -b3: -//SEG18 [6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1 - inc $6 -//SEG19 [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1 - lda $2 - clc - adc #$28 - sta $2 - bcc !+ - inc $2+$1 -!: -//SEG20 [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- zpby1=zpby1_minus_coby1 - lda $5 - sec - sbc #$27 - sta $5 -//SEG21 [9] phi from @3 to @2 -b2_from_b3: -//SEG22 [9] phi (byte) y#4 = (byte) y#1 -- register_copy -//SEG23 [9] phi (byte) e#5 = (byte) e#2 -- register_copy -//SEG24 [9] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy - jmp b2 -//SEG25 [9] phi from @1 to @2 -b2_from_b1: -//SEG26 [9] phi (byte) y#4 = (byte) y#2 -- register_copy -//SEG27 [9] phi (byte) e#5 = (byte) e#1 -- register_copy -//SEG28 [9] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy - jmp b2 -//SEG29 @2 -b2: -//SEG30 [10] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1 - lda $4 - cmp #$28 - bcc b1_from_b2 +//SEG1 [0] call main param-assignment [ ] + jsr main jmp bend -//SEG31 @end +//SEG2 @end bend: +//SEG3 main +main: { + //SEG4 [1] phi from main to main::@1 + b1_from_main: + //SEG5 [1] phi (byte) main::y#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $6 + //SEG6 [1] phi (byte) main::e#3 = (byte) 12 -- zpby1=coby1 + lda #$c + sta $5 + //SEG7 [1] phi (byte) main::x#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $4 + //SEG8 [1] phi (byte*) main::cursor#3 = (word) 1024 -- zpptrby1=cowo1 + lda #<$400 + sta $2 + lda #>$400 + sta $2+$1 + jmp b1 + //SEG9 [1] phi from main::@2 to main::@1 + b1_from_b2: + //SEG10 [1] phi (byte) main::y#2 = (byte) main::y#4 -- register_copy + //SEG11 [1] phi (byte) main::e#3 = (byte) main::e#5 -- register_copy + //SEG12 [1] phi (byte) main::x#2 = (byte) main::x#1 -- register_copy + //SEG13 [1] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 -- register_copy + jmp b1 + //SEG14 main::@1 + b1: + //SEG15 [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] -- _star_zpptrby1=coby1 + ldy #$0 + lda #$51 + sta ($2),y + //SEG16 [3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::x#1 main::cursor#3 main::e#3 main::y#2 ] -- zpby1=zpby1_plus_1 + inc $4 + //SEG17 [4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::x#1 main::e#3 main::y#2 main::cursor#1 ] -- zpptrby1=zpptrby1_plus_1 + inc $2 + bne !+ + inc $2+$1 + !: + //SEG18 [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- zpby1=zpby1_plus_coby1 + lda $5 + clc + adc #$18 + sta $5 + //SEG19 [6] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- coby1_ge_zpby1_then_la1 + lda #$27 + cmp $5 + bcs b2_from_b1 + jmp b3 + //SEG20 main::@3 + b3: + //SEG21 [7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::e#1 main::cursor#1 main::y#1 ] -- zpby1=zpby1_plus_1 + inc $6 + //SEG22 [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] -- zpptrby1=zpptrby1_plus_coby1 + lda $2 + clc + adc #$28 + sta $2 + bcc !+ + inc $2+$1 + !: + //SEG23 [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] -- zpby1=zpby1_minus_coby1 + lda $5 + sec + sbc #$27 + sta $5 + //SEG24 [10] phi from main::@3 to main::@2 + b2_from_b3: + //SEG25 [10] phi (byte) main::y#4 = (byte) main::y#1 -- register_copy + //SEG26 [10] phi (byte) main::e#5 = (byte) main::e#2 -- register_copy + //SEG27 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#2 -- register_copy + jmp b2 + //SEG28 [10] phi from main::@1 to main::@2 + b2_from_b1: + //SEG29 [10] phi (byte) main::y#4 = (byte) main::y#2 -- register_copy + //SEG30 [10] phi (byte) main::e#5 = (byte) main::e#1 -- register_copy + //SEG31 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 -- register_copy + jmp b2 + //SEG32 main::@2 + b2: + //SEG33 [11] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] -- zpby1_lt_coby1_then_la1 + lda $4 + cmp #$28 + bcc b1_from_b2 + jmp breturn + //SEG34 main::@return + breturn: + //SEG35 [12] return [ ] + rts +} -Statement [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] always clobbers reg byte a reg byte y -Removing always clobbered register reg byte a as potential for zp byte:4 [ x#2 x#1 ] -Removing always clobbered register reg byte y as potential for zp byte:4 [ x#2 x#1 ] -Removing always clobbered register reg byte a as potential for zp byte:5 [ e#3 e#5 e#1 e#2 ] -Removing always clobbered register reg byte y as potential for zp byte:5 [ e#3 e#5 e#1 e#2 ] -Removing always clobbered register reg byte a as potential for zp byte:6 [ y#2 y#4 y#1 ] -Removing always clobbered register reg byte y as potential for zp byte:6 [ y#2 y#4 y#1 ] -Statement [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] always clobbers reg byte a -Statement [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] always clobbers reg byte a -Statement [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] always clobbers reg byte a -Statement [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] always clobbers reg byte a reg byte y -Statement [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] always clobbers reg byte a -Statement [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] always clobbers reg byte a -Statement [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] always clobbers reg byte a +Statement [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] always clobbers reg byte a reg byte y +Removing always clobbered register reg byte a as potential for zp byte:4 [ main::x#2 main::x#1 ] +Removing always clobbered register reg byte y as potential for zp byte:4 [ main::x#2 main::x#1 ] +Removing always clobbered register reg byte a as potential for zp byte:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] +Removing always clobbered register reg byte y as potential for zp byte:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] +Removing always clobbered register reg byte a as potential for zp byte:6 [ main::y#2 main::y#4 main::y#1 ] +Removing always clobbered register reg byte y as potential for zp byte:6 [ main::y#2 main::y#4 main::y#1 ] +Statement [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] always clobbers reg byte a +Statement [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] always clobbers reg byte a +Statement [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] always clobbers reg byte a +Statement [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] always clobbers reg byte a reg byte y +Statement [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] always clobbers reg byte a +Statement [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] always clobbers reg byte a +Statement [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] always clobbers reg byte a REGISTER UPLIFT POTENTIAL REGISTERS -Potential registers zp ptr byte:2 [ cursor#3 cursor#5 cursor#1 cursor#2 ] : zp ptr byte:2 , -Potential registers zp byte:4 [ x#2 x#1 ] : zp byte:4 , reg byte x , -Potential registers zp byte:5 [ e#3 e#5 e#1 e#2 ] : zp byte:5 , reg byte x , -Potential registers zp byte:6 [ y#2 y#4 y#1 ] : zp byte:6 , reg byte x , +Potential registers zp ptr byte:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] : zp ptr byte:2 , +Potential registers zp byte:4 [ main::x#2 main::x#1 ] : zp byte:4 , reg byte x , +Potential registers zp byte:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] : zp byte:5 , reg byte x , +Potential registers zp byte:6 [ main::y#2 main::y#4 main::y#1 ] : zp byte:6 , reg byte x , REGISTER UPLIFT SCOPES -Uplift Scope [] 55: zp byte:5 [ e#3 e#5 e#1 e#2 ] 46.75: zp ptr byte:2 [ cursor#3 cursor#5 cursor#1 cursor#2 ] 29.33: zp byte:6 [ y#2 y#4 y#1 ] 14.67: zp byte:4 [ x#2 x#1 ] +Uplift Scope [main] 55: zp byte:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] 46.75: zp ptr byte:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] 29.33: zp byte:6 [ main::y#2 main::y#4 main::y#1 ] 14.67: zp byte:4 [ main::x#2 main::x#1 ] +Uplift Scope [] -Uplifting [] best 1210 combination reg byte x [ e#3 e#5 e#1 e#2 ] zp ptr byte:2 [ cursor#3 cursor#5 cursor#1 cursor#2 ] zp byte:6 [ y#2 y#4 y#1 ] zp byte:4 [ x#2 x#1 ] -Allocated (was zp byte:6) zp byte:5 [ y#2 y#4 y#1 ] +Uplifting [main] best 1225 combination reg byte x [ main::e#3 main::e#5 main::e#1 main::e#2 ] zp ptr byte:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] zp byte:6 [ main::y#2 main::y#4 main::y#1 ] zp byte:4 [ main::x#2 main::x#1 ] +Uplifting [] best 1225 combination +Allocated (was zp byte:6) zp byte:5 [ main::y#2 main::y#4 main::y#1 ] +Removing instruction jmp bend Removing instruction jmp b1 Removing instruction jmp b3 Removing instruction jmp b2 -Removing instruction jmp bend +Removing instruction jmp breturn Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin bbegin: -//SEG1 [0] phi from @begin to @1 -b1_from_bbegin: -//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $5 -//SEG3 [0] phi (byte) e#3 = (byte) 12 -- xby=coby1 - ldx #$c -//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $4 -//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1 - lda #<$400 - sta $2 - lda #>$400 - sta $2+$1 - jmp b1 -//SEG6 [0] phi from @2 to @1 -b1_from_b2: -//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy -//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy -//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy -//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy -//SEG11 @1 -b1: -//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1 - ldy #$0 - lda #$51 - sta ($2),y -//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1 - inc $4 -//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 y#2 cursor#1 ] -- zpptrby1=zpptrby1_plus_1 - inc $2 - bne !+ - inc $2+$1 -!: -//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] -- xby=xby_plus_coby1 - txa - clc - adc #$18 - tax -//SEG16 [5] if((byte) 39>=(byte) e#1) goto @2 [ x#1 e#1 y#2 cursor#1 ] -- coby1_ge_xby_then_la1 - cpx #$27 - bcc b2_from_b1 -//SEG17 @3 -b3: -//SEG18 [6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1 - inc $5 -//SEG19 [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1 - lda $2 - clc - adc #$28 - sta $2 - bcc !+ - inc $2+$1 -!: -//SEG20 [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- xby=xby_minus_coby1 - txa - sec - sbc #$27 - tax -//SEG21 [9] phi from @3 to @2 -b2_from_b3: -//SEG22 [9] phi (byte) y#4 = (byte) y#1 -- register_copy -//SEG23 [9] phi (byte) e#5 = (byte) e#2 -- register_copy -//SEG24 [9] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy - jmp b2 -//SEG25 [9] phi from @1 to @2 -b2_from_b1: -//SEG26 [9] phi (byte) y#4 = (byte) y#2 -- register_copy -//SEG27 [9] phi (byte) e#5 = (byte) e#1 -- register_copy -//SEG28 [9] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy -//SEG29 @2 -b2: -//SEG30 [10] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1 - lda $4 - cmp #$28 - bcc b1_from_b2 -//SEG31 @end +//SEG1 [0] call main param-assignment [ ] + jsr main +//SEG2 @end bend: +//SEG3 main +main: { + //SEG4 [1] phi from main to main::@1 + b1_from_main: + //SEG5 [1] phi (byte) main::y#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $5 + //SEG6 [1] phi (byte) main::e#3 = (byte) 12 -- xby=coby1 + ldx #$c + //SEG7 [1] phi (byte) main::x#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $4 + //SEG8 [1] phi (byte*) main::cursor#3 = (word) 1024 -- zpptrby1=cowo1 + lda #<$400 + sta $2 + lda #>$400 + sta $2+$1 + jmp b1 + //SEG9 [1] phi from main::@2 to main::@1 + b1_from_b2: + //SEG10 [1] phi (byte) main::y#2 = (byte) main::y#4 -- register_copy + //SEG11 [1] phi (byte) main::e#3 = (byte) main::e#5 -- register_copy + //SEG12 [1] phi (byte) main::x#2 = (byte) main::x#1 -- register_copy + //SEG13 [1] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 -- register_copy + //SEG14 main::@1 + b1: + //SEG15 [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] -- _star_zpptrby1=coby1 + ldy #$0 + lda #$51 + sta ($2),y + //SEG16 [3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::x#1 main::cursor#3 main::e#3 main::y#2 ] -- zpby1=zpby1_plus_1 + inc $4 + //SEG17 [4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::x#1 main::e#3 main::y#2 main::cursor#1 ] -- zpptrby1=zpptrby1_plus_1 + inc $2 + bne !+ + inc $2+$1 + !: + //SEG18 [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- xby=xby_plus_coby1 + txa + clc + adc #$18 + tax + //SEG19 [6] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- coby1_ge_xby_then_la1 + cpx #$27 + bcc b2_from_b1 + //SEG20 main::@3 + b3: + //SEG21 [7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::e#1 main::cursor#1 main::y#1 ] -- zpby1=zpby1_plus_1 + inc $5 + //SEG22 [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] -- zpptrby1=zpptrby1_plus_coby1 + lda $2 + clc + adc #$28 + sta $2 + bcc !+ + inc $2+$1 + !: + //SEG23 [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] -- xby=xby_minus_coby1 + txa + sec + sbc #$27 + tax + //SEG24 [10] phi from main::@3 to main::@2 + b2_from_b3: + //SEG25 [10] phi (byte) main::y#4 = (byte) main::y#1 -- register_copy + //SEG26 [10] phi (byte) main::e#5 = (byte) main::e#2 -- register_copy + //SEG27 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#2 -- register_copy + jmp b2 + //SEG28 [10] phi from main::@1 to main::@2 + b2_from_b1: + //SEG29 [10] phi (byte) main::y#4 = (byte) main::y#2 -- register_copy + //SEG30 [10] phi (byte) main::e#5 = (byte) main::e#1 -- register_copy + //SEG31 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 -- register_copy + //SEG32 main::@2 + b2: + //SEG33 [11] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] -- zpby1_lt_coby1_then_la1 + lda $4 + cmp #$28 + bcc b1_from_b2 + //SEG34 main::@return + breturn: + //SEG35 [12] return [ ] + rts +} Replacing label b2_from_b1 with b2 Replacing label b1_from_b2 with b1 -Removing instruction b1_from_bbegin: Removing instruction b1_from_b2: Removing instruction b2_from_b1: Succesful ASM optimization Pass5RedundantLabelElimination ASSEMBLER //SEG0 @begin bbegin: -//SEG1 [0] phi from @begin to @1 -//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $5 -//SEG3 [0] phi (byte) e#3 = (byte) 12 -- xby=coby1 - ldx #$c -//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $4 -//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1 - lda #<$400 - sta $2 - lda #>$400 - sta $2+$1 - jmp b1 -//SEG6 [0] phi from @2 to @1 -//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy -//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy -//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy -//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy -//SEG11 @1 -b1: -//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1 - ldy #$0 - lda #$51 - sta ($2),y -//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1 - inc $4 -//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 y#2 cursor#1 ] -- zpptrby1=zpptrby1_plus_1 - inc $2 - bne !+ - inc $2+$1 -!: -//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] -- xby=xby_plus_coby1 - txa - clc - adc #$18 - tax -//SEG16 [5] if((byte) 39>=(byte) e#1) goto @2 [ x#1 e#1 y#2 cursor#1 ] -- coby1_ge_xby_then_la1 - cpx #$27 - bcc b2 -//SEG17 @3 -b3: -//SEG18 [6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1 - inc $5 -//SEG19 [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1 - lda $2 - clc - adc #$28 - sta $2 - bcc !+ - inc $2+$1 -!: -//SEG20 [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- xby=xby_minus_coby1 - txa - sec - sbc #$27 - tax -//SEG21 [9] phi from @3 to @2 -b2_from_b3: -//SEG22 [9] phi (byte) y#4 = (byte) y#1 -- register_copy -//SEG23 [9] phi (byte) e#5 = (byte) e#2 -- register_copy -//SEG24 [9] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy - jmp b2 -//SEG25 [9] phi from @1 to @2 -//SEG26 [9] phi (byte) y#4 = (byte) y#2 -- register_copy -//SEG27 [9] phi (byte) e#5 = (byte) e#1 -- register_copy -//SEG28 [9] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy -//SEG29 @2 -b2: -//SEG30 [10] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1 - lda $4 - cmp #$28 - bcc b1 -//SEG31 @end +//SEG1 [0] call main param-assignment [ ] + jsr main +//SEG2 @end bend: +//SEG3 main +main: { + //SEG4 [1] phi from main to main::@1 + b1_from_main: + //SEG5 [1] phi (byte) main::y#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $5 + //SEG6 [1] phi (byte) main::e#3 = (byte) 12 -- xby=coby1 + ldx #$c + //SEG7 [1] phi (byte) main::x#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $4 + //SEG8 [1] phi (byte*) main::cursor#3 = (word) 1024 -- zpptrby1=cowo1 + lda #<$400 + sta $2 + lda #>$400 + sta $2+$1 + jmp b1 + //SEG9 [1] phi from main::@2 to main::@1 + //SEG10 [1] phi (byte) main::y#2 = (byte) main::y#4 -- register_copy + //SEG11 [1] phi (byte) main::e#3 = (byte) main::e#5 -- register_copy + //SEG12 [1] phi (byte) main::x#2 = (byte) main::x#1 -- register_copy + //SEG13 [1] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 -- register_copy + //SEG14 main::@1 + b1: + //SEG15 [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] -- _star_zpptrby1=coby1 + ldy #$0 + lda #$51 + sta ($2),y + //SEG16 [3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::x#1 main::cursor#3 main::e#3 main::y#2 ] -- zpby1=zpby1_plus_1 + inc $4 + //SEG17 [4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::x#1 main::e#3 main::y#2 main::cursor#1 ] -- zpptrby1=zpptrby1_plus_1 + inc $2 + bne !+ + inc $2+$1 + !: + //SEG18 [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- xby=xby_plus_coby1 + txa + clc + adc #$18 + tax + //SEG19 [6] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- coby1_ge_xby_then_la1 + cpx #$27 + bcc b2 + //SEG20 main::@3 + b3: + //SEG21 [7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::e#1 main::cursor#1 main::y#1 ] -- zpby1=zpby1_plus_1 + inc $5 + //SEG22 [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] -- zpptrby1=zpptrby1_plus_coby1 + lda $2 + clc + adc #$28 + sta $2 + bcc !+ + inc $2+$1 + !: + //SEG23 [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] -- xby=xby_minus_coby1 + txa + sec + sbc #$27 + tax + //SEG24 [10] phi from main::@3 to main::@2 + b2_from_b3: + //SEG25 [10] phi (byte) main::y#4 = (byte) main::y#1 -- register_copy + //SEG26 [10] phi (byte) main::e#5 = (byte) main::e#2 -- register_copy + //SEG27 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#2 -- register_copy + jmp b2 + //SEG28 [10] phi from main::@1 to main::@2 + //SEG29 [10] phi (byte) main::y#4 = (byte) main::y#2 -- register_copy + //SEG30 [10] phi (byte) main::e#5 = (byte) main::e#1 -- register_copy + //SEG31 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 -- register_copy + //SEG32 main::@2 + b2: + //SEG33 [11] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] -- zpby1_lt_coby1_then_la1 + lda $4 + cmp #$28 + bcc b1 + //SEG34 main::@return + breturn: + //SEG35 [12] return [ ] + rts +} Removing instruction bbegin: +Removing instruction bend: +Removing instruction b1_from_main: Removing instruction b3: Removing instruction b2_from_b3: -Removing instruction bend: +Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination ASSEMBLER //SEG0 @begin -//SEG1 [0] phi from @begin to @1 -//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $5 -//SEG3 [0] phi (byte) e#3 = (byte) 12 -- xby=coby1 - ldx #$c -//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $4 -//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1 - lda #<$400 - sta $2 - lda #>$400 - sta $2+$1 - jmp b1 -//SEG6 [0] phi from @2 to @1 -//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy -//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy -//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy -//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy -//SEG11 @1 -b1: -//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1 - ldy #$0 - lda #$51 - sta ($2),y -//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1 - inc $4 -//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 y#2 cursor#1 ] -- zpptrby1=zpptrby1_plus_1 - inc $2 - bne !+ - inc $2+$1 -!: -//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] -- xby=xby_plus_coby1 - txa - clc - adc #$18 - tax -//SEG16 [5] if((byte) 39>=(byte) e#1) goto @2 [ x#1 e#1 y#2 cursor#1 ] -- coby1_ge_xby_then_la1 - cpx #$27 - bcc b2 -//SEG17 @3 -//SEG18 [6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1 - inc $5 -//SEG19 [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1 - lda $2 - clc - adc #$28 - sta $2 - bcc !+ - inc $2+$1 -!: -//SEG20 [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- xby=xby_minus_coby1 - txa - sec - sbc #$27 - tax -//SEG21 [9] phi from @3 to @2 -//SEG22 [9] phi (byte) y#4 = (byte) y#1 -- register_copy -//SEG23 [9] phi (byte) e#5 = (byte) e#2 -- register_copy -//SEG24 [9] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy - jmp b2 -//SEG25 [9] phi from @1 to @2 -//SEG26 [9] phi (byte) y#4 = (byte) y#2 -- register_copy -//SEG27 [9] phi (byte) e#5 = (byte) e#1 -- register_copy -//SEG28 [9] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy -//SEG29 @2 -b2: -//SEG30 [10] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1 - lda $4 - cmp #$28 - bcc b1 -//SEG31 @end +//SEG1 [0] call main param-assignment [ ] + jsr main +//SEG2 @end +//SEG3 main +main: { + //SEG4 [1] phi from main to main::@1 + //SEG5 [1] phi (byte) main::y#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $5 + //SEG6 [1] phi (byte) main::e#3 = (byte) 12 -- xby=coby1 + ldx #$c + //SEG7 [1] phi (byte) main::x#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $4 + //SEG8 [1] phi (byte*) main::cursor#3 = (word) 1024 -- zpptrby1=cowo1 + lda #<$400 + sta $2 + lda #>$400 + sta $2+$1 + jmp b1 + //SEG9 [1] phi from main::@2 to main::@1 + //SEG10 [1] phi (byte) main::y#2 = (byte) main::y#4 -- register_copy + //SEG11 [1] phi (byte) main::e#3 = (byte) main::e#5 -- register_copy + //SEG12 [1] phi (byte) main::x#2 = (byte) main::x#1 -- register_copy + //SEG13 [1] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 -- register_copy + //SEG14 main::@1 + b1: + //SEG15 [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] -- _star_zpptrby1=coby1 + ldy #$0 + lda #$51 + sta ($2),y + //SEG16 [3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::x#1 main::cursor#3 main::e#3 main::y#2 ] -- zpby1=zpby1_plus_1 + inc $4 + //SEG17 [4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::x#1 main::e#3 main::y#2 main::cursor#1 ] -- zpptrby1=zpptrby1_plus_1 + inc $2 + bne !+ + inc $2+$1 + !: + //SEG18 [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- xby=xby_plus_coby1 + txa + clc + adc #$18 + tax + //SEG19 [6] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- coby1_ge_xby_then_la1 + cpx #$27 + bcc b2 + //SEG20 main::@3 + //SEG21 [7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::e#1 main::cursor#1 main::y#1 ] -- zpby1=zpby1_plus_1 + inc $5 + //SEG22 [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] -- zpptrby1=zpptrby1_plus_coby1 + lda $2 + clc + adc #$28 + sta $2 + bcc !+ + inc $2+$1 + !: + //SEG23 [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] -- xby=xby_minus_coby1 + txa + sec + sbc #$27 + tax + //SEG24 [10] phi from main::@3 to main::@2 + //SEG25 [10] phi (byte) main::y#4 = (byte) main::y#1 -- register_copy + //SEG26 [10] phi (byte) main::e#5 = (byte) main::e#2 -- register_copy + //SEG27 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#2 -- register_copy + jmp b2 + //SEG28 [10] phi from main::@1 to main::@2 + //SEG29 [10] phi (byte) main::y#4 = (byte) main::y#2 -- register_copy + //SEG30 [10] phi (byte) main::e#5 = (byte) main::e#1 -- register_copy + //SEG31 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 -- register_copy + //SEG32 main::@2 + b2: + //SEG33 [11] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] -- zpby1_lt_coby1_then_la1 + lda $4 + cmp #$28 + bcc b1 + //SEG34 main::@return + //SEG35 [12] return [ ] + rts +} Removing instruction jmp b1 Removing instruction jmp b2 Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER //SEG0 @begin -//SEG1 [0] phi from @begin to @1 -//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $5 -//SEG3 [0] phi (byte) e#3 = (byte) 12 -- xby=coby1 - ldx #$c -//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $4 -//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1 - lda #<$400 - sta $2 - lda #>$400 - sta $2+$1 -//SEG6 [0] phi from @2 to @1 -//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy -//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy -//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy -//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy -//SEG11 @1 -b1: -//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1 - ldy #$0 - lda #$51 - sta ($2),y -//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1 - inc $4 -//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 y#2 cursor#1 ] -- zpptrby1=zpptrby1_plus_1 - inc $2 - bne !+ - inc $2+$1 -!: -//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] -- xby=xby_plus_coby1 - txa - clc - adc #$18 - tax -//SEG16 [5] if((byte) 39>=(byte) e#1) goto @2 [ x#1 e#1 y#2 cursor#1 ] -- coby1_ge_xby_then_la1 - cpx #$27 - bcc b2 -//SEG17 @3 -//SEG18 [6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1 - inc $5 -//SEG19 [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1 - lda $2 - clc - adc #$28 - sta $2 - bcc !+ - inc $2+$1 -!: -//SEG20 [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- xby=xby_minus_coby1 - txa - sec - sbc #$27 - tax -//SEG21 [9] phi from @3 to @2 -//SEG22 [9] phi (byte) y#4 = (byte) y#1 -- register_copy -//SEG23 [9] phi (byte) e#5 = (byte) e#2 -- register_copy -//SEG24 [9] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy -//SEG25 [9] phi from @1 to @2 -//SEG26 [9] phi (byte) y#4 = (byte) y#2 -- register_copy -//SEG27 [9] phi (byte) e#5 = (byte) e#1 -- register_copy -//SEG28 [9] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy -//SEG29 @2 -b2: -//SEG30 [10] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1 - lda $4 - cmp #$28 - bcc b1 -//SEG31 @end +//SEG1 [0] call main param-assignment [ ] + jsr main +//SEG2 @end +//SEG3 main +main: { + //SEG4 [1] phi from main to main::@1 + //SEG5 [1] phi (byte) main::y#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $5 + //SEG6 [1] phi (byte) main::e#3 = (byte) 12 -- xby=coby1 + ldx #$c + //SEG7 [1] phi (byte) main::x#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $4 + //SEG8 [1] phi (byte*) main::cursor#3 = (word) 1024 -- zpptrby1=cowo1 + lda #<$400 + sta $2 + lda #>$400 + sta $2+$1 + //SEG9 [1] phi from main::@2 to main::@1 + //SEG10 [1] phi (byte) main::y#2 = (byte) main::y#4 -- register_copy + //SEG11 [1] phi (byte) main::e#3 = (byte) main::e#5 -- register_copy + //SEG12 [1] phi (byte) main::x#2 = (byte) main::x#1 -- register_copy + //SEG13 [1] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 -- register_copy + //SEG14 main::@1 + b1: + //SEG15 [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] -- _star_zpptrby1=coby1 + ldy #$0 + lda #$51 + sta ($2),y + //SEG16 [3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::x#1 main::cursor#3 main::e#3 main::y#2 ] -- zpby1=zpby1_plus_1 + inc $4 + //SEG17 [4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::x#1 main::e#3 main::y#2 main::cursor#1 ] -- zpptrby1=zpptrby1_plus_1 + inc $2 + bne !+ + inc $2+$1 + !: + //SEG18 [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- xby=xby_plus_coby1 + txa + clc + adc #$18 + tax + //SEG19 [6] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- coby1_ge_xby_then_la1 + cpx #$27 + bcc b2 + //SEG20 main::@3 + //SEG21 [7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::e#1 main::cursor#1 main::y#1 ] -- zpby1=zpby1_plus_1 + inc $5 + //SEG22 [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] -- zpptrby1=zpptrby1_plus_coby1 + lda $2 + clc + adc #$28 + sta $2 + bcc !+ + inc $2+$1 + !: + //SEG23 [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] -- xby=xby_minus_coby1 + txa + sec + sbc #$27 + tax + //SEG24 [10] phi from main::@3 to main::@2 + //SEG25 [10] phi (byte) main::y#4 = (byte) main::y#1 -- register_copy + //SEG26 [10] phi (byte) main::e#5 = (byte) main::e#2 -- register_copy + //SEG27 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#2 -- register_copy + //SEG28 [10] phi from main::@1 to main::@2 + //SEG29 [10] phi (byte) main::y#4 = (byte) main::y#2 -- register_copy + //SEG30 [10] phi (byte) main::e#5 = (byte) main::e#1 -- register_copy + //SEG31 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 -- register_copy + //SEG32 main::@2 + b2: + //SEG33 [11] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] -- zpby1_lt_coby1_then_la1 + lda $4 + cmp #$28 + bcc b1 + //SEG34 main::@return + //SEG35 [12] return [ ] + rts +} FINAL SYMBOL TABLE -(label) @1 -(label) @2 -(label) @3 (label) @begin (label) @end (byte[1000]) SCREEN (byte) STAR -(byte*) cursor -(byte*) cursor#1 zp ptr byte:2 8.25 -(byte*) cursor#2 zp ptr byte:2 11.0 -(byte*) cursor#3 zp ptr byte:2 11.0 -(byte*) cursor#5 zp ptr byte:2 16.5 -(byte) e -(byte) e#1 reg byte x 11.0 -(byte) e#2 reg byte x 22.0 -(byte) e#3 reg byte x 5.5 -(byte) e#5 reg byte x 16.5 -(byte) x -(byte) x#1 zp byte:4 3.666666666666667 -(byte) x#2 zp byte:4 11.0 -(byte) x0 -(byte) x1 -(byte) xd -(byte) y -(byte) y#1 zp byte:5 7.333333333333333 -(byte) y#2 zp byte:5 5.5 -(byte) y#4 zp byte:5 16.5 -(byte) y0 -(byte) y1 -(byte) yd +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@return +(byte*) main::cursor +(byte*) main::cursor#1 zp ptr byte:2 8.25 +(byte*) main::cursor#2 zp ptr byte:2 11.0 +(byte*) main::cursor#3 zp ptr byte:2 11.0 +(byte*) main::cursor#5 zp ptr byte:2 16.5 +(byte) main::e +(byte) main::e#1 reg byte x 11.0 +(byte) main::e#2 reg byte x 22.0 +(byte) main::e#3 reg byte x 5.5 +(byte) main::e#5 reg byte x 16.5 +(byte) main::x +(byte) main::x#1 zp byte:4 3.666666666666667 +(byte) main::x#2 zp byte:4 11.0 +(byte) main::x0 +(byte) main::x1 +(byte) main::xd +(byte) main::y +(byte) main::y#1 zp byte:5 7.333333333333333 +(byte) main::y#2 zp byte:5 5.5 +(byte) main::y#4 zp byte:5 16.5 +(byte) main::y0 +(byte) main::y1 +(byte) main::yd -zp ptr byte:2 [ cursor#3 cursor#5 cursor#1 cursor#2 ] -zp byte:4 [ x#2 x#1 ] -reg byte x [ e#3 e#5 e#1 e#2 ] -zp byte:5 [ y#2 y#4 y#1 ] +zp ptr byte:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] +zp byte:4 [ main::x#2 main::x#1 ] +reg byte x [ main::e#3 main::e#5 main::e#1 main::e#2 ] +zp byte:5 [ main::y#2 main::y#4 main::y#1 ] FINAL CODE //SEG0 @begin -//SEG1 [0] phi from @begin to @1 -//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $5 -//SEG3 [0] phi (byte) e#3 = (byte) 12 -- xby=coby1 - ldx #$c -//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1 - lda #$0 - sta $4 -//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1 - lda #<$400 - sta $2 - lda #>$400 - sta $2+$1 -//SEG6 [0] phi from @2 to @1 -//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy -//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy -//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy -//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy -//SEG11 @1 -b1: -//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1 - ldy #$0 - lda #$51 - sta ($2),y -//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1 - inc $4 -//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 y#2 cursor#1 ] -- zpptrby1=zpptrby1_plus_1 - inc $2 - bne !+ - inc $2+$1 -!: -//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ] -- xby=xby_plus_coby1 - txa - clc - adc #$18 - tax -//SEG16 [5] if((byte) 39>=(byte) e#1) goto @2 [ x#1 e#1 y#2 cursor#1 ] -- coby1_ge_xby_then_la1 - cpx #$27 - bcc b2 -//SEG17 @3 -//SEG18 [6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1 - inc $5 -//SEG19 [7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1 - lda $2 - clc - adc #$28 - sta $2 - bcc !+ - inc $2+$1 -!: -//SEG20 [8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- xby=xby_minus_coby1 - txa - sec - sbc #$27 - tax -//SEG21 [9] phi from @3 to @2 -//SEG22 [9] phi (byte) y#4 = (byte) y#1 -- register_copy -//SEG23 [9] phi (byte) e#5 = (byte) e#2 -- register_copy -//SEG24 [9] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy -//SEG25 [9] phi from @1 to @2 -//SEG26 [9] phi (byte) y#4 = (byte) y#2 -- register_copy -//SEG27 [9] phi (byte) e#5 = (byte) e#1 -- register_copy -//SEG28 [9] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy -//SEG29 @2 -b2: -//SEG30 [10] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1 - lda $4 - cmp #$28 - bcc b1 -//SEG31 @end +//SEG1 [0] call main param-assignment [ ] + jsr main +//SEG2 @end +//SEG3 main +main: { + //SEG4 [1] phi from main to main::@1 + //SEG5 [1] phi (byte) main::y#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $5 + //SEG6 [1] phi (byte) main::e#3 = (byte) 12 -- xby=coby1 + ldx #$c + //SEG7 [1] phi (byte) main::x#2 = (byte) 0 -- zpby1=coby1 + lda #$0 + sta $4 + //SEG8 [1] phi (byte*) main::cursor#3 = (word) 1024 -- zpptrby1=cowo1 + lda #<$400 + sta $2 + lda #>$400 + sta $2+$1 + //SEG9 [1] phi from main::@2 to main::@1 + //SEG10 [1] phi (byte) main::y#2 = (byte) main::y#4 -- register_copy + //SEG11 [1] phi (byte) main::e#3 = (byte) main::e#5 -- register_copy + //SEG12 [1] phi (byte) main::x#2 = (byte) main::x#1 -- register_copy + //SEG13 [1] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 -- register_copy + //SEG14 main::@1 + b1: + //SEG15 [2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] -- _star_zpptrby1=coby1 + ldy #$0 + lda #$51 + sta ($2),y + //SEG16 [3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::x#1 main::cursor#3 main::e#3 main::y#2 ] -- zpby1=zpby1_plus_1 + inc $4 + //SEG17 [4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::x#1 main::e#3 main::y#2 main::cursor#1 ] -- zpptrby1=zpptrby1_plus_1 + inc $2 + bne !+ + inc $2+$1 + !: + //SEG18 [5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- xby=xby_plus_coby1 + txa + clc + adc #$18 + tax + //SEG19 [6] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ] -- coby1_ge_xby_then_la1 + cpx #$27 + bcc b2 + //SEG20 main::@3 + //SEG21 [7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::e#1 main::cursor#1 main::y#1 ] -- zpby1=zpby1_plus_1 + inc $5 + //SEG22 [8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ] -- zpptrby1=zpptrby1_plus_coby1 + lda $2 + clc + adc #$28 + sta $2 + bcc !+ + inc $2+$1 + !: + //SEG23 [9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ] -- xby=xby_minus_coby1 + txa + sec + sbc #$27 + tax + //SEG24 [10] phi from main::@3 to main::@2 + //SEG25 [10] phi (byte) main::y#4 = (byte) main::y#1 -- register_copy + //SEG26 [10] phi (byte) main::e#5 = (byte) main::e#2 -- register_copy + //SEG27 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#2 -- register_copy + //SEG28 [10] phi from main::@1 to main::@2 + //SEG29 [10] phi (byte) main::y#4 = (byte) main::y#2 -- register_copy + //SEG30 [10] phi (byte) main::e#5 = (byte) main::e#1 -- register_copy + //SEG31 [10] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 -- register_copy + //SEG32 main::@2 + b2: + //SEG33 [11] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] -- zpby1_lt_coby1_then_la1 + lda $4 + cmp #$28 + bcc b1 + //SEG34 main::@return + //SEG35 [12] return [ ] + rts +} diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.sym b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.sym index d64ba7378..aa5c1ad86 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bresenham.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/bresenham.sym @@ -1,35 +1,37 @@ -(label) @1 -(label) @2 -(label) @3 (label) @begin (label) @end (byte[1000]) SCREEN (byte) STAR -(byte*) cursor -(byte*) cursor#1 zp ptr byte:2 8.25 -(byte*) cursor#2 zp ptr byte:2 11.0 -(byte*) cursor#3 zp ptr byte:2 11.0 -(byte*) cursor#5 zp ptr byte:2 16.5 -(byte) e -(byte) e#1 reg byte x 11.0 -(byte) e#2 reg byte x 22.0 -(byte) e#3 reg byte x 5.5 -(byte) e#5 reg byte x 16.5 -(byte) x -(byte) x#1 zp byte:4 3.666666666666667 -(byte) x#2 zp byte:4 11.0 -(byte) x0 -(byte) x1 -(byte) xd -(byte) y -(byte) y#1 zp byte:5 7.333333333333333 -(byte) y#2 zp byte:5 5.5 -(byte) y#4 zp byte:5 16.5 -(byte) y0 -(byte) y1 -(byte) yd +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@return +(byte*) main::cursor +(byte*) main::cursor#1 zp ptr byte:2 8.25 +(byte*) main::cursor#2 zp ptr byte:2 11.0 +(byte*) main::cursor#3 zp ptr byte:2 11.0 +(byte*) main::cursor#5 zp ptr byte:2 16.5 +(byte) main::e +(byte) main::e#1 reg byte x 11.0 +(byte) main::e#2 reg byte x 22.0 +(byte) main::e#3 reg byte x 5.5 +(byte) main::e#5 reg byte x 16.5 +(byte) main::x +(byte) main::x#1 zp byte:4 3.666666666666667 +(byte) main::x#2 zp byte:4 11.0 +(byte) main::x0 +(byte) main::x1 +(byte) main::xd +(byte) main::y +(byte) main::y#1 zp byte:5 7.333333333333333 +(byte) main::y#2 zp byte:5 5.5 +(byte) main::y#4 zp byte:5 16.5 +(byte) main::y0 +(byte) main::y1 +(byte) main::yd -zp ptr byte:2 [ cursor#3 cursor#5 cursor#1 cursor#2 ] -zp byte:4 [ x#2 x#1 ] -reg byte x [ e#3 e#5 e#1 e#2 ] -zp byte:5 [ y#2 y#4 y#1 ] +zp ptr byte:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] +zp byte:4 [ main::x#2 main::x#1 ] +reg byte x [ main::e#3 main::e#5 main::e#1 main::e#2 ] +zp byte:5 [ main::y#2 main::y#4 main::y#1 ]