# --funroll-loops?

## Ph0eniX

I saw this in someone's make.conf.  What does the "--funroll-loops" options do?

Grazie!  :Smile: 

----------

## Elfan

From the gcc manual

```
-funroll-loops

    Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop. -funroll-loops implies both -fstrength-reduce and -frerun-cse-after-loop. This option makes code larger, and may or may not make it run faster.

-funroll-all-loops

    Unroll all loops, even if their number of iterations is uncertain when the loop is entered. This usually makes programs run more slowly. -funroll-all-loops implies the same options as -funroll-loops, 
```

See this page for more info.

----------

## koziolek

 *Ph0eniX wrote:*   

> What does the "--funroll-loops" options do?

 

In make.conf they slow things down  :Smile: . In some special applications they can give much speed-up but generally (in make.conf) they are a bad idea.

----------

## NeddySeagoon

Ph0eniX,

Its an attempt to make code faster by making it bigger.

Normally a loop involves a jump instruction, back to the start of the loop, which takes up time and space and if the branch prediction fails, causes a CPU stall. The jump adds nothing to the programs output.

The jump instruction can be removed by repeating the loop code as many times as is needed, removing the above disadvatanges. However, the code gets bigger, when ran from cache may no longer fit in the cache, so it gets slower again while cache misses are addressed.

In general, optimisations like this, that make the code bigger, should only be used where you have time to test to ensure they have the desired effect. That means you don't use them globally in make.conf.

----------

## Ph0eniX

Thanks everyone!  :Smile: 

----------

