Skip to content

Add codegen test for 112169 #124087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 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,24 @@
//@ compile-flags: -O
//@ ignore-wasm FIXME: LLVM does not vectorize loops on WASM so this doesn't get optimized
#![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
}
Loading