Closed
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.