-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Closed
Labels
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
I want to initialize a large Vec<Option<i32>> with None.
pub fn vec_none() -> Vec<Option<i32>> {
vec![None; 1024]
}
Compiling with Rust 1.66 -C opt-level=3 -C target-cpu=skylake generates mov instructions.
However, after initializing with Some(...) the code gets vectorized as expected:
pub fn vec_some() -> Vec<Option<i32>> {
vec![Some(42); 1024]
}
The generated assembly contains vmovups instructions.
Now, the weird thing is that if I have both functions in the same file, both get vectorized.
See this demonstration. As long asvec_some() is commented out, vec_none() is not vectorized. As soon as you remove the comment, both functions are vectorized.
Metadata
Metadata
Assignees
Labels
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.