Skip to content

Commit fb5f05e

Browse files
Added codegen test for issue 112169
1 parent 6c6b302 commit fb5f05e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ compile-flags: -O
2+
//@ ignore-wasm FIXME: LLVM does not vectorize loops on WASM so this doesn't get optimized
3+
#![crate_type = "lib"]
4+
5+
// Test that simple iterator-based loops of length > 101 are fully optimized away.
6+
// See <https://github.com/rust-lang/rust/issues/112169>
7+
8+
// CHECK-LABEL: issue_112169()
9+
#[no_mangle]
10+
pub fn issue_112169() -> i32 {
11+
// CHECK-NEXT: {{.*}}:
12+
// CHECK-NEXT: ret i32 102
13+
let mut s = 0;
14+
15+
for i in 0..102 {
16+
if i == 0 {
17+
s = i;
18+
}
19+
20+
s += 1;
21+
}
22+
23+
s
24+
}

0 commit comments

Comments
 (0)