Skip to content

Commit

Permalink
Auto merge of rust-lang#124087 - SadiinsoSnowfall:master, r=Mark-Simu…
Browse files Browse the repository at this point in the history
…lacrum

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 ^^
  • Loading branch information
bors committed Apr 21, 2024
2 parents b9be3c4 + 9c77de1 commit 5c6b635
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/codegen/issues/issue-112169-long-iterator-unroll.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//@ compile-flags: -O
#![crate_type = "lib"]

// Test that simple iterator-based loops of length > 101 are fully optimized away.
// See <https://github.com/rust-lang/rust/issues/112169>

// CHECK-LABEL: issue_112169()
#[no_mangle]
pub fn issue_112169() -> i32 {
// CHECK-NEXT: {{.*}}:
// CHECK-NEXT: ret i32 102
let mut s = 0;

for i in 0..102 {
if i == 0 {
s = i;
}

s += 1;
}

s
}

0 comments on commit 5c6b635

Please sign in to comment.