Skip to content

Commit 31ddbd4

Browse files
Add regression test for #120189
1 parent d5525a7 commit 31ddbd4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//! Loop inside closure correctly compiled to assembly using SSE instructions.
2+
//! Regression test for <https://github.com/rust-lang/rust/issues/120189>.
3+
//! also see <https://godbolt.org/z/W1Yc4s3xo>
4+
//@ assembly-output: emit-asm
5+
//@ compile-flags: -Copt-level=3
6+
//@ only-x86_64
7+
// to test SSE instructions
8+
9+
#![crate_type = "lib"]
10+
11+
// CHECK-LABEL: for_in_closure
12+
// CHECK: {{paddb|psubb}}
13+
#[inline(never)]
14+
#[no_mangle]
15+
pub fn for_in_closure() {
16+
let mut v = [[0u8; 4]; 60];
17+
18+
let mut closure = || {
19+
for item in &mut v {
20+
item[0] += 1;
21+
item[1] += 1;
22+
item[2] += 1;
23+
item[3] += 1;
24+
}
25+
};
26+
27+
closure();
28+
}

0 commit comments

Comments
 (0)