On x86, I got
[...@gnu-6 divb]$ cat umod-2.c
extern unsigned char z;
unsigned char
foo (unsigned char x, unsigned char y)
{
z = x/y;
return x % y;
}
[...@gnu-6 divb]$ gcc -S -O3 umod-2.c
[...@gnu-6 divb]$ cat umod-2.s
.file "umod-2.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movzbl %dil, %edi
movzbl %sil, %ecx
xorl %edx, %edx
movl %edi, %eax
divb %sil
movb %al, z(%rip)
movl %edi, %eax
divw %cx
movl %edx, %eax
ret
--
Summary: Very inefficient 8bit mod/div
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hjl dot tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44588