Skip to content

inline(always) for lt/le/ge/gt on integers and floats #110935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2023

Conversation

scottmcm
Copy link
Member

I happened to notice one of these not getting inlined as part of Range::next in https://rust.godbolt.org/z/4WKWWxj1G

    bb1: {
        StorageLive(_5);
        _6 = &mut _4;
        StorageLive(_21);
        StorageLive(_14);
        StorageLive(_15);
        _15 = &((*_6).0: usize);
        StorageLive(_16);
        _16 = &((*_6).1: usize);
        _14 = <usize as PartialOrd>::lt(move _15, move _16) -> bb7;
    }

So since a call for something that's just one instruction is never the right choice, #[inline(always)] seems appropriate, like we have it on things like the rotate methods on integers.

I happened to notice one of these not getting inlined as part of `Range::next` in <https://rust.godbolt.org/z/4WKWWxj1G>
```rust
    bb1: {
        StorageLive(_5);
        _6 = &mut _4;
        StorageLive(_21);
        StorageLive(_14);
        StorageLive(_15);
        _15 = &((*_6).0: usize);
        StorageLive(_16);
        _16 = &((*_6).1: usize);
        _14 = <usize as PartialOrd>::lt(move _15, move _16) -> bb7;
    }
```

So since a call for something this trivial is never the right choice, `#[inline(always)]` seems appropriate.
@scottmcm scottmcm marked this pull request as ready for review April 28, 2023 08:11
@rustbot
Copy link
Collaborator

rustbot commented Apr 28, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot
Copy link
Collaborator

rustbot commented Apr 28, 2023

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 28, 2023
@scottmcm
Copy link
Member Author

I don't think this should be perf-relevant, since the MIR inliner will already be inlining them almost always, but just in case...
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 28, 2023
@bors
Copy link
Collaborator

bors commented Apr 28, 2023

⌛ Trying commit 8857cc2 with merge 6c1a0267c787582839d81193b869347a06a55abf...

@bors
Copy link
Collaborator

bors commented Apr 28, 2023

☀️ Try build successful - checks-actions
Build commit: 6c1a0267c787582839d81193b869347a06a55abf (6c1a0267c787582839d81193b869347a06a55abf)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6c1a0267c787582839d81193b869347a06a55abf): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.4% [0.4%, 0.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.1%, -0.1%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 28, 2023
@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 28, 2023

📌 Commit 8857cc2 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2023
@bors
Copy link
Collaborator

bors commented Apr 30, 2023

⌛ Testing commit 8857cc2 with merge c1bb0e0...

@bors
Copy link
Collaborator

bors commented Apr 30, 2023

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing c1bb0e0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 30, 2023
@bors bors merged commit c1bb0e0 into rust-lang:master Apr 30, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 30, 2023
@scottmcm scottmcm deleted the always-ord branch April 30, 2023 10:36
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c1bb0e0): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
11.7% [11.7%, 11.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 5.8% [-0.1%, 11.7%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants