This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/16978] New: Inefficient 32x32=>64 multiply and add on x86-32
- From: "tomstdenis at iahu dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Aug 2004 13:39:36 -0000
- Subject: [Bug target/16978] New: Inefficient 32x32=>64 multiply and add on x86-32
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code [on an x86-32 target]
typedef unsigned long mp_digit;
typedef unsigned long long mp_word;
void test(mp_word *W, mp_digit *x, mp_digit *y, int n)
{
int iz;
mp_word _W;
_W = 0;
for (iz = 0; iz < n; ++iz) {
_W += ((mp_word)*x++)*((mp_word)*y--);
}
*W = _W;
}
Demos what I'm talking about ... It produces
.L6:
movl (%ecx), %edx
movl %edx, %eax
mull (%ebx)
addl %eax, %esi
adcl %edx, %edi
movl -4(%ecx), %edx
movl %edx, %eax
mull 4(%ebx)
addl %eax, %esi
adcl %edx, %edi
...
The load of EDX is not required. Since the multiplication is 32x32 all you
have to do is load EAX. This causes annoying stalls on the Athlon since edx
=> eax => mull is just two stalls in a row.
The correct optimization would be to load the next word into eax directly.
--
Summary: Inefficient 32x32=>64 multiply and add on x86-32
Product: gcc
Version: 3.3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tomstdenis at iahu dot ca
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-
3.3.2-2,
GCC host triplet: Linux tombox 2.6.7 #1 SMP Mon Jul 26 15:43:24 EDT 2004
i686 Inte
GCC target triplet: gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-
3.3.2-2,
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16978