[LLVMbugs] [Bug 6397] New: Intrinsics for DIV instruction on x86

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 22 14:13:33 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=6397

           Summary: Intrinsics for DIV instruction on x86
           Product: libraries
           Version: 2.6
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: llvm at henning-thielemann.de
                CC: llvmbugs at cs.uiuc.edu


I have implemented a simple random number generator based on linear
concurrences.
It needs a division and LLVM chooses to call __umoddi3 which is really slow.
I can prove that the x86 instruction DIV cannot overflow, thus I like to use
it.
An intrinsic would be nice!

; The argument is always smaller than modulus 2147483399,
; thus 'urem' cannot overflow,
; thus we could use x86's 'div',
; but LLVM chooses to call the expensive __umoddi3 instead.
define i32 @_rnd(i32) {
  %x = zext i32 %0 to i64
  %y = mul i64 40692, %x
  %z = urem i64 %y, 2147483399
  %r = trunc i64 %z to i32
  ret i32 %r
}

This is code that is currently produced

    movl    $40692, %eax
    mull    24(%esp)
    movl    %edx, 4(%esp)
    movl    %eax, (%esp)
    movl    $0, 12(%esp)
    movl    $2147483399, 8(%esp)
    call    __umoddi3

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list