http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56770
Bug #: 56770 Summary: Partial sums loop optimization Classification: Unclassified Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: d...@gcc.gnu.org GCC loop optimization should unroll and transform loops using partial sums where beneficial for expensive, independent computations where the target has additional function units available. Before double fValue = 0; int j; for (j = 0; j < NZ; j++) fValue += Q[j] / r[j]; After double fValue = 0; double fValue1 = 0; int j; for (j = 0; j < NZ; j=j+2){ fValue += Q[j] / r[j]; fValue1 += Q[j+1] / r[j+1]; } for (j = (NZ/2)*2; j < NZ; j++){ fValue += Q[j] / r[j]; } fValue = fValue + fValue1;