Files
rust/library
Jacob Pratt 8c6ef9fb36 Rollup merge of #158879 - WaffleLapkin:slice_iter_next_chunk_simp, r=JohnTitor
simplify `slice::Iter[Mut]::next_chunk` implementation

I verified that this doesn't pessimize codegen using the example from the PR that inroduced the optimization of `next_chunk` (rust-lang/rust#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
```

r? libs
cc @bend-n
2026-07-28 20:09:36 -04:00
..
2026-07-26 04:23:22 +00:00
2026-07-20 10:49:36 +02:00
…
2026-07-27 11:32:43 +02:00
2026-07-22 10:49:07 +08:00