Set optimization level to n. Optimization levels range from -1 to 6. Optimization level -1 disables all optimizations, while optimization level 6 enables all optimizations except for the cross-module optimizations listed below. Some experimental optimizations (for example constraint propagation) are not be enabled at any optimization level.
In general, there is a trade-off between compilation speed and the speed of the generated code. When developing, you should normally use optimization level 0, which aims to minimize compilation time. It enables only those optimizations that in fact usually reduce compilation time. The default optimization level is level 2, which delivers reasonably good optimization in reasonable time. Optimization levels higher than that give better optimization, but take longer, and are subject to the law of diminishing returns. The difference in the quality of the generated code between optimization level 5 and optimization level 6 is very small, but using level 6 may increase compilation time and memory requirements dramatically.
Note that if you want the compiler to perform cross-module optimizations, then you must enable them separately; the cross-module optimizations are not enabled by any ‘-O’ level, because they affect the compilation process in ways that require special treatment by ‘mmake’.
Turn on optimizations that reduce code size and turn off optimizations that significantly increase code size.
Perform inlining and higher-order specialization of the code for predicates or functions imported from other modules.
Use the information stored in module.trans_opt files to make intermodule optimizations. The module.trans_opt files are different to the module.opt files as ‘.trans_opt’ files may depend on other ‘.trans_opt’ files, whereas each ‘.opt’ file may only depend on the corresponding ‘.m’ file. Note that ‘--transitive-intermodule-optimization’ does not work with ‘mmc --make’.
Only read the inter-module optimization information for directly imported modules, not the transitive closure of the imports.
Perform inter-module optimization using any ‘.opt’ files which are already built, e.g. those for the standard library, but do not build any others.
Perform inter-module optimization using any ‘.trans_opt’ files which are already built, e.g. those for the standard library, but do not build any others.
Perform analyses such as termination analysis and unused argument elimination across module boundaries. This option is not yet fully implemented.
The maximum number of times to repeat analyses of suboptimal modules with ‘--intermodule-analyses’ (default: 0). This option only works with ‘mmc --make’.