Skip to content

x86_64 simd fmadd (and other) bug (release only) #56950

Closed
@kali

Description

@kali

This bit of code falls in the assert in Release, while working in Debug.

Both stable and nightly.

https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=6f280db2aaf8241e46a080f4189e0328

use std::arch::x86_64::*;

fn main() {
        unsafe {
            let a = [2.0f32, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
            let b = -1.0f32;

            let ar = _mm256_loadu_ps(a.as_ptr());
            println!("ar: {:?}", ar);
            let br = _mm256_set1_ps(b);
            println!("br: {:?}", br);
            let mut abr = _mm256_setzero_ps();
            println!("ab: {:?}", abr);
            abr = _mm256_fmadd_ps(ar, br, abr);
            println!("ab: {:?}", abr);
            
            let mut ab = [0.0; 8];
            _mm256_storeu_ps(ab.as_mut_ptr(), abr);
            assert_eq!(ab[0], -2.0f32);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions