Skip to content

Remove array_zip - #112096

Merged
bors merged 2 commits into
rust-lang:masterfrom
workingjubilee:array-unzip
May 31, 2023
Merged

Remove array_zip#112096
bors merged 2 commits into
rust-lang:masterfrom
workingjubilee:array-unzip

Conversation

@workingjubilee

Copy link
Copy Markdown
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.
@rustbotrustbot 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
@workingjubileeworkingjubilee added T-libs-api [DEPRECATED; DO NOT USE] 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)
}

@scottmcmscottmcmMay 30, 2023

Copy link
Copy Markdown
Member

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]
pubfnauto_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]
pubfnauto_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
Copy Markdown
Member

r=me with the codegen test suggested above

@workingjubilee

Copy link
Copy Markdown
MemberAuthor

@bors r=scottmcm rollup

@bors

bors commented May 31, 2023

Copy link
Copy Markdown
Collaborator

📌 Commit 374f5a8 has been approved by scottmcm

It is now in the queue for this repository.

@borsbors 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:masterMay 31, 2023
@rustbotrustbot 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
See rust-lang/rust/pull/112096
Signed-off-by: Neil Shen <overvenus@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libs-api[DEPRECATED; DO NOT USE]

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

@workingjubilee@scottmcm@bors@rustbot