Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5c6b635

Browse files
committed
Auto merge of rust-lang#124087 - SadiinsoSnowfall:master, r=Mark-Simulacrum
Add codegen test for 112169 Add codegen test for rust-lang#112169. The test passes but it's my first time using FileCheck, don't hesitate to tell me if this can be improved ^^
2 parents b9be3c4 + 9c77de1 commit 5c6b635

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)