Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compiler optimization setting
#2
(01-27-2021, 06:35 PM)patters Wrote: Is it a good idea to use -O3? I know typically there are trade-offs - like loop unrolling can make code bigger in order to become faster. Is there much of a difference for ZX Basic between -O2 and -O3? Am I better off sticking to the default -O2 since it's more tried and tested?
Or since I'm not yet running into memory limits should I use -O3 while I can?

ZX Basic supports -O3 and -O4 but this is compiler specific (i.e. -O3 in GCC is not the same as -O3 here).

You should try -O3 and -O4. There's currently no loop unrolling implemented, and no trade-off (memory vs speed) implemented either.

Beware -O4 is very aggressive and (for the moment) it also optimizes (aka removes and caches) VOLATILE variables (variables whose value change out of BASIC, like in an interruption, or within an ASM block). I.e. the input routine might fail with -O4 as it uses ROM KEYIN Peek value.

O3 and O4 are related to the peephole optimizer which, starting from -O3 creates the asm basic block DAGs, etc, and perform more efficient assembling instructions.

To sum up: -O3 should work always. -O4 might fail if you use volatile variables.
Reply


Messages In This Thread
Compiler optimization setting - by patters - 01-27-2021, 06:35 PM
RE: Compiler optimization setting - by boriel - 01-27-2021, 11:24 PM
RE: Compiler optimization setting - by patters - 01-28-2021, 12:41 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)