One more optimizer bug (*solved*) - Printable Version

+- Forum (
+-- Forum: Compilers and Computer Languages (
+--- Forum: ZX Basic Compiler (
+---- Forum: Bug Reports (
+---- Thread: One more optimizer bug (*solved*) (/showthread.php?tid=733)

One more optimizer bug (*solved*) - einar - 05-07-2016

File "test.bas":

sub test()
        ld      hl, 56469
        ld      de, 5
        ld      (hl), e
        inc     l
        ld      (hl), d
;        ret
    end asm
end sub


Trying to compile it:

>zxb.exe -t -O3 test.bas -o test.tap
Traceback (most recent call last):
  File "", line 348, in <module>
  File "", line 301, in main
  File "optimizer.pyc", line 2290, in optimize
  File "optimizer.pyc", line 1949, in optimize
  File "optimizer.pyc", line 680, in op
  File "optimizer.pyc", line 538, in inc
  File "optimizer.pyc", line 432, in set
TypeError: unsupported operand type(s) for <<: 'NoneType' and 'int'

Compiling it without "-O3" works just fine.

Re: One more optimizer bug - einar - 05-07-2016

Regardless of the problem itself, it worries me that the compiler is trying to optimize my assembly code. I certainly understand more about my assembly code context than the compiler, so any attempt by the compiler to "improve" it will most likely break something.

Even if it's necessary for the compiler to analyze small assembly snippets in the middle of a BASIC routine (in order to figure out how to integrate Assembly code with surrounding BASIC code)... perhaps compiler optimization could be disabled whenever a routine is written 100% in Assembly? Or perhaps ZX BASIC could provide a directive (or command-line option) to disable attempts to optimize Assembly code implemented by the programmer, and only optimize Assembly code produced by the compiler?

Re: One more optimizer bug - boriel - 05-17-2016

Is this bug still pending?? Confusedhock:

Anyway, yes, the compiler should not optimize users code and this will be fixed.

Re: One more optimizer bug - einar - 05-18-2016

boriel Wrote:Is this bug still pending??

Yes. Tested against latest version 1.4.0s1967.

Re: One more optimizer bug - boriel - 03-21-2017

Well, I'm finally addressing it (also fixed another two already, available in version s1975, but wait until I also fix this one).
I'm also trying to integrate the "don't optimize the user asm code" feature.

Update: Version 1.4.0s1980 is out.
Hope it's not too late :|
If you're still interested, try and tell me, please.
Note: This version does still optimize ASM user code (work in progress...)

Re: One more optimizer bug - einar - 03-22-2017

Thank you!!!

Re: One more optimizer bug - boriel - 03-22-2017

Ok. Now updated!

Re: One more optimizer bug (*solved*) - boriel - 07-11-2017

Okay, from version 1.6.6 and on, user's asm code won't be optimized regardless of the -O flag 8)