I have some code that calls memset(p, cr+1, cr*cr); inside a loop. (Will attach this later.)
gcc 4.1.2 (snapshot from 20060715) appears to attempt to calculate cr*cr outside the loop and then load it when needed. However, the generated code uses the wrong register for one the multiplicands: movl %edi, %ecx /* edi contains cr */ xorl %eax, %eax imull %ebx, %ecx /* ebx contains another variable */ leal 1(%edi), %ebx -- Summary: Wrong code for hoisted multiplication Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ben at decadentplace dot org dot uk GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28545