mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
5365b3f7be
`IndexRange::len` is justified as an overall invariant, and `take_prefix` and `take_suffix` are justified by local branch conditions. A few more UB-checked calls remain in cases that are only supported locally by `debug_assert!`, which won't do anything in distributed builds, so those UB checks may still be useful. We generally expect core's `#![rustc_preserve_ub_checks]` to optimize away in user's release builds, but the mere presence of that extra code can sometimes inhibit optimization, as seen in #131563.
21 lines
425 B
Rust
21 lines
425 B
Rust
//@ compile-flags: -O
|
|
//@ revisions: host x86-64-v3
|
|
|
|
// This particular CPU regressed in #131563
|
|
//@[x86-64-v3] only-x86_64
|
|
//@[x86-64-v3] compile-flags: -Ctarget-cpu=x86-64-v3
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#[no_mangle]
|
|
pub fn test() -> usize {
|
|
// CHECK-LABEL: @test(
|
|
// CHECK: ret {{i64|i32}} 165
|
|
let values = [23, 16, 54, 3, 60, 9];
|
|
let mut acc = 0;
|
|
for item in values {
|
|
acc += item;
|
|
}
|
|
acc
|
|
}
|