Hi, is there a way to tell the compiler that a variable can contain only some specified values?
An example:
for (i = 0; i < max; i++)
{
tot += someFunc(vals[idx]);
idx = (idx + 1) % 12;
}
Looking to the assembly I can see two cases:
1) if idx is local and is equal to any number between 0 and 11:
(idx+1) % 12 is computed as idx = (idx > 10)? 0 : idx+1;
2) else if idx is received as a parameter and the compiler doesn't know his value:
the compiler divide idx+1 by 12 (in a smart way) and than compute the % 12.
Of course the solution (1) is way better and faster.
I would like to say to the compiler that, even if coming from another function, idx is absolutely less than 12.
Is it possible via some pragma?
Thanks!