File: closure-inherit-target-feature.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (59 lines) | stat: -rw-r--r-- 1,831 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//@ only-x86_64
//@ ignore-sgx Tests incompatible with LVI mitigations
//@ assembly-output: emit-asm
// make sure the feature is not enabled at compile-time
//@ compile-flags: -C opt-level=3 -C target-feature=-sse4.1 -C llvm-args=-x86-asm-syntax=intel

#![feature(target_feature_11)]
#![crate_type = "rlib"]

use std::arch::x86_64::{__m128, _mm_blend_ps};

#[no_mangle]
pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 {
    let f = {
        // check that _mm_blend_ps is not being inlined into the closure
        // CHECK-LABEL: {{sse41_blend_nofeature.*closure.*:}}
        // CHECK-NOT: blendps
        // CHECK: {{call .*_mm_blend_ps.*}}
        // CHECK-NOT: blendps
        // CHECK: ret
        #[inline(never)]
        |x, y| _mm_blend_ps(x, y, 0b0101)
    };
    f(x, y)
}

#[no_mangle]
#[target_feature(enable = "sse4.1")]
pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 {
    let f = {
        // check that _mm_blend_ps is being inlined into the closure
        // CHECK-LABEL: {{sse41_blend_noinline.*closure.*:}}
        // CHECK-NOT: _mm_blend_ps
        // CHECK: blendps
        // CHECK-NOT: _mm_blend_ps
        // CHECK: ret
        #[inline(never)]
        |x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
    };
    f(x, y)
}

#[no_mangle]
#[target_feature(enable = "sse4.1")]
pub fn sse41_blend_doinline(x: __m128, y: __m128) -> __m128 {
    // check that the closure and _mm_blend_ps are being inlined into the function
    // CHECK-LABEL: sse41_blend_doinline:
    // CHECK-NOT: {{sse41_blend_doinline.*closure.*}}
    // CHECK-NOT: _mm_blend_ps
    // CHECK: blendps
    // CHECK-NOT: {{sse41_blend_doinline.*closure.*}}
    // CHECK-NOT: _mm_blend_ps
    // CHECK: ret
    let f = {
        #[inline]
        |x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
    };
    f(x, y)
}