SPRUJG0B December 2024 – November 2025 F29H850TU , F29H859TU-Q1
When pointers are passed as function arguments, using the "restrict" keyword on the pointer can result in performance improvements. By applying restrict to the type declaration of a pointer p, the programmer provides the following to the compiler:
Within the scope of the declaration of p , only p or expressions based on p are used to access the object pointed to by p.
The compiler can take advantage of this to generate more efficient code.
Example:
void matrix_vector_product(float32_t *restrict A, float32_t *restrict b, int nr, int nc, float32_t *restrict c)
{
int i, j;
float32_t s;
for(i = nr -1; i >=0; i--)
{
s =c[i];
for(j = nc -1; j >=0; j--)
{
s = s +A[j*nr+i]*b[j];
}
c[i] = s;
}
}