-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{i686,x86_64}-pc-windows-gnu Appveyor builds failing #72
Comments
The following operations of the 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);
}
} |
Filled issue upstream: rust-lang/rust#53254 |
This might be related to: #25 which shows a similar failure on apple darwin. |
Maybe @CAD97 can help set this up? |
Why me? 😛 Is it just because I jumped ship from windows-msvc to -gnu? Sure, I'm a CI guy but you already have that set up! The given minimal case passes on the Windows 10 machine I'm writing this from under
Running
|
Thank you for confirming that the repro fails! |
I see that the upstream LLVM patch has landed. Is there documentation of how to build a local version of the compiler against a development LLVM so I could potentially test to see if the patch effected this issue? |
@CAD97 see this comment: rust-lang/stdarch#513 (comment) |
Rust's llvm already has this fix. I'll see if I can reproduce it later on today. |
64bit Windows 10, latest gnu nightly and the same result as in #72 (comment) BTW I had to remove
New lint or what? |
Seems to be a Rust2018 related bug: rust-lang/rust#55344 |
Nice, as I said in my previous comment tests still fail (with NaN). |
I tested it again recently and it still happens for debug builds (release is fine) using Failing example extracted from testsuite: use packed_simd::f32x2;
fn main() {
let z = f32x2::splat(0 as f32);
let o = f32x2::splat(1 as f32);
let t = f32x2::splat(2 as f32);
assert_eq!(o, o.powf(z));
assert_eq!(o, t.powf(z));
assert_eq!(o, o.powf(o));
assert_eq!(t, t.powf(o));
let f = f32x2::splat(4 as f32);
assert_eq!(f, t.powf(t));
}
IR and assembly at the bottom of this comment. It does not reproduce when calling llvm intrinsics directly: #![feature(
repr_simd,
simd_ffi,
link_llvm_intrinsics
)]
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
#[allow(non_camel_case_types)]
struct f32x2(f32, f32);
#[allow(improper_ctypes)]
extern "C" {
#[link_name = "llvm.pow.v2f32"]
fn powf_v2f32(x: f32x2, y: f32x2) -> f32x2;
}
fn main() {
let z = f32x2(0.0, 0.0);
let o = f32x2(1.0, 1.0);
let t = f32x2(2.0, 2.0);
unsafe {
assert_eq!(powf_v2f32(o, z), o);
assert_eq!(powf_v2f32(t, z), o);
assert_eq!(powf_v2f32(o, o), o);
assert_eq!(powf_v2f32(t, o), t);
}
let f = f32x2(4.0, 4.0);
unsafe {
assert_eq!(powf_v2f32(t, t), f);
}
} For the failing example: Let me know if I can do something else to help here. |
What's the difference in the LLVM IR generated when calling intrinsics directly vs when using |
I'm pretty much beginner at this stuff but by my understanding outstanding thing here is alignment. Direct code operates on 8-byte alignment and Direct IR: https://gist.github.com/mati865/7ff6c9f76284d1526d947d0f9d82130e#file-direct-ll |
@mati865 you can use
This might be it. I'll have to investigate why the Which target are you using ? |
I was actually wondering if there is a way to remove redundant data. Direct: https://gist.github.com/mati865/4f0228869f70b2f677dd402ab9a9c6d5#file-direct-ll
Thought I mentioned it but probably I removed it during pre-post edits. At first tested it on 64 bit Windows 10 with native |
So I haven't been able to reproduce this yet. Can you replace the macro_rules! assert_eq_ {
($a:id, $b:id) => { if $a != $b { panic!() } }
} ? And remove the That would remove all the formatting code and hopefully leave only what matters (compile with |
Source code: use packed_simd::f32x2;
macro_rules! assert_eq_ {
($a:expr, $b:expr) => { if $a != $b { panic!() } }
}
fn main() {
let z = f32x2::splat(0.0);
let o = f32x2::splat(1.0);
let t = f32x2::splat(2.0);
assert_eq_!(o, o.powf(z));
assert_eq_!(o, t.powf(z));
assert_eq_!(o, o.powf(o));
assert_eq_!(t, t.powf(o));
let f = f32x2::splat(4 as f32);
assert_eq_!(f, t.powf(t));
} Build command:
|
Cool, that means that the issue persist with O1 and packed_simd, could you provide the O1 code with the same compilation options without packed_simd ? the diff should reveal the issue. |
#![feature(
repr_simd,
simd_ffi,
link_llvm_intrinsics
)]
#[repr(simd)]
#[derive(Copy, Clone, PartialEq)]
#[allow(non_camel_case_types)]
struct f32x2(f32, f32);
#[allow(improper_ctypes)]
extern "C" {
#[link_name = "llvm.pow.v2f32"]
fn powf_v2f32(x: f32x2, y: f32x2) -> f32x2;
}
macro_rules! assert_eq_ {
($a:expr, $b:expr) => { if $a != $b { panic!() } }
}
fn main() {
let z = f32x2(0.0, 0.0);
let o = f32x2(1.0, 1.0);
let t = f32x2(2.0, 2.0);
unsafe {
assert_eq_!(powf_v2f32(o, z), o);
assert_eq_!(powf_v2f32(t, z), o);
assert_eq_!(powf_v2f32(o, o), o);
assert_eq_!(powf_v2f32(t, o), t);
}
let f = f32x2(4.0, 4.0);
unsafe {
assert_eq_!(powf_v2f32(t, t), f);
}
} Built with |
There is still too much noise. If you are sure that the O1 version of non-packed-simd passes without an assert, and the O1 version of packed-simd fails with an assert, can you compile these as libraries ( |
I must have been sleepy last time I checked assembly, alignment difference exists because direct code calls |
With a lot of Running: rustc code.rs --target x86_64-pc-windows-gnu -C linker=x86_64-w64-mingw32-gcc >/dev/null 2>&1 &&\
! wine64 code.exe |
Reduced it further and updated the gist: https://gist.github.com/mati865/7f8e6600ec15f509afca8f316e7d4be3. Generated IR is quite large and I don't see important differences between I'll also post that in Rust issue. |
https://godbolt.org/z/-AF3xb uses |
Oops, I meant assembly. |
It appears that incorrect results are produced on windows when the
gnu
toolchain is used andNaN
s are involved.cc @retep007
The text was updated successfully, but these errors were encountered: