miri icon indicating copy to clipboard operation
miri copied to clipboard

Dot-product reduction mismatch

Open Forever119 opened this issue 3 weeks ago • 4 comments

For a rounding-sensitive reduction and an all-negative-zero reduction, Miri differs from native DPPS.

Program

use std::arch::x86_64::*;
fn main() { unsafe {
    let a = std::mem::transmute([1e20f32, 1., -1e20, 1.]);
    let b = _mm_set1_ps(1.);
    let r: [f32;4] = std::mem::transmute(_mm_dp_ps::<0xff>(a,b));
    println!("dot_tree={r:?}");
    let a = _mm_set1_ps(-0.0);
    let r: [u32;4] = std::mem::transmute(_mm_dp_ps::<0xff>(a,b));
    println!("dot_negative_zero={r:08x?}");
} }

Output

native:
dot_tree=[0.0, 0.0, 0.0, 0.0]
dot_negative_zero=[80000000, 80000000, 80000000, 80000000]


miri:
dot_tree=[1.0, 1.0, 1.0, 1.0]
dot_negative_zero=[00000000, 00000000, 00000000, 00000000]

Forever119 avatar Nov 09 '26 02:11 Forever119

This is a bug in Miri's, which violate the Intel SDM specification.

@rustbot claim

@programskillforverification you are claiming all new issues currently. Please stop doing that. Other people might also want to claim issues.

You can claim this one once the other two are fixed, if noone else has claimed it in the mean time.

RalfJung avatar Nov 09 '26 07:11 RalfJung

@rustbot claim

Kaileshwar16 avatar Nov 09 '26 09:11 Kaileshwar16