Rollup merge of #149815 - is57primenumber:add-slp-vectorize-test, r=chenyukang

Add regression test for #120189

This PR adds regression tests for rust-lang/rust#120189.
I added tests to verify vectorization of loops inside closures.
This commit is contained in:
Matthias Krüger 2025-12-19 09:25:25 +01:00 committed by GitHub
commit eb0f57507c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,28 @@
//! Loop inside closure correctly compiled to assembly using SSE instructions.
//! Regression test for <https://github.com/rust-lang/rust/issues/120189>.
//! also see <https://godbolt.org/z/W1Yc4s3xo>
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3
//@ only-x86_64
// to test SSE instructions
#![crate_type = "lib"]
// CHECK-LABEL: for_in_closure
// CHECK: {{paddb|psubb}}
#[inline(never)]
#[no_mangle]
pub fn for_in_closure() {
let mut v = [[0u8; 4]; 60];
let mut closure = || {
for item in &mut v {
item[0] += 1;
item[1] += 1;
item[2] += 1;
item[3] += 1;
}
};
closure();
}