CC loop assignment oddity
Rick Murray (539) 13751 posts |
The DDE compiler, v5.82 is the one that’s currently installed here. Here’s a snippet of some code:
The assembler in the comments is a translation of the code that has been commented out. Why has the compiler decided to put |
Jeffrey Lee (213) 6048 posts |
Assuming Manually caching the pointer in a local variable outside of the loop is one common way of avoiding the compiler constantly reloading it: char *p = texture[0]; for(int offset=0;offset<64*64;offset++) { p[offset] = 0; } Making the local pointer const can also help, e.g. You can also use the C99 void test(char * restrict * restrict texture) { for(int offset=0;offset<64*64;offset++) texture[0][offset] = 0; } |
Rick Murray (539) 13751 posts |
Can it not see
That makes sense. |
Stuart Swales (8827) 1326 posts |
Or memset()… |