-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #123930 - Mark-Simulacrum:vec-length-invariant, r=jhpratt
Tell LLVM Vec::len is invariant across growth This allows LLVM to avoid re-loading it from memory.
- Loading branch information
Showing
2 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//@ compile-flags: -O | ||
//@ only-64bit | ||
// | ||
// This test confirms that we do not reload the length of a Vec after growing it in push. | ||
|
||
#![crate_type = "lib"] | ||
|
||
// CHECK-LABEL: @should_load_once | ||
#[no_mangle] | ||
pub fn should_load_once(v: &mut Vec<u8>) { | ||
// CHECK: load i64 | ||
// CHECK: call {{.*}}grow_one | ||
// CHECK-NOT: load i64 | ||
// CHECK: add {{.*}}, 1 | ||
v.push(1); | ||
} |