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: unassignedb...@nondot.org
          Reporter: kutdan...@yandex.ru
                CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
                    llvm-...@redking.me.uk, spatel+l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to