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

Set both nuw and nsw in slice size calculation #136575

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Feb 5, 2025

There's an old note in the code to do this, and now that LLVM-C has an API for it, we might as well. And it's been there since what looks like LLVM 17 llvm/llvm-project@de9b6aa so doesn't even need to be conditional.

(There's other places, like RawVecInner or Layout, that might want to do things like this too, but I'll leave those for a future PR.)

@rustbot
Copy link
Collaborator

rustbot commented Feb 5, 2025

r? @fmease

rustbot has assigned @fmease.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 5, 2025

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 5, 2025
@scottmcm
Copy link
Member Author

scottmcm commented Feb 5, 2025

Probably won't change that much, but let's see
@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 5, 2025
@bors
Copy link
Contributor

bors commented Feb 5, 2025

⌛ Trying commit 5ea5384 with merge c304764...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 5, 2025
Set both `nuw` and `nsw` in slice size calculation

There's an old note in the code to do this, and now that [LLVM-C has an API for it](https://github.com/llvm/llvm-project/blob/f0b8ff12519270adcfef93410abff76ab073476a/llvm/include/llvm-c/Core.h#L4403-L4408), we might as well.  And it's been there since what looks like LLVM 17 llvm/llvm-project@de9b6aa so doesn't even need to be conditional.

(There's other places, like `RawVecInner` or `Layout`, that might want to do things like this too, but I'll leave those for a future PR.)
@bors
Copy link
Contributor

bors commented Feb 5, 2025

☀️ Try build successful - checks-actions
Build commit: c304764 (c304764cea431bce2cab535d52c219ed858d70e7)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c304764): 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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

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

Max RSS (memory usage)

Results (primary 6.5%)

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

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: 779.293s -> 779.494s (0.03%)
Artifact size: 328.78 MiB -> 328.74 MiB (-0.01%)

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

scottmcm commented Feb 5, 2025

Allows a bit more optimization without a compile-time perf change, so looks ready to go to me 👍

// CHECK-LABEL: @slice_size_plus_2
#[no_mangle]
pub fn slice_size_plus_2(x: &[u16]) -> usize {
// Before #136575 this didn't get the `nuw` in the add.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

bors commented Feb 13, 2025

☔ The latest upstream changes (presumably #136965) made this pull request unmergeable. Please resolve the merge conflicts.

There's an old note in the code to do this, and now that LLVM-C has an API for it, we might as well.
@@ -1430,6 +1430,8 @@ unsafe extern "C" {

// Extra flags on arithmetic
pub(crate) fn LLVMSetIsDisjoint(Instr: &Value, IsDisjoint: Bool);
pub(crate) fn LLVMSetNUW(ArithInst: &Value, HasNUW: Bool);
pub(crate) fn LLVMSetNSW(ArithInst: &Value, HasNSW: Bool);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annot: Rebased to address the conflict, and updated these to pub(crate) following #136881

@nikic
Copy link
Contributor

nikic commented Feb 14, 2025

@bors r+

@bors
Copy link
Contributor

bors commented Feb 14, 2025

📌 Commit 9ad6839 has been approved by nikic

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

bors commented Feb 14, 2025

⌛ Testing commit 9ad6839 with merge bdc97d1...

@bors
Copy link
Contributor

bors commented Feb 14, 2025

☀️ Test successful - checks-actions
Approved by: nikic
Pushing bdc97d1 to master...

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

Finished benchmarking commit (bdc97d1): 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 (primary -2.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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.2% [-2.2%, -2.2%] 1

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: 789.359s -> 790.438s (0.14%)
Artifact size: 347.77 MiB -> 347.75 MiB (-0.00%)

@scottmcm scottmcm deleted the nsuw-math branch February 14, 2025 18:53
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.

6 participants