File: libm_std_can_float.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 893,176 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; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (23 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//@ run-pass

// This is the converse of the other libm test.
#![feature(portable_simd)]
use std::simd::f32x4;
use std::simd::{num::SimdFloat, StdFloat};

// For SIMD float ops, the LLIR version which is used to implement the portable
// forms of them may become calls to math.h AKA libm. So, we can't guarantee
// we can compile them for #![no_std] crates.
//
// However, we can expose some of these ops via an extension trait.
fn main() {
    let x = f32x4::from_array([0.1, 0.5, 0.6, -1.5]);
    let x2 = x + x;
    let _xc = x.ceil();
    let _xf = x.floor();
    let _xr = x.round();
    let _xt = x.trunc();
    let _xfma = x.mul_add(x, x);
    let _xsqrt = x.sqrt();
    let _ = x2.abs() * x2;
}