about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-23 00:16:03 +0000
committerbors <bors@rust-lang.org>2023-07-23 00:16:03 +0000
commit1c44af9b791c16557b5bf606707bb76df979134a (patch)
treec1b61598822646a529fd6ba2f96bedfc5f84aefc /tests/codegen
parent98179ad634b1039e5db084f545c59c58c7f96222 (diff)
parentcdb9de7e8bd70c7e3580ec28b37af879e555f45d (diff)
downloadrust-1c44af9b791c16557b5bf606707bb76df979134a.tar.gz
rust-1c44af9b791c16557b5bf606707bb76df979134a.zip
Auto merge of #111836 - calebzulawski:target-feature-closure, r=workingjubilee
Fix #[inline(always)] on closures with target feature 1.1

Fixes #108655.  I think this is the most obvious solution that isn't overly complicated.  The comment includes more justification, but I think this is likely better than demoting the `#[inline(always)]` to `#[inline]`, since existing code is unaffected.
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)
+}