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

[mir-opt] simplify Repeats that don't actually repeat the operand #135322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scottmcm
Copy link
Member

Created because when I was writing this case in GVN

https://github.com/rust-lang/rust/pull/133324/files#diff-292b215fdc6b59e3f3c4173c2270b14591c5673832fbfb05cd69a05c2ef0c30eR977-R979

I happened to notice that it worked for [x] but not for [x; 1], so figured it would be good to simplify that Repeat to the simpler Aggregate.

@rustbot
Copy link
Collaborator

rustbot commented Jan 10, 2025

r? @Nadrieril

rustbot has assigned @Nadrieril.
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 Jan 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 10, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the inst-simplify-repeat-one branch from b1a6483 to 699703e Compare January 10, 2025 07:09
// CHECK-LABEL: fn remove_generic_array
// CHECK: debug a => const ZeroSized: [T; 0];
// CHECK-NOT: = [];
let a = [x; 0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also add a test where the zero comes from a constant not a literal

// CHECK: _0 = [move {{_[0-9]+}}];
// CHECK-NOT: [move {{_[0-9]+}}; 1]

[x; 1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Also test getting the 1 from a constant, not a literal. I think the normalization for that has already happened, but we've had some issues with that recently

@oli-obk oli-obk assigned oli-obk and unassigned Nadrieril Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants