about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorAngelicosPhosphoros <xuzin.timur@gmail.com>2021-03-30 00:19:10 +0300
committerAngelicosPhosphoros <xuzin.timur@gmail.com>2021-04-01 18:34:11 +0300
commit4464cc2256b2ccf5fbdaaf60135db11537d5bff9 (patch)
treef9fab1afa194b56acaef57a5869f1e50ff4ed51e /src/test/codegen
parentcc4103089f40a163f6d143f06359cba7043da29b (diff)
downloadrust-4464cc2256b2ccf5fbdaaf60135db11537d5bff9.tar.gz
rust-4464cc2256b2ccf5fbdaaf60135db11537d5bff9.zip
Simplify logical operations CFG
This is basically same commit as e38e954a0d249f88d0a55504f70d6055e865a931 which was reverted later in 676953fde9120cda62e4ef2f75a804af7481d6af
In both cases, this changes weren't benchmarked.
e38e954a0d249f88d0a55504f70d6055e865a931 leads to missed optimization described in [this issue](https://github.com/rust-lang/rust/issues/62993)
676953fde9120cda62e4ef2f75a804af7481d6af leads to missed optimization described in [this issue](https://github.com/rust-lang/rust/issues/83623)

Also it changes some src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump* files automatically.
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/issue-83623-SIMD-PartialEq.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/codegen/issue-83623-SIMD-PartialEq.rs b/src/test/codegen/issue-83623-SIMD-PartialEq.rs
new file mode 100644
index 00000000000..b22b7f52402
--- /dev/null
+++ b/src/test/codegen/issue-83623-SIMD-PartialEq.rs
@@ -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
+}