rust/tests/codegen/simd/issue-120720-reduce-nan.rs
Nicholas Nethercote 72800d3b89 Run rustfmt on tests/codegen/.
Except for `simd-intrinsic/`, which has a lot of files containing
multiple types like `u8x64` which really are better when hand-formatted.

There is a surprising amount of two-space indenting in this directory.

Non-trivial changes:
- `rustfmt::skip` needed in `debug-column.rs` to preserve meaning of the
  test.
- `rustfmt::skip` used in a few places where hand-formatting read more
  nicely: `enum/enum-match.rs`
- Line number adjustments needed for the expected output of
  `debug-column.rs` and `coroutine-debug.rs`.
2024-05-31 15:56:43 +10:00

22 lines
799 B
Rust

//@ compile-flags: -C opt-level=3 -C target-cpu=cannonlake
//@ only-x86_64
// In a previous implementation, _mm512_reduce_add_pd did the reduction with all fast-math flags
// enabled, making it UB to reduce a vector containing a NaN.
#![crate_type = "lib"]
#![feature(stdarch_x86_avx512, avx512_target_feature)]
use std::arch::x86_64::*;
// CHECK-LABEL: @demo(
#[no_mangle]
#[target_feature(enable = "avx512f")] // Function-level target feature mismatches inhibit inlining
pub unsafe fn demo() -> bool {
// CHECK: %0 = tail call reassoc double @llvm.vector.reduce.fadd.v8f64(
// CHECK: %_0.i = fcmp uno double %0, 0.000000e+00
// CHECK: ret i1 %_0.i
let res =
unsafe { _mm512_reduce_add_pd(_mm512_set_pd(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, f64::NAN)) };
res.is_nan()
}