Skip to content
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

Emit getelementptr inbounds nuw for pointer::add() #137271

Merged
merged 3 commits into from
Feb 24, 2025
Merged

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Feb 19, 2025

Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative.

Fixes #137217.

@rustbot
Copy link
Collaborator

rustbot commented Feb 19, 2025

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 19, 2025
@nikic
Copy link
Contributor Author

nikic commented Feb 19, 2025

@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 Feb 19, 2025
@bors
Copy link
Contributor

bors commented Feb 19, 2025

⌛ Trying commit 511c91a with merge 934001d...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 19, 2025
Emit getelementptr inbounds nuw for pointer::add()

Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative.

Fixes rust-lang#137217.
@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Contributor

lcnr commented Feb 19, 2025

r? @scottmcm

@rustbot rustbot assigned scottmcm and unassigned lcnr Feb 19, 2025
@bors
Copy link
Contributor

bors commented Feb 19, 2025

☀️ Try build successful - checks-actions
Build commit: 934001d (934001ddafec5df9468c91504d935de13ea65aff)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (934001d): comparison URL.

Overall result: no relevant changes - 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 benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 1.0%, secondary 6.0%)

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)
2.3% [2.0%, 2.6%] 2
Regressions ❌
(secondary)
6.0% [6.0%, 6.0%] 1
Improvements ✅
(primary)
-1.5% [-1.5%, -1.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.0% [-1.5%, 2.6%] 3

Cycles

Results (primary 3.4%)

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)
3.4% [3.4%, 3.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.4% [3.4%, 3.4%] 1

Binary size

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

Bootstrap: 773.598s -> 773.894s (0.04%)
Artifact size: 360.32 MiB -> 360.32 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 19, 2025
@nikic
Copy link
Contributor Author

nikic commented Feb 19, 2025

Okay, those results aren't very interesting... should probably use it in more places. In particular this doesn't even cover slice indexing.

@nikic
Copy link
Contributor Author

nikic commented Feb 19, 2025

@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 Feb 19, 2025
@bors
Copy link
Contributor

bors commented Feb 19, 2025

⌛ Trying commit 9e7b184 with merge fb26d83...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 19, 2025
Emit getelementptr inbounds nuw for pointer::add()

Lower pointer::add (via intrinsic::offset with unsigned offset) to getelementptr inbounds nuw on LLVM versions that support it. This lets LLVM make use of the pre-condition that the offset addition does not wrap in an unsigned sense. Together with inbounds, this also implies that the offset is non-negative.

Fixes rust-lang#137217.
@bors
Copy link
Contributor

bors commented Feb 19, 2025

☀️ Try build successful - checks-actions
Build commit: fb26d83 (fb26d83173e2e6c470d8693cc5a3f18e26d7829b)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fb26d83): comparison URL.

Overall result: no relevant changes - 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 benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 1.2%)

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)
2.1% [1.4%, 2.5%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.6% [-1.6%, -1.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.2% [-1.6%, 2.5%] 4

Cycles

Results (primary -4.0%)

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)
-4.0% [-5.7%, -1.6%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.0% [-5.7%, -1.6%] 6

Binary size

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

Bootstrap: 773.063s -> 772.561s (-0.06%)
Artifact size: 362.34 MiB -> 362.33 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 19, 2025
@scottmcm
Copy link
Member

Cycle wins look like noise, but that's ok. More optimization potential without measurable compile-time perf cost sounds good to me.

@bors r+

@bors
Copy link
Contributor

bors commented Feb 19, 2025

📌 Commit 9e7b184 has been approved by scottmcm

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 Feb 19, 2025
@bors
Copy link
Contributor

bors commented Feb 24, 2025

⌛ Testing commit 9e7b184 with merge e0be1a0...

@bors
Copy link
Contributor

bors commented Feb 24, 2025

☀️ Test successful - checks-actions
Approved by: scottmcm
Pushing e0be1a0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 24, 2025
@bors bors merged commit e0be1a0 into rust-lang:master Feb 24, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Feb 24, 2025
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e0be1a0): 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)

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

Cycles

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

Binary size

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

Bootstrap: 769.943s -> 770.178s (0.03%)
Artifact size: 359.62 MiB -> 359.64 MiB (0.00%)

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-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make use of getelementptr nuw in pointer::add
7 participants