Source: #include <string.h> void dequant_lsps(double *lsps, int num, const unsigned short *values, int n_stages, const unsigned char * __restrict table, const double * __restrict mul_q, const double * __restrict base_q) { const unsigned char *t_off = &table[values[0] * num]; int m;
memset(lsps, 0, num * sizeof(*lsps)); for (m = 0; m < num; m++) lsps[m] += base_q[0] + mul_q[0] * t_off[m]; } > /usr/local/gcc45/bin/gcc -O3 -S base_lsp.c The inner loop: L3: movzbl (%r15), %edx incq %r15 cvtsi2sd %edx, %xmm0 mulsd 0(%r13), %xmm0 <- constant (and "0" prefix) addsd (%r14), %xmm0 <- constant addsd (%rbx,%rax), %xmm0 movsd %xmm0, (%rbx,%rax) addq $8, %rax cmpq %rcx, %rax jne L3 Rest of the output attached. base_q and mul_q should be loaded outside of the loop but aren't. I added __restrict to base_q/mul_q/table, but it didn't affect it. Code is reduced from FFmpeg WMA Voice decoder. -- Summary: Constant load not raised out of loop Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: astrange at ithinksw dot com GCC host triplet: x86_64-apple-darwin10.2.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43224