The following program (split off from PR30032) needs with "gcc -march=opteron -ffast-math -funroll-loops -ftree-vectorize -msse3 -O3 -g" 0m6.478s but if I use #define NODES 2500 it only needs only 0m1.390s
(The Intel compiler seems to do this conversion automatically and needs 0m1.879s for the VLA version of the program.) void eos(const int NODES, const float CGAMMA, float CS[NODES], float PRES[NODES], const float DENS[NODES]) { int j; for(j = 0; j < NODES; j ++) { CS[j] = sqrt(CGAMMA*PRES[j]/DENS[j]); } } int main() { const int NODES = 25000; float CGAMMA; float DENS[NODES], CS[NODES], PRES[NODES]; int i,j; for(i = 0; i < NODES; i++) { DENS[i] = 3.0; PRES[i] = 0.25; } CGAMMA = 2.0; for(i = 0; i < 20000; i++) { eos(NODES, CGAMMA, &CS, &PRES, &DENS); CGAMMA = CGAMMA + CS[1]; } return (int)CGAMMA; } -- Summary: Variable-length arrays (VLA) should be converted to normal arrays if possible Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30049