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

Remove array_zip #112096

Merged
merged 2 commits into from
May 31, 2023
Merged

Remove array_zip #112096

merged 2 commits into from
May 31, 2023

Conversation

workingjubilee
Copy link
Member

[T; N]::zip is "eager" but most zips are mapped. This causes poor optimization in generated code. This is a fundamental design issue and "zip" is "prime real estate" in terms of function names, so let's free it up again.

Could use review to make sure we aren't losing any essential codegen tests.
r? @scottmcm

`[T; N]::zip` is "eager" but most zips are mapped.
This causes poor optimization in generated code.
This is a fundamental design issue and "zip" is
"prime real estate" in terms of function names,
so let's free it up again.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 30, 2023
@workingjubilee workingjubilee added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 30, 2023
Comment on lines 34 to 43

// CHECK-LABEL: @auto_vectorize_array_zip_map
#[no_mangle]
pub fn auto_vectorize_array_zip_map(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
a.zip(b).map(|(a, b)| a + b)
}
Copy link
Member

@scottmcm scottmcm May 30, 2023

Choose a reason for hiding this comment

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

I'd like to keep something with extra layers of abstraction here, so how about

Suggested change
// CHECK-LABEL: @auto_vectorize_array_zip_map
#[no_mangle]
pub fn auto_vectorize_array_zip_map(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
a.zip(b).map(|(a, b)| a + b)
}
// CHECK-LABEL: @auto_vectorize_array_from_fn
#[no_mangle]
pub fn auto_vectorize_array_from_fn(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
// CHECK: load <4 x float>
// CHECK: load <4 x float>
// CHECK: fadd <4 x float>
// CHECK: store <4 x float>
std::array::from_fn(|i| a[i] + b[i])
}

@scottmcm
Copy link
Member

r=me with the codegen test suggested above

@workingjubilee
Copy link
Member Author

@bors r=scottmcm rollup

@bors
Copy link
Contributor

bors commented May 31, 2023

📌 Commit 374f5a8 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 May 31, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#112031 (Migrate  `item_proc_macro` to Askama)
 - rust-lang#112053 (Remove `-Zcgu-partitioning-strategy`.)
 - rust-lang#112069 (offset_of: don't require type to be `Sized`)
 - rust-lang#112084 (enhancements on  build_helper utilization and rustdoc-gui-test)
 - rust-lang#112096 (Remove array_zip)
 - rust-lang#112108 (Fix re-export of doc hidden item inside private item not displayed)
 - rust-lang#112113 (rustdoc: simplify `clean` by removing `FnRetTy`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 88160ab into rust-lang:master May 31, 2023
@rustbot rustbot added this to the 1.72.0 milestone May 31, 2023
@workingjubilee workingjubilee deleted the array-unzip branch July 31, 2023 17:53
overvenus added a commit to overvenus/tikv that referenced this pull request Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

array::zip in combination with array::map optimises very poorly Tracking Issue for array_zip
4 participants