John Mavrick's Garden

Search IconIcon to open search

Last updated April 10, 2022

Status: Tags: #cards/cmpt295/compilers Links: Coding MOC


Code Optimization

Principles

gcc has different forms of optimization: -Og -O1 -O2

Code optimization helps with:

Reduction in Strength

? Turn existing code into a less demanding operation

Example

Remove unecessary function call

? For a function that adds 1,2,…,7:

Code Motion (-O1)

?

Limitations

Solutions

For Instruction-level parallelism

Loop unrolling (kxc)

?

Re-associating (denoted as a) ?

Accumulating ?


References:

Created:: 2022-04-07 01:01


Interactive Graph