This recommendation is part of the open catalog of best practice rules for performance that is automatically detected and reported by Codee.
Issue
A pointer assignment statement interleaved between two nested loops prevents the usage of loop interchange to improve the memory access pattern and loop’s performance.
Relevance
Performance optimization best practices recommend writing programs that read and write data laid out consecutively in the memory of the computer. However, programmers must use memory access patterns that matches the data layout rules for multi-dimensional arrays (e.g. in C/C++ use a row-wise access pattern for multi-dimensional static arrays).
Loop interchange is a performance optimization technique frequently used to enable consecutive memory accesses to multi-dimensional arrays. In the scope of perfectly nested loops its implementation is straightforward and consists of interchanging the loop headers only. For non perfectly nested loops it may require further code rewriting, but it usually pays off the effort because it brings high performance gains.
Actions
Remove the pointer assignment instruction between loop headers to make the loops perfectly nested.
Code example
void example(float *a, float *b, unsigned size) {
for (unsigned i = 0; i < size; i++) {
b = a + i * size;
for (unsigned j = 0; j < size; j++) {
b[j * size] = 0;
}
}
}
References

Building performance into the code from day one with Codee