]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/issue-83623-SIMD-PartialEq.rs
Merge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyup
[rust.git] / src / test / codegen / issue-83623-SIMD-PartialEq.rs
1 // This test checks that jumps generated by logical operators can be optimized away
2
3 // compile-flags: -Copt-level=3
4 // only-64bit
5
6 #![crate_type="lib"]
7
8 pub struct Blueprint {
9     pub fuel_tank_size: u32,
10     pub payload: u32,
11     pub wheel_diameter: u32,
12     pub wheel_width: u32,
13     pub storage: u32,
14 }
15
16 // && chains should not prevent SIMD optimizations for primitives
17 impl PartialEq for Blueprint{
18     fn eq(&self, other: &Self)->bool{
19        // CHECK-NOT: call{{.*}}bcmp
20        // CHECK-NOT: call{{.*}}memcmp
21        // CHECK-NOT: br {{.*}}
22        self.fuel_tank_size == other.fuel_tank_size
23             && self.payload == other.payload
24             && self.wheel_diameter == other.wheel_diameter
25             && self.wheel_width == other.wheel_width
26             && self.storage == other.storage
27     }
28 }
29
30 #[derive(PartialEq)]
31 pub struct Blueprint2 {
32     pub fuel_tank_size: u32,
33     pub payload: u32,
34     pub wheel_diameter: u32,
35     pub wheel_width: u32,
36     pub storage: u32,
37 }
38
39 // Derived PartialEq should not generate jumps and should use SIMD
40 #[no_mangle]
41 pub fn partial_eq_should_not_jump(a: &Blueprint2, b:&Blueprint2)->bool{
42     // CHECK-NOT: call{{.*}}bcmp
43     // CHECK-NOT: call{{.*}}memcmp
44     // CHECK-NOT: br {{.*}}
45     a==b
46 }