The following two functions should be the same (note don't compile with -ffast-math or even -fno- math-errno as sqrt is marked as pure) #define NUMPOINTS 20 float opoints[NUMPOINTS]; double sqrt (double); void NormalizeVectors (void) { int i, r; float s, x, y, z; static float d = 0.0; d += 0.2f; if (d > 4) d = 0.0; for (i=0; i<NUMPOINTS; i++) { opoints[i] = sqrt (d); } } void NormalizeVectors1 (void) { int i, r; float s, x, y, z; static float d = 0.0; d += 0.2f; if (d > 4) d = 0.0; s = d; for (i=0; i<NUMPOINTS; i++) { opoints[i] = sqrt (s); } }
Confirmed.
oh, why is d considered call clobbered when it cannot be: Variable: d.0, UID 0, float Variable: d, UID 1, float, is global, call clobbered, default def: d_4
This is not fixed Kenny's promote statics, in fact we now produce worse code at -O3. Note on ppc- darwin the code is fine since -fno-math-errno is done by default.
(In reply to comment #3) > This is not fixed Kenny's promote statics, in fact we now produce worse code at -O3. Note on ppc- > darwin the code is fine since -fno-math-errno is done by default. I filed that as PR 22532.
I think the FIXME in tree-ssa-operands.c is the answer here: /* FIXME - if we have better information from the static vars analysis, we need to make the cache call site specific. This way we can have the performance benefits even if we are doing good optimization. */
Long fixed.