Skip to content

Commit e66f88c

Browse files
added codegen test for issue 112169
1 parent 6c6b302 commit e66f88c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/codegen/issues/issue-112169.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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: define{{.*}}i32 @issue_112169(){{.*}}{
8+
#[no_mangle]
9+
pub fn issue_112169() -> i32 {
10+
// CHECK-NOT: icmp
11+
// CHECK-NOT: add
12+
// CHECK-NOT: br
13+
// CHECK: ret i32 102
14+
// CHECK-NOT: icmp
15+
// CHECK-NOT: add
16+
// CHECK-NOT: br
17+
let mut s = 0;
18+
19+
for i in 0..102 {
20+
if i == 0 {
21+
s = i;
22+
}
23+
24+
s += 1;
25+
}
26+
27+
s
28+
}

0 commit comments

Comments
 (0)