mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-01 09:32:15 +00:00
I verified that this doesn't pessimize codegen using the example from the
PR that inroduced the optimization of `next_chunk` (# 149131):
```rust
#![feature(iter_next_chunk)]
#[no_mangle]
pub fn simd_sum_slow(arr: &[u32]) -> u32 {
const STEP_SIZE: usize = 16;
let mut result = [0; STEP_SIZE];
let mut iter = arr.iter();
while let Ok(c) = iter.next_chunk::<STEP_SIZE>() {
for (&n, r) in c.iter().zip(result.iter_mut()) {
*r += n;
}
}
result.iter().sum()
}
```
I compiled this example with
```shell
./build/host/stage1/bin/rustc t.rs --emit=asm -O --crate-type=lib
```
Before and after this change; the only difference is the choice of the
jump instruction, which I think shouldn't make any difference:
```diff
28,29c28,29
< cmpq $64, %rsi
< jae .LBB0_2
---
> cmpq $60, %rsi
> ja .LBB0_2
```