3 ms·
The compiler isn't even smart enough to switch for-loops that iterating over a grid when they would greatly improve cache usage. Swapping the lines `for (x=0; x
by DixieDev 5y ago
The compiler isn't even smart enough to switch for-loops that iterating over a grid when they would greatly improve cache usage. Swapping the lines `for (x=0; x<width; x++)` and `for (y=0; y<height; y++)` can give insane speedups on typical modern hardware.
- astrange 5y agoThey do have that optimization in some cases; it helps on SPECint. It often requires UB to optimize well, which many people aren't into letting it do.
- jcelerier 5y agoBoth GCC and clang are able to do some level of loop interchange optimization
- orwin 5y agoAre you sure about that? It must depend on the compiler.