mirror of
https://github.com/irmen/prog8.git
synced 2025-02-18 20:30:43 +00:00
revert restriction on certain associative operator reshuffling
it caused larger generated code
This commit is contained in:
parent
24d13dd120
commit
b2c9b7635d
@ -307,13 +307,12 @@ internal class StatementReorderer(val program: Program,
|
||||
val newValue = BinaryExpression(leftBinExpr.left, binExpr.operator, newRight, binExpr.position)
|
||||
listOf(IAstModification.ReplaceNode(binExpr, newValue, assignment))
|
||||
}
|
||||
else if(leftBinExpr.left.constValue(program)!=null && binExpr.right.constValue(program)!=null) {
|
||||
else {
|
||||
// A = (x <associative-operator> A) <same-operator> y ==> A = A <associative-operator> (x <same-operator> y)
|
||||
val newRight = BinaryExpression(leftBinExpr.left, binExpr.operator, binExpr.right, binExpr.position)
|
||||
val newValue = BinaryExpression(leftBinExpr.right, binExpr.operator, newRight, binExpr.position)
|
||||
listOf(IAstModification.ReplaceNode(binExpr, newValue, assignment))
|
||||
}
|
||||
else noModifications
|
||||
}
|
||||
val rightBinExpr = binExpr.right as? BinaryExpression
|
||||
if(rightBinExpr?.operator == binExpr.operator) {
|
||||
|
@ -3,22 +3,12 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- petaxian roller.p8 line 49 (also see test.p8) generates large code compared to 8.2
|
||||
- logical.p8 is huge compared to 8.2
|
||||
|
||||
- code gen for if statements has become inefficient? vm/6502?
|
||||
if not a or not b
|
||||
return 0
|
||||
- code gen for while loops has become inefficient: (until loops probably as well)
|
||||
(maybe solved when if statements code has been fixed)
|
||||
while c64.CHRIN()!='\"' {
|
||||
if c64.READST()
|
||||
goto close_end
|
||||
}
|
||||
- compiling logical.p8 to virtual with optimization generates code that is smaller,
|
||||
but takes many more vm instructions to execute than not-optimized code!?
|
||||
|
||||
- petaxian.prg became quite a bit (200 bytes) larger, why!? because of the above?
|
||||
|
||||
- compiling logical.p8 to virtual with optimization generates a lot larger code as without optimizations.
|
||||
this is not the case for the 6502 codegen.
|
||||
- petaxian.prg became quite a bit (150 bytes) larger since 8.2, what causes that
|
||||
|
||||
- add some more optimizations in vmPeepholeOptimizer
|
||||
- vm Instruction needs to know what the read-registers/memory are, and what the write-register/memory is.
|
||||
|
100
examples/test.p8
100
examples/test.p8
@ -7,90 +7,22 @@ main {
|
||||
|
||||
sub start() {
|
||||
|
||||
ubyte a1 = 0
|
||||
uword w1 = 0
|
||||
ubyte vv
|
||||
; a "pixelshader":
|
||||
sys.gfx_enable(0) ; enable lo res screen
|
||||
ubyte shifter
|
||||
|
||||
if not a1
|
||||
txt.print("ok ")
|
||||
else
|
||||
txt.print("fail ")
|
||||
vv = not a1
|
||||
txt.print_ub(vv)
|
||||
txt.nl()
|
||||
a1=128
|
||||
if not a1
|
||||
txt.print("fail ")
|
||||
else
|
||||
txt.print("ok ")
|
||||
vv = not a1
|
||||
txt.print_ub(vv)
|
||||
txt.nl()
|
||||
if not w1
|
||||
txt.print("ok ")
|
||||
else
|
||||
txt.print("fail ")
|
||||
vv = not w1
|
||||
txt.print_ub(vv)
|
||||
txt.nl()
|
||||
w1 = 4096
|
||||
if not w1
|
||||
txt.print("fail ")
|
||||
else
|
||||
txt.print("ok ")
|
||||
vv = not w1
|
||||
txt.print_ub(vv)
|
||||
txt.nl()
|
||||
|
||||
|
||||
; petaxian roller.p8 line 49
|
||||
; super large in new version, ok in 8.2....
|
||||
; TODO cx16.r0 = a2 + 25 + (a1/40)
|
||||
; txt.setcc( a1, a2 + 25 + (a1/40), 11,22)
|
||||
|
||||
; if a1 and a2 {
|
||||
; a1++
|
||||
; }
|
||||
;
|
||||
; if not a1 or not a2 {
|
||||
; a1++
|
||||
; }
|
||||
;
|
||||
; if a1!=99 and not a2 {
|
||||
; a1++
|
||||
; }
|
||||
|
||||
; while a1 != a2 {
|
||||
; a1++
|
||||
; }
|
||||
;
|
||||
; while a1!='\"' {
|
||||
; a1++
|
||||
; }
|
||||
; do {
|
||||
; a1++
|
||||
; } until a1==99
|
||||
;
|
||||
;close_end:
|
||||
; a1++
|
||||
|
||||
|
||||
; ; a "pixelshader":
|
||||
; sys.gfx_enable(0) ; enable lo res screen
|
||||
; ubyte shifter
|
||||
;
|
||||
; repeat {
|
||||
; uword xx
|
||||
; uword yy = 0
|
||||
; repeat 240 {
|
||||
; xx = 0
|
||||
; repeat 320 {
|
||||
; sys.gfx_plot(xx, yy, xx*yy + shifter as ubyte)
|
||||
; xx++
|
||||
; }
|
||||
; yy++
|
||||
; }
|
||||
; shifter+=4
|
||||
; }
|
||||
repeat {
|
||||
uword xx
|
||||
uword yy = 0
|
||||
repeat 240 {
|
||||
xx = 0
|
||||
repeat 320 {
|
||||
sys.gfx_plot(xx, yy, xx*yy + shifter as ubyte)
|
||||
xx++
|
||||
}
|
||||
yy++
|
||||
}
|
||||
shifter+=4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user