Skip to content

Commit 9c77de1

Browse files
Add codegen test for issue 112169
1 parent 6c6b302 commit 9c77de1

File tree

1 file changed

+23
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)