Super Prev Next

Optimizing a program

It sometimes happens with almost all compilers that the unoptimized version of a program works properly, but the optimized one does not or vice versa. If the compiler has a dozen of optimization control options it may be extremely difficult to test the compiler itself. The compiler manufacturer has to check all possible combinations of options. Fortunately, this is not the case with XDS.

Unlike many other compilers, XDS performs optimizations by default. Most of them may be turned off by setting the NOOPTIMIZE option ON. However, the code generator always performs some low-level optimizations /As a result, disabling optimizations optimizer significantly slows down the complier/ . Instruction scheduling can be turned on or off using the DOREORDER option. The last option that implicitly disables some of optimizations is the GENDEBUG option.

There are still several ways to control the generated code. First of all, you have to choose what is more important for you: performance or compactness. By default, the option SPACE is set OFF, forcing the compiler to favor the code effeciency.

To get the maximum performance, do the following:

It is possible not to turn run-time checks off in the product versions of your programs, because the code generator usually removes redundant checks. A typical program runs only 10-15% faster with all run-time checks turned off (but the code size is usually significantly smaller).

Two options should be used with care:

Super Prev Next

Example of project file for maximum performance

    -alignment=4          % is unnecessary under Linux
    -noptralias+
    -procinline+
    -space
    -doreorder+
    -cpu=486
    -genframe

    -checkindex
    -checkrange
    -checknil
    -ioverflow
    -coverflow

    -gendebug
    -genhistory
    -lineno
    !module Foo.mod

In some cases, it may be better to set different options for different modules in your program. See dry.mod from XDS samples.