forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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 rust-lang#83663 - AngelicosPhosphoros:simplify_binary_a…
…nd_to_get_better_asm, r=nagisa Simplify logical operations CFG This is basically same commit as e38e954 which was reverted later in 676953f In both cases, this changes weren't benchmarked. e38e954 leads to missed optimization described in [this issue](rust-lang#62993) 676953f leads to missed optimization described in [this issue](rust-lang#83623)
- Loading branch information
Showing
8 changed files
with
352 additions
and
317 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,46 @@ | ||
// This test checks that jumps generated by logical operators can be optimized away | ||
|
||
// compile-flags: -Copt-level=3 | ||
// only-64bit | ||
|
||
#![crate_type="lib"] | ||
|
||
pub struct Blueprint { | ||
pub fuel_tank_size: u32, | ||
pub payload: u32, | ||
pub wheel_diameter: u32, | ||
pub wheel_width: u32, | ||
pub storage: u32, | ||
} | ||
|
||
// && chains should not prevent SIMD optimizations for primitives | ||
impl PartialEq for Blueprint{ | ||
fn eq(&self, other: &Self)->bool{ | ||
// CHECK-NOT: call{{.*}}bcmp | ||
// CHECK-NOT: call{{.*}}memcmp | ||
// CHECK-NOT: br {{.*}} | ||
self.fuel_tank_size == other.fuel_tank_size | ||
&& self.payload == other.payload | ||
&& self.wheel_diameter == other.wheel_diameter | ||
&& self.wheel_width == other.wheel_width | ||
&& self.storage == other.storage | ||
} | ||
} | ||
|
||
#[derive(PartialEq)] | ||
pub struct Blueprint2 { | ||
pub fuel_tank_size: u32, | ||
pub payload: u32, | ||
pub wheel_diameter: u32, | ||
pub wheel_width: u32, | ||
pub storage: u32, | ||
} | ||
|
||
// Derived PartialEq should not generate jumps and should use SIMD | ||
#[no_mangle] | ||
pub fn partial_eq_should_not_jump(a: &Blueprint2, b:&Blueprint2)->bool{ | ||
// CHECK-NOT: call{{.*}}bcmp | ||
// CHECK-NOT: call{{.*}}memcmp | ||
// CHECK-NOT: br {{.*}} | ||
a==b | ||
} |
Oops, something went wrong.