-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-SIMDArea: SIMD (Single Instruction Multiple Data)Area: SIMD (Single Instruction Multiple Data)C-bugCategory: This is a bug.Category: This is a bug.O-windows-gnuToolchain: GNU, Operating system: WindowsToolchain: GNU, Operating system: Windows
Description
crossref: rust-lang/packed_simd#72
The following operations of the f32x2
vector type produce incorrect results on gnu windows targets ({i686, x86_64}-pc-windows-gnu
) in debug builds: sin
, cos
, fma
, scalar (+,-,*,/, unary -):
64::f32x2_math_cos::cos' panicked at 'assertion failed: `(left == right)`
left: `f32x2(-0.00000004371139, -0.00000004371139)`,
right: `f32x2(NaN, -0.00000004371139)`', src\v64.rs:43:1
---- v64::f32x2_math_fma::fma stdout ----
thread 'v64::f32x2_math_fma::fma' panicked at 'assertion failed: `(left == right)`
left: `f32x2(1.0, 1.0)`,
right: `f32x2(NaN, NaN)`', src\v64.rs:43:1
---- v64::f32x2_math_sin::sin stdout ----
thread 'v64::f32x2_math_sin::sin' panicked at 'assertion failed: `(left == right)`
left: `f32x2(1.0, 1.0)`,
right: `f32x2(NaN, 1.0)`', src\v64.rs:43:1
---- v64::f32x2_ops_scalar_arith::ops_scalar_arithmetic stdout ----
thread 'v64::f32x2_ops_scalar_arith::ops_scalar_arithmetic' panicked at 'assertion failed: `(left == right)`
left: `f32x2(NaN, 0.0)`,
right: `f32x2(0.0, 0.0)`', src\v64.rs:43:1
---- v64::f32x2_ops_vector_arith::ops_vector_arithmetic stdout ----
thread 'v64::f32x2_ops_vector_arith::ops_vector_arithmetic' panicked at 'assertion failed: `(left == right)`
left: `f32x2(NaN, 0.0)`,
right: `f32x2(0.0, 0.0)`', src\v64.rs:43:1
I can't reproduce locally but the following could help somebody to try to reproduce this on Windows, and maybe figure out what's going on.
This playground example might be used to reproduce this though (I can't know since I don't have access to the platform - it would be good to know if that reproduces the issue or not to narrow down the root cause):
#![feature(
repr_simd,
simd_ffi,
link_llvm_intrinsics,
platform_intrinsics
)]
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
#[allow(non_camel_case_types)]
struct f32x2(f32, f32);
extern "platform-intrinsic" {
fn simd_fma<T>(a: T, b: T, c: T) -> T;
}
#[allow(improper_ctypes)]
extern "C" {
#[link_name = "llvm.cos.v2f32"]
fn cos_v2f32(x: f32x2) -> f32x2;
#[link_name = "llvm.sin.v2f32"]
fn sin_v2f32(x: f32x2) -> f32x2;
}
fn main() {
let a = f32x2(1.0, 1.0);
let b = f32x2(0.0, 0.0);
let c = f32x2(2.0, 2.0);
unsafe {
assert_eq!(simd_fma(a, c, b), c);
assert_eq!(sin_v2f32(b), b);
assert_eq!(cos_v2f32(b), a);
}
}
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-SIMDArea: SIMD (Single Instruction Multiple Data)Area: SIMD (Single Instruction Multiple Data)C-bugCategory: This is a bug.Category: This is a bug.O-windows-gnuToolchain: GNU, Operating system: WindowsToolchain: GNU, Operating system: Windows