Commit c183ab16 authored by Milad Fa's avatar Milad Fa Committed by Commit Bot

PPC [simd]: fix NaN propagation on vector fp min/mix simulator

Change-Id: Ia60893e627d61cd8ec2663dea47c5463e3606c78
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2787190Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#73695}
parent 6eb8c81f
......@@ -1473,26 +1473,29 @@ void VectorPackSaturate(Simulator* sim, Instruction* instr, S min_val,
template <typename T>
T VSXFPMin(T x, T y) {
// Handle NaN.
// TODO(miladfarca): include the payload of src1.
if (std::isnan(x) && std::isnan(y)) return NAN;
// Handle +0 and -0.
if (std::signbit(x) < std::signbit(y)) return y;
if (std::signbit(y) < std::signbit(x)) return x;
// fmin will handle NaN correctly.
return std::fmin(x, y);
}
template <typename T>
T VSXFPMax(T x, T y) {
// Handle NaN.
// TODO(miladfarca): include the payload of src1.
if (std::isnan(x) && std::isnan(y)) return NAN;
// Handle +0 and -0.
if (std::signbit(x) < std::signbit(y)) return x;
if (std::signbit(y) < std::signbit(x)) return y;
// fmax will handle NaN correctly.
return std::fmax(x, y);
}
float VMXFPMin(float x, float y) {
// Handle NaN.
if (std::isnan(x)) return x;
if (std::isnan(y)) return y;
if (std::isnan(x) || std::isnan(y)) return NAN;
// Handle +0 and -0.
if (std::signbit(x) < std::signbit(y)) return y;
if (std::signbit(y) < std::signbit(x)) return x;
......@@ -1501,8 +1504,7 @@ float VMXFPMin(float x, float y) {
float VMXFPMax(float x, float y) {
// Handle NaN.
if (std::isnan(x)) return x;
if (std::isnan(y)) return y;
if (std::isnan(x) || std::isnan(y)) return NAN;
// Handle +0 and -0.
if (std::signbit(x) < std::signbit(y)) return x;
if (std::signbit(y) < std::signbit(x)) return y;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment