c++performancebuild

how to get the compiled extended to a function or loop


I have a function with a loop that I would get the extended development of the loop in c++ code. Also I have a recursive function that I wanted to get the same.

An example of I need:

for (i = 0; i <4; i++)
{
      printf ("%d", "example");
}

should result that i need

printf ("%d", "example");
printf ("%d", "example");
printf ("%d", "example");
printf ("%d", "example");

this is a simple example. But I would need to do this for more complex functions. For what it's worth I use visual c++. I do not know if there is a build option for this.


Solution

  • Visual C++ does not have an explicit option for loop unrolling. However, if you turn optimisations on, then the optimiser loop unrolls based on heuristic. Loop unrolling is a trade-off - it may or may not result in improved performance.

    Here is a discussion on loop unrolling in Visual C++.