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

Use br instead of a conditional when switching on a constant boolean #120650

Merged
merged 1 commit into from
Feb 25, 2024

Conversation

clubby789
Copy link
Contributor

r? @ghost

@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 4, 2024
@clubby789
Copy link
Contributor Author

@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 4, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 4, 2024
Use `br` instead of a conditional when switching on a constant boolean

r? `@ghost`
@bors
Copy link
Contributor

bors commented Feb 4, 2024

⌛ Trying commit b0be08c with merge 14c7e36...

@bors
Copy link
Contributor

bors commented Feb 4, 2024

☀️ Try build successful - checks-actions
Build commit: 14c7e36 (14c7e36e619b79df407c2f6cf769648c6b7681cf)

1 similar comment
@bors
Copy link
Contributor

bors commented Feb 4, 2024

☀️ Try build successful - checks-actions
Build commit: 14c7e36 (14c7e36e619b79df407c2f6cf769648c6b7681cf)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (14c7e36): comparison URL.

Overall result: ✅ improvements - 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
Improvements ✅
(primary)
-0.8% [-1.8%, -0.2%] 17
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-1.8%, -0.2%] 17

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)
-2.2% [-3.7%, -0.8%] 5
Improvements ✅
(secondary)
-2.3% [-2.5%, -2.1%] 5
All ❌✅ (primary) -2.2% [-3.7%, -0.8%] 5

Cycles

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

Binary size

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)
-1.1% [-2.6%, -0.1%] 65
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.0%] 10
All ❌✅ (primary) -1.1% [-2.6%, -0.1%] 65

Bootstrap: 660.289s -> 662.794s (0.38%)
Artifact size: 308.12 MiB -> 308.09 MiB (-0.01%)

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

Lets try applying this to all discriminants, not only bools
@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, 2024
@bors
Copy link
Contributor

bors commented Feb 5, 2024

⌛ Trying commit ee1df1b with merge e99adce...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 5, 2024
Use `br` instead of a conditional when switching on a constant boolean

r? `@ghost`
@bors
Copy link
Contributor

bors commented Feb 5, 2024

☀️ Try build successful - checks-actions
Build commit: e99adce (e99adce02fa787e0bd5af9c16309ef8fc5b6431e)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e99adce): comparison URL.

Overall result: ✅ improvements - 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
Improvements ✅
(primary)
-0.9% [-2.1%, -0.3%] 21
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 2
All ❌✅ (primary) -0.9% [-2.1%, -0.3%] 21

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)
-3.1% [-5.6%, -0.9%] 7
Improvements ✅
(secondary)
-3.0% [-5.1%, -1.0%] 12
All ❌✅ (primary) -3.1% [-5.6%, -0.9%] 7

Cycles

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

Binary size

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)
-1.2% [-2.8%, -0.0%] 69
Improvements ✅
(secondary)
-0.2% [-0.4%, -0.0%] 10
All ❌✅ (primary) -1.2% [-2.8%, -0.0%] 69

Bootstrap: 659.551s -> 660.659s (0.17%)
Artifact size: 308.15 MiB -> 308.08 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 5, 2024
@clubby789 clubby789 marked this pull request as ready for review February 5, 2024 16:16
@clubby789
Copy link
Contributor Author

r? compiler

@fmease
Copy link
Member

fmease commented Feb 5, 2024

r? compiler

@rustbot rustbot assigned michaelwoerister and unassigned fmease Feb 5, 2024
@michaelwoerister
Copy link
Member

Looks promising but I don't know enough about this to gauge if this has any subtle, undesirable side effects.

r? compiler

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 22, 2024
@bors
Copy link
Contributor

bors commented Feb 23, 2024

⌛ Testing commit 15dad2b with merge 77899b3...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2024
Use `br` instead of a conditional when switching on a constant boolean

r? `@ghost`
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Feb 23, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 23, 2024
@clubby789
Copy link
Contributor Author

@bors r-

pub fn main() {
    match -1 { -1 => {}, _ => panic!("wat") }
    assert_eq!(1-1, 0);
}

This test fails on the first match, and codegens to a branch directly to the panic. Looking into it

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 23, 2024
@clubby789
Copy link
Contributor Author

Looks like sign_ext indeed needs to be false - discriminants are stored sign-extended to their type size (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/util/struct.Discr.html#structfield.val). Updated and added a new codegen test but this should probably be re-checked to make sure I'm right on this
@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 23, 2024
@saethlin
Copy link
Member

o7
@bors r+

@bors
Copy link
Contributor

bors commented Feb 24, 2024

📌 Commit 7159aed has been approved by saethlin

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 24, 2024

🌲 The tree is currently closed for pull requests below priority 50. This pull request will be tested once the tree is reopened.

@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 24, 2024
@bors
Copy link
Contributor

bors commented Feb 25, 2024

⌛ Testing commit 7159aed with merge 89d8e31...

@bors
Copy link
Contributor

bors commented Feb 25, 2024

☀️ Test successful - checks-actions
Approved by: saethlin
Pushing 89d8e31 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 25, 2024
@bors bors merged commit 89d8e31 into rust-lang:master Feb 25, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 25, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (89d8e31): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Improvements ✅
(primary)
-0.9% [-2.2%, -0.1%] 19
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.9% [-2.2%, -0.1%] 19

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)
-3.6% [-6.1%, -1.1%] 7
Improvements ✅
(secondary)
-4.0% [-4.0%, -4.0%] 1
All ❌✅ (primary) -3.6% [-6.1%, -1.1%] 7

Cycles

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

Binary size

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)
-1.7% [-3.8%, -0.0%] 69
Improvements ✅
(secondary)
-0.6% [-1.1%, -0.3%] 21
All ❌✅ (primary) -1.7% [-3.8%, -0.0%] 69

Bootstrap: 650.564s -> 651.95s (0.21%)
Artifact size: 311.05 MiB -> 311.05 MiB (-0.00%)

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2024
CopyProp: Propagate moves of constants

Yet another try of rust-lang#120650 - this time, keep track of SSA locals with a constant value and propagate it. Then, re-run `SimplifyConstCondition` to take advantage of it (simply reordering the pass regressed some tests).

r? `@ghost`
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.