Skip to content

Miscompilation in _mm512_reduce_add_pd, assumes values not NaN #120720

Closed
@orlp

Description

@orlp

The following example should obviously compile to a panic, as the documentation of _mm512_reduce_add_pd mentions nothing about NaNs not being respected:

#![feature(stdsimd)]
use core::arch::x86_64::*;

#[no_mangle]
unsafe fn test() -> f64 {
    let ret = _mm512_reduce_add_pd(_mm512_set_pd(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, f64::NAN));
    if ret.is_nan() {
        panic!("hi")
    }
    ret
}

However, when compiled with -C opt-level=3 -C target-cpu=cannonlake on the latest nightly there is no panic generated, despite the output being NaN regardless:

.LCPI0_0:
        .quad   0x7ff8000000000000
test:
        vmovsd  xmm0, qword ptr [rip + .LCPI0_0]
        ret

Metadata

Metadata

Assignees

Labels

A-SIMDArea: SIMD (Single Instruction Multiple Data)C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityPG-portable-simdProject group: Portable SIMD (https://github.com/rust-lang/project-portable-simd)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions