Next: , Previous: Units; GPI files and Automake, Up: Borland Pascal

7.7 Optimization

GNU Pascal is a 32/64 bit compiler with excellent optimization algorithms (which are identically the same as those of GNU C). There are six optimization levels, specified by the command line options -O, -O2, ..., -O6.

One example:

     program OptimizationDemo;
     procedure Foo;
       A, B: Integer;
       A := 3;
       B := 4;
       WriteLn (A + B)

When GNU Pascal compiles this program with optimization (-O3), it recognizes that the argument to `WriteLn' is the constant 7 – and optimizes away the variables A and B. If the variables were global, they would not be optimized away because they might be accessed from other places, but the constant 7 would still be optimized.

For more about optimization, see the GNU C documentation.