diff options
| author | Caleb Zulawski <caleb.zulawski@gmail.com> | 2023-07-16 21:25:46 -0400 |
|---|---|---|
| committer | Caleb Zulawski <caleb.zulawski@gmail.com> | 2023-07-16 21:26:08 -0400 |
| commit | cdb9de7e8bd70c7e3580ec28b37af879e555f45d (patch) | |
| tree | d59e5cf9aacd88e314a348901107ceeec3362663 /tests/codegen | |
| parent | ddb16e2884cdfe3c1c7eff8a431d1165213f7842 (diff) | |
| download | rust-cdb9de7e8bd70c7e3580ec28b37af879e555f45d.tar.gz rust-cdb9de7e8bd70c7e3580ec28b37af879e555f45d.zip | |
Add codegen test ensuring always-inline closures don't bypass target features
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/target-feature-inline-closure.rs | 33 |
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) +} |
