-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Copy 1-/2-element arrays as scalars, not vectors #116479
Conversation
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`. And treat `[T; 2]` as a scalar pair like `(T, T)` when copying it.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Copy 1-/2-element arrays as scalars, not vectors For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`. And treat `[T; 2]` as a scalar pair (like `(T, T)`) when copying it. Inspired by rust-lang#101210 (comment), which pointed out that `Option<[u8; 1]>` was codegenning worse than `Option<u8>`. (I'm not sure *why* LLVM doesn't optimize out `<1 x u8>`, but might as well just not emit it in the first place in this codepath.)
(don't expect perf to come back up with much but we'll see what it does to rustc at least) |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
// (Having types like `<1 x u8>` is silly.) | ||
let ety = element.llvm_type(cx); | ||
return Some(cx.type_array(ety, *count)); | ||
} else if count.is_power_of_two() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already inside if count.is_power_of_two()
, did you mean to remove it from the outer condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I think I'd intended to remove it from the outer, but with the tests not actually failing I guess I never did.
@rustbot author
Finished benchmarking commit (b571f53): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 625.189s -> 622.203s (-0.48%) |
Copy 1-element arrays as scalars, not vectors For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`. Inspired by rust-lang#101210 (comment), which pointed out that `Option<[u8; 1]>` was codegenning worse than `Option<u8>`. (I'm not sure *why* LLVM doesn't optimize out `<1 x u8>`, but might as well just not emit it in the first place in this codepath.) --- I think I bit off too much in rust-lang#116479; let me try just the scalar case first. r? `@ghost`
…rors Copy 1-element arrays as scalars, not vectors For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`. Inspired by rust-lang#101210 (comment), which pointed out that `Option<[u8; 1]>` was codegenning worse than `Option<u8>`. (I'm not sure *why* LLVM doesn't optimize out `<1 x u8>`, but might as well just not emit it in the first place in this codepath.) --- I think I bit off too much in rust-lang#116479; let me try just the scalar case first. r? `@ghost`
…rors Copy 1-element arrays as scalars, not vectors For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`. Inspired by rust-lang#101210 (comment), which pointed out that `Option<[u8; 1]>` was codegenning worse than `Option<u8>`. (I'm not sure *why* LLVM doesn't optimize out `<1 x u8>`, but might as well just not emit it in the first place in this codepath.) --- I think I bit off too much in rust-lang#116479; let me try just the scalar case first. r? `@ghost`
Given #123185, I think this is no longer a good idea. |
For
[T; 1]
it's silly to copy as<1 x T>
when we can just copy asT
.And treat
[T; 2]
as a scalar pair (like(T, T)
) when copying it.Inspired by #101210 (comment), which pointed out that
Option<[u8; 1]>
was codegenning worse thanOption<u8>
.(I'm not sure why LLVM doesn't optimize out
<1 x u8>
, but might as well just not emit it in the first place in this codepath.)