Skip to content

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

Open
@danlark1

Description

@danlark1
Bugzilla Link 47006
Version trunk
OS Linux
CC @topperc,@RKSimon,@nikic,@rotateright

Extended Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions