-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Consider code like this:
#![feature(core_intrinsics)]
pub fn method(a: usize, b: usize) -> usize {
a.wrapping_sub(b)
}
pub fn intrinsic(a: usize, b: usize) -> usize {
std::intrinsics::wrapping_sub(a, b)
}
at -Copt-level=1
and lower, the generated assembly for versions with the method call will generate a function call, rather than direct operation. Once the inlining fails, other optimisations that could be done are inhibited, especially at -Copt-level=1`.
More generally speaking, I wonder if we might want to make these methods have a special annotation that would make the compiler generate the instructions directly much like it does for intrinsics right now. These seem like basic enough that #[inline(always)]
might not be good enough (it being just a hint) and also possibly more expensive than necessary (something needs to do the inlining still).
workingjubilee and thomcc
Metadata
Metadata
Assignees
Labels
I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.