Next: , Previous: , Up: Optimization options   [Contents][Index]


9.16.2 Source-to-source optimizations


--optimize-dead-procs
--optimise-dead-procs

Delete all procedures that are never called.


Optimization levels 0 to 6 automatically set –optimize-dead-procs.


--unneeded-code

Remove goals from computation paths where their outputs are not needed, provided the semantics options allow the deletion or movement of the goal.


--unneeded-code-copy-limit copy_limit

Specify the maximum number of places to which a goal may be copied when removing it from computation paths on which its outputs are not needed. A value of zero forbids goal movement and allows only goal deletion; a value of one prevents any increase in the size of the code.


--optimize-unused-args
--optimise-unused-args

Delete unused arguments from predicates and functions. This will cause the compiler to generate more efficient code for many polymorphic predicates.


Optimization levels 3 to 6 automatically set –optimize-unused-args.


--intermod-unused-args

Delete unused arguments from predicates and functions even when the analysis required crosses module boundaries. This option implies ‘--optimize-unused-args’ and ‘--intermodule-optimization’.


--no-optimize-format-calls

Do not optimize calls to string.format, io.format, and stream.string_writer.format at compile time. The default is to interpret the format string in such calls at compile time, replacing those calls with the sequence of more primitive operations required to implement them.


--optimize-constant-propagation
--optimise-constant-propagation

Given calls to some frequently used library functions and predicates, mainly those that do arithmetic, evaluate them at compile time, if all their input arguments are constants.


Optimization levels 2 to 6 automatically set –optimize-constant-propagation.


--optimize-duplicate-calls
--optimise-duplicate-calls

Given multiple calls to a predicate or function with the same input arguments, optimize away all but one.


--inlining

Ask the compiler to inline procedures using its usual heuristics.


--inline-single-use

Inline procedures which are called only from one call site.


Optimization levels 2 to 6 automatically set –inline-single-use.


--inline-simple

Inline all simple procedures.


Optimization levels 2 to 6 automatically set –inline-simple.


--inline-simple-threshold threshold

With ‘--inline-simple’, inline a procedure if its size is less than the given threshold.


Optimization levels 4 to 6 automatically set –inline-simple-threshold=8.


--intermod-inline-simple-threshold threshold

Similar to ‘--inline-simple-threshold’, except used to determine which predicates should be included in .opt files. Note that changing this between writing the .opt file and compiling to C may cause link errors, and too high a value may result in reduced performance.


--inline-compound-threshold threshold

Inline a procedure if its size (measured roughly in terms of the number of connectives in its internal form) less the assumed call cost, multiplied by the number of times it is called, is below the given threshold.


Optimization levels 2 to 3 automatically set –inline-compound-threshold=10.


Optimization level 4 automatically sets –inline-compound-threshold=20.


Optimization levels 5 to 6 automatically set –inline-compound-threshold=100.


--inline-call-cost cost

Assume that the cost of a call is the given parameter. Used only in conjunction with ‘--inline-compound-threshold’.


--inline-vars-threshold threshold

Don’t inline a call if it would result in a procedure containing more than threshold variables. Procedures containing large numbers of variables can cause slow compilation.


--optimize-higher-order
--optimise-higher-order

Create specialized variants of higher-order predicates and functions for call sites where the values of the higher-order arguments are known.


Optimization levels 3 to 6 automatically set –optimize-higher-order.


--type-specialization
--type-specialisation

Enable specialization of polymorphic predicates where the polymorphic types are known.


--user-guided-type-specialization
--user-guided-type-specialisation

Enable specialization of polymorphic predicates for which there are :- pragma type_spec declarations. See the “Type specialization” section of the “Pragmas” chapter of the Mercury language Reference Manual for more details.


Optimization levels 2 to 6 automatically set –user-guided-type-specialization.


--higher-order-size-limit max_size

Set the maximum goal size of specialized versions created by ‘--optimize-higher-order’ and ‘--type-specialization’. Goal size is measured as the number of calls, unifications and branched goals.


Optimization level 4 automatically sets –higher-order-size-limit=30.


Optimization levels 5 to 6 automatically set –higher-order-size-limit=40.


--higher-order-arg-limit max_size

Set the maximum size of higher-order arguments to be specialized by ‘--optimize-higher-order’ and ‘--type-specialization’.


--loop-invariants

Hoist loop invariant computations out of loops.


Optimization levels 5 to 6 automatically set –loop-invariants.


--introduce-accumulators

Attempt to make procedures tail recursive by introducing accumulator variables into them.


--optimize-constructor-last-call
--optimise-constructor-last-call

Enable the optimization of almost-last calls that are followed only by constructor application.


--no-split-switch-arms

When a switch on a variable has an inner switch on that same variable inside one of its arms, the default is to split up that arm of the outer switch along the same lines, effectively inlining the inner switch. ‘--no-split-switch-arms’ prevents this split.


Optimization levels 2 to 6 automatically set –split-switch-arms.


--no-const-struct

By default, the compiler will gather constant ground structures in a separate table, with each such structure being stored in this table just once, even if it occurs in many different procedures. ‘--no-const-struct’ prevents this behavior.


--common-struct

Replace two or more occurrences of the same term in a conjunction with just one copy.


Optimization levels 2 to 6 automatically set –common-struct.


--optimize-saved-vars
--optimise-saved-vars

Minimize the number of variables saved across calls.


--constraint-propagation

Perform the constraint propagation transformation, which attempts to ensure that goals which can fail are executed as early as possible.


Optimization levels 3 to 6 automatically set –constraint-propagation.


--local-constraint-propagation

Perform the constraint propagation transformation, but only rearrange goals within each procedure. Specialized versions of procedures will not be created.


Optimization levels 3 to 6 automatically set –local-constraint-propagation.


--deforestation

Perform deforestation, which is a program transformation whose aims are to avoid the construction of intermediate data structures, and to avoid repeated traversals over data structures within a conjunction.


Optimization levels 3 to 6 automatically set –deforestation.


--deforestation-depth-limit depth_limit

Specify a depth limit to prevent infinite loops in the deforestation algorithm. A value of -1 specifies no depth limit. The default is 4.


--deforestation-vars-threshold threshold

Specify a rough limit on the number of variables in a procedure created by deforestation. A value of -1 specifies no limit. The default is 200.


--deforestation-size-threshold threshold

Specify a rough limit on the size of a goal to be optimized by deforestation. A value of -1 specifies no limit. The default is 15.


--delay-constructs
--delay-construct

Reorder goals to move construction unifications after primitive goals that can fail.


Optimization levels 5 to 6 automatically set –delay-constructs.


--no-generate-trail-ops-inline

Normally, the compiler generates inline code for trailing operations. With ‘--no-generate-trail-ops-inline’, the compiler will implement them using calls to those operations in the standard library.


Next: , Previous: , Up: Optimization options   [Contents][Index]