about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-09-21 16:13:24 +0000
committerbors <bors@rust-lang.org>2021-09-21 16:13:24 +0000
commit840acd378a273dab6798352d3d6a087fa09e4806 (patch)
tree3752e1c012309eaf9d73e687361ab5d34a544a47 /src/test/codegen
parent7743c9fadd64886d537966ba224b9c20e6014a59 (diff)
parent4185b76dc3d3b22292033125487c07ce52276b11 (diff)
Auto merge of #88981 - durin42:llvm-14-crc32, r=nagisa
rustc_codegen_llvm: make sse4.2 imply crc32 for LLVM 14

This fixes compiling things like the `snap` crate after
https://reviews.llvm.org/D105462. I added a test that verifies the
additional attribute gets specified, and confirmed that I can build
cargo with both LLVM 13 and 14 with this change applied.

r? `@nagisa` cc `@nikic`
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/sse42-implies-crc32.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/codegen/sse42-implies-crc32.rs b/src/test/codegen/sse42-implies-crc32.rs
new file mode 100644
index 00000000000..47b1a899340
--- /dev/null
+++ b/src/test/codegen/sse42-implies-crc32.rs
@@ -0,0 +1,16 @@
+// only-x86_64
+// min-llvm-version: 14.0
+// compile-flags: -Copt-level=3
+
+#![crate_type = "lib"]
+
+#[cfg(target_arch = "x86_64")]
+#[target_feature(enable = "sse4.2")]
+#[no_mangle]
+pub unsafe fn crc32sse(v: u8) -> u32 {
+    use std::arch::x86_64::*;
+    let out = !0u32;
+    _mm_crc32_u8(out, v)
+}
+
+// CHECK: attributes #0 {{.*"target-features"="\+sse4.2,\+crc32"}}