OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/wasm/wasm-macro-gen.h" | 5 #include "src/wasm/wasm-macro-gen.h" |
6 | 6 |
7 #include "test/cctest/cctest.h" | 7 #include "test/cctest/cctest.h" |
8 #include "test/cctest/compiler/value-helper.h" | 8 #include "test/cctest/compiler/value-helper.h" |
9 #include "test/cctest/wasm/wasm-run-utils.h" | 9 #include "test/cctest/wasm/wasm-run-utils.h" |
10 | 10 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, | 229 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, |
230 WASM_GET_LOCAL(simd0), | 230 WASM_GET_LOCAL(simd0), |
231 WASM_GET_LOCAL(simd1))), | 231 WASM_GET_LOCAL(simd1))), |
232 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected), | 232 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected), |
233 WASM_RETURN1(WASM_ONE))); | 233 WASM_RETURN1(WASM_ONE))); |
234 | 234 |
235 FOR_FLOAT32_INPUTS(i) { | 235 FOR_FLOAT32_INPUTS(i) { |
236 if (std::isnan(*i)) continue; | 236 if (std::isnan(*i)) continue; |
237 FOR_FLOAT32_INPUTS(j) { | 237 FOR_FLOAT32_INPUTS(j) { |
238 if (std::isnan(*j)) continue; | 238 if (std::isnan(*j)) continue; |
239 CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); | 239 float expected = expected_op(*i, *j); |
| 240 // SIMD on some platforms may handle denormalized numbers differently. |
| 241 // TODO(bbudge) On platforms that flush denorms to zero, test with |
| 242 // expected == 0. |
| 243 if (std::fpclassify(expected) == FP_SUBNORMAL) continue; |
| 244 CHECK_EQ(1, r.Call(*i, *j, expected)); |
240 } | 245 } |
241 } | 246 } |
242 } | 247 } |
243 | 248 |
244 WASM_EXEC_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } | 249 WASM_EXEC_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } |
245 WASM_EXEC_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } | 250 WASM_EXEC_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } |
246 | 251 |
247 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { | 252 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { |
248 FLAG_wasm_simd_prototype = true; | 253 FLAG_wasm_simd_prototype = true; |
249 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); | 254 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); |
250 byte a = 0; | 255 byte a = 0; |
251 byte b = 1; | 256 byte b = 1; |
252 byte expected = 2; | 257 byte expected = 2; |
253 byte simd0 = r.AllocateLocal(kAstS128); | 258 byte simd0 = r.AllocateLocal(kAstS128); |
254 byte simd1 = r.AllocateLocal(kAstS128); | 259 byte simd1 = r.AllocateLocal(kAstS128); |
255 BUILD(r, WASM_BLOCK( | 260 BUILD(r, WASM_BLOCK( |
256 WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 261 WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
257 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), | 262 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), |
258 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, | 263 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op & 0xffu, |
259 WASM_GET_LOCAL(simd0), | 264 WASM_GET_LOCAL(simd0), |
260 WASM_GET_LOCAL(simd1))), | 265 WASM_GET_LOCAL(simd1))), |
261 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), | 266 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), |
262 WASM_RETURN1(WASM_ONE))); | 267 WASM_RETURN1(WASM_ONE))); |
263 | 268 |
264 FOR_FLOAT32_INPUTS(i) { | 269 FOR_FLOAT32_INPUTS(i) { |
265 if (std::isnan(*i)) continue; | 270 if (std::isnan(*i)) continue; |
266 FOR_FLOAT32_INPUTS(j) { | 271 FOR_FLOAT32_INPUTS(j) { |
267 if (std::isnan(*j)) continue; | 272 if (std::isnan(*j)) continue; |
| 273 // SIMD on some platforms may handle denormalized numbers differently. |
| 274 // Check for number pairs that are very close together. |
| 275 if (std::fpclassify(*i - *j) == FP_SUBNORMAL) continue; |
268 CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); | 276 CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); |
269 } | 277 } |
270 } | 278 } |
271 } | 279 } |
272 | 280 |
273 WASM_EXEC_TEST(F32x4Equal) { RunF32x4CompareOpTest(kExprF32x4Eq, Equal); } | 281 WASM_EXEC_TEST(F32x4Equal) { RunF32x4CompareOpTest(kExprF32x4Eq, Equal); } |
274 WASM_EXEC_TEST(F32x4NotEqual) { RunF32x4CompareOpTest(kExprF32x4Ne, NotEqual); } | 282 WASM_EXEC_TEST(F32x4NotEqual) { RunF32x4CompareOpTest(kExprF32x4Ne, NotEqual); } |
275 #endif // V8_TARGET_ARCH_ARM | 283 #endif // V8_TARGET_ARCH_ARM |
276 | 284 |
277 WASM_EXEC_TEST(I32x4Splat) { | 285 WASM_EXEC_TEST(I32x4Splat) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 433 |
426 WASM_EXEC_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); } | 434 WASM_EXEC_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); } |
427 | 435 |
428 WASM_EXEC_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } | 436 WASM_EXEC_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } |
429 | 437 |
430 #if V8_TARGET_ARCH_ARM | 438 #if V8_TARGET_ARCH_ARM |
431 WASM_EXEC_TEST(I32x4Equal) { RunI32x4BinOpTest(kExprI32x4Eq, Equal); } | 439 WASM_EXEC_TEST(I32x4Equal) { RunI32x4BinOpTest(kExprI32x4Eq, Equal); } |
432 | 440 |
433 WASM_EXEC_TEST(I32x4NotEqual) { RunI32x4BinOpTest(kExprI32x4Ne, NotEqual); } | 441 WASM_EXEC_TEST(I32x4NotEqual) { RunI32x4BinOpTest(kExprI32x4Ne, NotEqual); } |
434 #endif // V8_TARGET_ARCH_ARM | 442 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |