about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-07-23 09:27:28 +0200
committerRalf Jung <post@ralfj.de>2023-07-23 09:27:28 +0200
commit8a3b7463ed657ddc3d705c44028f1fe7915edb60 (patch)
treed5cc4f8f0bbfae65d776880374519df12393f27e /tests/codegen
parent46ddf460afb6b277700f1bac9a3e26b34dc2ed62 (diff)
parentcec34a43b1b14f4e39363f3b283d7ac4f593ee81 (diff)
downloadrust-8a3b7463ed657ddc3d705c44028f1fe7915edb60.tar.gz
rust-8a3b7463ed657ddc3d705c44028f1fe7915edb60.zip
Merge from rustc
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/target-feature-inline-closure.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/codegen/target-feature-inline-closure.rs b/tests/codegen/target-feature-inline-closure.rs
new file mode 100644
index 00000000000..d075706173f
--- /dev/null
+++ b/tests/codegen/target-feature-inline-closure.rs
@@ -0,0 +1,33 @@
+// only-x86_64
+// compile-flags: -Copt-level=3
+
+#![crate_type = "lib"]
+#![feature(target_feature_11)]
+
+#[cfg(target_arch = "x86_64")]
+use std::arch::x86_64::*;
+
+// CHECK-LABEL: @with_avx
+#[no_mangle]
+#[cfg(target_arch = "x86_64")]
+#[target_feature(enable = "avx")]
+fn with_avx(x: __m256) -> __m256 {
+    // CHECK: fadd
+    let add = {
+        #[inline(always)]
+        |x, y| unsafe { _mm256_add_ps(x, y) }
+    };
+    add(x, x)
+}
+
+// CHECK-LABEL: @without_avx
+#[no_mangle]
+#[cfg(target_arch = "x86_64")]
+unsafe fn without_avx(x: __m256) -> __m256 {
+    // CHECK-NOT: fadd
+    let add = {
+        #[inline(always)]
+        |x, y| unsafe { _mm256_add_ps(x, y) }
+    };
+    add(x, x)
+}