3 ms·
predictive commoning is a loop optimization that commons cross-loop redundancies. It is basically CSE "around loops". You can generalize it to subsume loop st
by DannyBee 13y ago
predictive commoning is a loop optimization that commons cross-loop redundancies.
It is basically CSE "around loops". You can generalize it to subsume loop store motion and strength reduction, but most compilers (including GCC) don't bother.
For example, it transforms
for (int i = 0; i < 50; i++)
a[i+2] = a[i] + a[i+1]
into
p0 = a[0]
p1 = a[1]
for (int i = 0; i < 50; i++) {
a[i+2]=p2=p0+p1;
p0=p1;
p1=p2;
}
Eliminating a whole ton of loads and stores.
It's been a while since i looked at GCC's implementation, but it did pretty well in the past (whether you can do commoning depends on your ability to identify and group sequences, etc)
-ftree-vectorize does the obvious thing (turn on vectorization). How effective it is depends on a lot of factors.