PowerPC AltiVec source vector subnormal values are not flushed to zero
Host environment
- Operating system: Ubuntu 20.04
- OS/kernel version: Linux ab4ce1e724be 5.10.47-linuxkit #1 SMP Sat Jul 3 21:51:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
- Architecture: x86-64
- QEMU flavor: qemu-ppc
- QEMU version: 7.0.0
- QEMU command line:
qemu-ppc -cpu e600 /target/powerpc-unknown-linux-gnu/debug/ppc-error
Emulated/Virtualized environment
- Operating system: Ubuntu
- OS/kernel version: Linux ab4ce1e724be 5.10.47-linuxkit #1 SMP Sat Jul 3 21:51:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
- Architecture: PowerPC
Description of problem
AltiVec specifies that source and result vectors are flushed to zero (in NJ mode). Only result vectors are flushed to zero.
Steps to reproduce
- Compile the attached Rust program (e.g.
cargo +nightly build --target powerpc-unknown-linux-gnu
) - Run the program and expect assertions to pass.
- See assertions fail.
Additional information
See the offending Rust program:
#![feature(stdsimd, powerpc_target_feature)]
use std::arch::powerpc::*;
#[target_feature(enable = "altivec")]
unsafe fn add(x: f32, y: f32) -> f32 {
let array: [f32; 4] = unsafe { std::mem::transmute(vec_add(vec_splats(x), vec_splats(y))) };
array[0]
}
pub fn main() {
let result = unsafe { add(-1.0857398e-38, 0.) };
assert_eq!(result, 0.);
// if the input is flushed, the result will be +0
// if only the output is flushed, the result is -0
assert!(result.is_sign_positive());
}