[llvm-bugs] [Bug 47006] New: 128 bit division generates __udivti3 and __umodti3 instead of calling __udivmodti4 once

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 5 13:58:40 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47006

            Bug ID: 47006
           Summary: 128 bit division generates __udivti3 and __umodti3
                    instead of calling __udivmodti4 once
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: kutdanila at yandex.ru
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

128 bit division generates __udivti3 and __umodti3 instead of calling
__udivmodti4 once

This happens because of DivRemPairs pass and lack of instrumentation in the
backend.

; Unsigned 128-bit division
define i128 @udiv128(i128 %a, i128 %b) {
  %quot = udiv i128 %a, %b
  %rem = urem i128 %a, %b
  %sum = add i128 %quot, %rem
  ret i128 %sum
}

=>

https://gcc.godbolt.org/z/PorhMz

Will call __udivti3 on LP64 but libgcc and compiler-rt have __udivmodti4 which
computes the quotient and the remainder at the same time. This particular hurts
x86 as divq instruction is presented. Other backends can also benefit from this
too

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200805/115ac51f/attachment.html>


More information about the llvm-bugs mailing list