summary refs log tree commit diff
path: root/tests/assembly/struct-target-features.rs
blob: cc86fbaa8406465810e684c3776264604a7ebd83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//@ compile-flags: -O
//@ assembly-output: emit-asm
//@ only-x86_64

#![crate_type = "lib"]
#![feature(struct_target_features)]

// Check that a struct_target_features type causes the compiler to effectively inline intrinsics.

use std::arch::x86_64::*;

#[target_feature(enable = "avx")]
struct Avx {}

#[target_feature(enable = "fma")]
struct Fma {}

pub fn add_simple(_: Avx, v: __m256) -> __m256 {
    // CHECK-NOT: call
    // CHECK: vaddps
    unsafe { _mm256_add_ps(v, v) }
}

pub fn add_complex_type(_: (&Avx, ()), v: __m256) -> __m256 {
    // CHECK-NOT: call
    // CHECK: vaddps
    unsafe { _mm256_add_ps(v, v) }
}

pub fn add_fma_combined(_: (&Avx, &Fma), v: __m256) -> (__m256, __m256) {
    // CHECK-NOT: call
    // CHECK-DAG: vaddps
    let r1 = unsafe { _mm256_add_ps(v, v) };
    // CHECK-DAG: vfmadd213ps
    let r2 = unsafe { _mm256_fmadd_ps(v, v, v) };
    (r1, r2)
}