[LLVMbugs] [Bug 986] NEW: Extremely ugly code is generated for integer division in some cases.
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Mon Nov 6 14:27:29 PST 2006
http://llvm.org/bugs/show_bug.cgi?id=986
Summary: Extremely ugly code is generated for integer division in
some cases.
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Backend: X86
AssignedTo: unassignedbugs at nondot.org
ReportedBy: asl at math.spbu.ru
Consider the folowing code:
uint %test_div_func7(uint %u) {
entry:
%tmp1 = udiv uint %u, 7
ret uint %tmp1
}
llvm currently generates the following code (well, actually it was generated via
llvm-gcc from C source with -O3):
test_div_func7:
subl $4, %esp
movl %esi, (%esp)
movl $613566757, %ecx
movl 8(%esp), %esi
movl %esi, %eax
mull %ecx
subl %edx, %esi
shrl %esi
addl %edx, %esi
shrl $2, %esi
movl %esi, %eax
movl (%esp), %esi
addl $4, %esp
ret
This is really ugly:
1. "General" algorithm for division-via-multiplication is ok, but it can be
tweaked more for x86 platform.
2. Codegenerator transforms LLVM code to something not so good.
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list