Although Jeff's answer is right, i.e., you can always make a pointer to the allocated array, the fact is that the compiler knows at compile-time that tmpvalues won't be aliased because the variable is declared as an actual array, not a pointer. The only chances to alias an array is declaring a pointer to it, so if you don't do that, there's no need to declare it as restrict
. This is more evident if tmpvalues
is the only variable you'll have within the function.
The problem may arise if you pass the pointer to another function, then there you should state whether the received pointer is restricted or not.
The documentation I encountered related to this topic includes the C99:
Let D be a declaration of an ordinary identifier that provides a means
of designating an object P as a restrict-qualified pointer to type T.
Note that it only applies to pointers.
This other document from TI provides some performance tuning hints using the restrict
keyword. In addition to all the hints, section 3.3 provides examples when it is possible to apply this type qualifier and when not. Look for the x
array declaration in the middle of page 16, it states that it does not declare a pointer and thus cannot be restrict
-qualified.
float *restrict tmpvalues
outperforms the VLA? (pref. with timing code in place already) – Lyford