In the following, is_infinite is optimized to always return zero, but it should instead perform fabs and cmp:
#![feature(platform_intrinsics, repr_simd)]
extern "platform-intrinsic" {
fn simd_fabs<T>(x: T) -> T;
fn simd_eq<T, U>(x: T, y: T) -> U;
}
#[repr(simd)]
pub struct V([f32; 4]);
#[repr(simd)]
pub struct M([i32; 4]);
pub fn is_infinite(v: V) -> M {
unsafe {
simd_eq(simd_fabs(v), V([f32::INFINITY; 4]))
}
}
It works correctly in debug, and fails in release.
Playground link: https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=49b790d5e14139e6bea9e57b0ae381d5
The problem is related to simd_fabs, because in stdsimd we are currently using simd_xor instead of simd_fabs and that optimizes correctly.
Meta
rustc --version --verbose:
rustc 1.53.0-nightly (b0c818c5e 2021-04-16)
binary: rustc
commit-hash: b0c818c5e0fa37251d9fda2f656bf1041a2e1e1d
commit-date: 2021-04-16
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0
In the following,
is_infiniteis optimized to always return zero, but it should instead performfabsandcmp:It works correctly in debug, and fails in release.
Playground link: https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=49b790d5e14139e6bea9e57b0ae381d5
The problem is related to
simd_fabs, because instdsimdwe are currently usingsimd_xorinstead ofsimd_fabsand that optimizes correctly.Meta
rustc --version --verbose: