This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[GCC] x86 optimizer suggestion
- From: Tom St Denis <tomstdenis at iahu dot ca>
- To: gcc at gnu dot org
- Date: Mon, 16 Jun 2003 22:35:34 -0400
- Subject: [GCC] x86 optimizer suggestion
Code like
unsigned long long t, w;
unsigned long b;
t = w / b;
w = w % b;
Generates asm like
movl %esi, (%esp)
movl 40(%esp), %eax
movl 44(%esp), %ebx
movl %edi, 4(%esp)
movl %eax, 8(%esp)
movl %ebx, 12(%esp)
call ___udivdi3
movl 40(%esp), %ecx
movl %esi, (%esp)
movl 44(%esp), %esi
movl %edi, 4(%esp)
movl %eax, 56(%esp)
movl %esi, 12(%esp)
movl %edx, 60(%esp)
movl %ecx, 8(%esp)
call ___umoddi3
movl %eax, %esi
movl %edx, %edi
When call as "gcc -I./ -Wall -W -Wshadow -O3 -fomit-frame-pointer
-funroll-loops -S bn_mp_div_d.c" [in this case].
If I am not mistaken the x86 series [from 80386 and up] has a 64x32
division instruction DIV which will divide EDX:EAX by another regmem
value. Couldn't this source code make only a single DIV opcode to get
both results [or at the very least do two DIVs]?
Thanks,
Tom