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

Beta backports #36591

Merged
merged 3 commits into from
Sep 20, 2016
Merged

Beta backports #36591

merged 3 commits into from
Sep 20, 2016

Conversation

nagisa and others added 3 commits September 19, 2016 23:42
Go back on half the specialization, the part that changed the Zip
struct's fields themselves depending on the types of the iterators.

This means that the Zip iterator will always carry two usize fields,
which are unused. If a whole for loop using a .zip() iterator is
inlined, these are simply removed and have no effect.

The same improvement for Zip of for example slice iterators remain, and
they still optimize well. However, like when the specialization of zip
was merged, the compiler is still very sensistive to the exact context.

For example this code only autovectorizes if the function is used, not
if the code in zip_sum_i32 is inserted inline it was called:

```
fn zip_sum_i32(xs: &[i32], ys: &[i32]) -> i32 {
    let mut s = 0;
    for (&x, &y) in xs.iter().zip(ys) {
        s += x * y;
    }
    s
}

fn zipdot_i32_default_zip(b: &mut test::Bencher)
{
    let xs = vec![1; 1024];
    let ys = vec![1; 1024];

    b.iter(|| {
        zip_sum_i32(&xs, &ys)
    })
}
```

Include a test that checks that Zip<T, U> is covariant w.r.t. T and U.
@sophiajt
Copy link
Contributor

@brson - the first three look good to me. Feel free to r=me

@brson brson merged commit 34622fb into rust-lang:beta Sep 20, 2016
@pnkfelix pnkfelix mentioned this pull request Sep 21, 2016
pmatos pushed a commit to LinkiTools/rust that referenced this pull request Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants