Skip to content

Commit 6c12546

Browse files
authored
Rollup merge of #134871 - clubby789:test-63646, r=compiler-errors
Add codegen test for issue 63646 Closes #63646
2 parents 953418c + 71e3ea3 commit 6c12546

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/codegen/range_to_inclusive.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//! Test that `RangeTo` and `RangeToInclusive` generate identical
2+
//! (and optimal) code; #63646
3+
//@ compile-flags: -O -Zmerge-functions=disabled
4+
#![crate_type = "lib"]
5+
6+
#[no_mangle]
7+
// CHECK-LABEL: range_to(
8+
pub fn range_to(a: i32, mut b: i32) -> i32 {
9+
// CHECK: %1 = and i32 %0, %a
10+
// CHECK-NEXT: ret i32 %1
11+
for _ in 0..65 {
12+
b &= a;
13+
}
14+
15+
b
16+
}
17+
18+
#[no_mangle]
19+
// CHECK-LABEL: range_to_inclusive(
20+
pub fn range_to_inclusive(a: i32, mut b: i32) -> i32 {
21+
// CHECK: %1 = and i32 %0, %a
22+
// CHECK-NEXT: ret i32 %1
23+
for _ in 0..=64 {
24+
b &= a;
25+
}
26+
27+
b
28+
}

0 commit comments

Comments
 (0)