4 // LLVM can't optimize some loops with a large number of iterations because of
5 // @llvm.sideeffect() (see also #59546)
8 // ignore-debug: the debug assertions get in the way
10 #![crate_type = "lib"]
12 // verify that LLVM recognizes a loop involving 0..=n and will const-fold it.
14 // Example from original issue #45222
16 fn foo2(n: u64) -> u64 {
19 for j in (0..=n).rev() {
26 // CHECK-LABEL: @check_foo2
28 pub fn check_foo2() -> u64 {
29 // CHECK: ret i64 500005000000000
33 // Simplified example of #45222
35 fn triangle_inc(n: u64) -> u64 {
43 // CHECK-LABEL: @check_triangle_inc
45 pub fn check_triangle_inc() -> u64 {
46 // CHECK: ret i64 5000050000
52 fn foo3r(n: u64) -> u64 {
55 (0 ..= n).rev().for_each(|j| {
62 // CHECK-LABEL: @check_foo3r
64 pub fn check_foo3r() -> u64 {
65 // CHECK: ret i64 500050000000