Open
Description
Rustc fails to combine div()
and mod()
operations with u128
to a single division with remainder on x64. The following code compiles down to separate calls to __udivti3()
and __umodti3()
when we would prefer a single call to __udivmodti4()
.
#![feature(i128_type, i128, test)]
extern crate test;
#[inline(never)]
fn divmod_u128(a: u128, b: u128) -> (u128, u128) {
(a / b, a % b)
}
fn main() {
println!("{:?}", divmod_u128(std::u128::MAX, test::black_box(1000)));
}
Related to #39078.
Relevant in the Display implementation for i128 and u128.
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: An issue proposing an enhancement or a PR with one.Issue: Problems and improvements with respect to performance of generated code.Relevant to the compiler team, which will review and decide on the PR/issue.