Optimize

 

Some standard intra-procedural optimizations. Useful to clean up code after certain transformations. This transformation is experimental. mergeLocals is particularly useful after inlining, as it reduces the number of local variables in the combined function. This can be helpful for subsequent transformations (like virtualization).

The loopUnroll optimization replicates each loop body a number of times, set by --OptimizeLoopUnrollCount. It works on for, while and do-while loops, and preserves the program's behavior for any number of iterations, including loops that use break and continue. For example, to unroll the loops in function f three times:

tigress --Environment=x86_64:Linux:Gcc:11 \
        --Transform=Optimize \
           --Functions=f \
           --OptimizeKinds=loopUnroll \
           --OptimizeLoopUnrollCount=3 \
        program.c --out=result.c


Options

OptionArgumentsDescription
--Transform Optimize Some standard intra-procedural optimizations. Useful to clean up code after certain transformations.
--OptimizeKinds constProp, copyProp, mergeLocals, deadCodeElim, gotos, loopUnroll List of optimizing transformations to apply Default=NONE.
  • constProp = Constant Propagation, i.e. replace a variable with its value, if it is constant.
  • copyProp = Copy Propagation, i.e. after the assignment x=y replaces uses of variable x with y.
  • mergeLocals = Reduce the number of local variables by merging locals that are not live at the same time. Particularly useful after inlining,
  • deadCodeElim = Dead Code Elimination, i.e. remove assignments whose results are never used.
  • gotos = Branch simplification, i.e. shorten jump chains, delete redundant gotos and empty statements, and strip labels nobody branches to.
  • loopUnroll = Loop Unrolling, i.e. replicate each loop body a number of times (see --OptimizeLoopUnrollCount).
--OptimizeDumpInterferenceGraph For, mergeLocals, write the interference graph to a *.neato file. It can be visualized using neato -Tpdf foo-interferenceGraph.neato > foo.pdf. Default=False.
--OptimizeShortMergedNames For, mergeLocals, generate short names for merged local variables, instead of the default var1_var2_.... Default=False.
--OptimizeLoopUnrollCount For loopUnroll, the number of copies of each loop body to emit per loop iteration (the unroll factor). A value of 1 leaves loops unchanged. Default=2.