Is there some advantage to knowing at compile time how many iterations should be done of a for loop?
For example, in some situations, can the compiler produce an executable that will run faster given this:
#define ITERATIONS 10
int foo()
{
for (int i=0; i < ITERATIONS; i++){
do_something();
}
}
than given this:
int foo(int iterations)
{
for (int i=0; i < iterations; i++){
do_something();
}
}
If this is not universally the case, what are those situations?
My concern is in the specific case of OpenCL, so I'm also interested to know if this is different to C.