Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: test/cctest/wasm/test-run-wasm.cc

Issue 2252863003: [turbofan] Add Float32(Max|Min) machine operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Type is number now. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/compiler/value-helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm.cc
diff --git a/test/cctest/wasm/test-run-wasm.cc b/test/cctest/wasm/test-run-wasm.cc
index f48e44d4eb5c258f67fd3452510affe2c47eeb79..42ca816655aa96e3cafc4a1d0b081ae386462adc 100644
--- a/test/cctest/wasm/test-run-wasm.cc
+++ b/test/cctest/wasm/test-run-wasm.cc
@@ -7,7 +7,7 @@
#include <string.h>
#include "src/base/platform/elapsed-timer.h"
-
+#include "src/utils.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/cctest/cctest.h"
@@ -2546,21 +2546,7 @@ WASM_EXEC_TEST(F32Min) {
BUILD(r, WASM_F32_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_FLOAT32_INPUTS(i) {
- FOR_FLOAT32_INPUTS(j) {
- float expected;
- if (*i < *j) {
- expected = *i;
- } else if (*j < *i) {
- expected = *j;
- } else if (*i != *i) {
- // If *i or *j is NaN, then the result is NaN.
- expected = *i;
- } else {
- expected = *j;
- }
-
- CHECK_FLOAT_EQ(expected, r.Call(*i, *j));
- }
+ FOR_FLOAT32_INPUTS(j) { CHECK_DOUBLE_EQ(JSMin(*i, *j), r.Call(*i, *j)); }
}
}
@@ -2570,21 +2556,7 @@ WASM_EXEC_TEST(F64Min) {
BUILD(r, WASM_F64_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_FLOAT64_INPUTS(i) {
- FOR_FLOAT64_INPUTS(j) {
- double result = r.Call(*i, *j);
- if (std::isnan(*i) || std::isnan(*j)) {
- // If one of the inputs is nan, the result should be nan.
- CHECK(std::isnan(result));
- } else if ((*i == 0.0) && (*j == 0.0) &&
- (copysign(1.0, *i) != copysign(1.0, *j))) {
- // If one input is +0.0 and the other input is -0.0, the result should
- // be -0.0.
- CHECK_EQ(bit_cast<uint64_t>(-0.0), bit_cast<uint64_t>(result));
- } else {
- double expected = *i < *j ? *i : *j;
- CHECK_DOUBLE_EQ(expected, result);
- }
- }
+ FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(JSMin(*i, *j), r.Call(*i, *j)); }
}
}
@@ -2594,21 +2566,7 @@ WASM_EXEC_TEST(F32Max) {
BUILD(r, WASM_F32_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_FLOAT32_INPUTS(i) {
- FOR_FLOAT32_INPUTS(j) {
- float expected;
- if (*i > *j) {
- expected = *i;
- } else if (*j > *i) {
- expected = *j;
- } else if (*i != *i) {
- // If *i or *j is NaN, then the result is NaN.
- expected = *i;
- } else {
- expected = *j;
- }
-
- CHECK_FLOAT_EQ(expected, r.Call(*i, *j));
- }
+ FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(JSMax(*i, *j), r.Call(*i, *j)); }
}
}
@@ -2620,18 +2578,7 @@ WASM_EXEC_TEST(F64Max) {
FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) {
double result = r.Call(*i, *j);
- if (std::isnan(*i) || std::isnan(*j)) {
- // If one of the inputs is nan, the result should be nan.
- CHECK(std::isnan(result));
- } else if ((*i == 0.0) && (*j == 0.0) &&
- (copysign(1.0, *i) != copysign(1.0, *j))) {
- // If one input is +0.0 and the other input is -0.0, the result should
- // be -0.0.
- CHECK_EQ(bit_cast<uint64_t>(0.0), bit_cast<uint64_t>(result));
- } else {
- double expected = *i > *j ? *i : *j;
- CHECK_DOUBLE_EQ(expected, result);
- }
+ CHECK_DOUBLE_EQ(JSMax(*i, *j), result);
}
}
}
« no previous file with comments | « test/cctest/compiler/value-helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698