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/assembler-inl.h" | 5 #include "src/assembler-inl.h" |
6 #include "src/wasm/wasm-macro-gen.h" | 6 #include "src/wasm/wasm-macro-gen.h" |
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 |
11 using namespace v8::base; | 11 using namespace v8::base; |
12 using namespace v8::internal; | 12 using namespace v8::internal; |
13 using namespace v8::internal::compiler; | 13 using namespace v8::internal::compiler; |
14 using namespace v8::internal::wasm; | 14 using namespace v8::internal::wasm; |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 typedef float (*FloatUnOp)(float); | 18 typedef float (*FloatUnOp)(float); |
19 typedef float (*FloatBinOp)(float, float); | 19 typedef float (*FloatBinOp)(float, float); |
20 typedef int32_t (*FloatCompareOp)(float, float); | 20 typedef int (*FloatCompareOp)(float, float); |
21 typedef int32_t (*Int32UnOp)(int32_t); | 21 typedef int32_t (*Int32UnOp)(int32_t); |
22 typedef int32_t (*Int32BinOp)(int32_t, int32_t); | 22 typedef int32_t (*Int32BinOp)(int32_t, int32_t); |
| 23 typedef int (*Int32CompareOp)(int32_t, int32_t); |
23 typedef int32_t (*Int32ShiftOp)(int32_t, int); | 24 typedef int32_t (*Int32ShiftOp)(int32_t, int); |
24 typedef int16_t (*Int16UnOp)(int16_t); | 25 typedef int16_t (*Int16UnOp)(int16_t); |
25 typedef int16_t (*Int16BinOp)(int16_t, int16_t); | 26 typedef int16_t (*Int16BinOp)(int16_t, int16_t); |
| 27 typedef int (*Int16CompareOp)(int16_t, int16_t); |
26 typedef int16_t (*Int16ShiftOp)(int16_t, int); | 28 typedef int16_t (*Int16ShiftOp)(int16_t, int); |
27 typedef int8_t (*Int8UnOp)(int8_t); | 29 typedef int8_t (*Int8UnOp)(int8_t); |
28 typedef int8_t (*Int8BinOp)(int8_t, int8_t); | 30 typedef int8_t (*Int8BinOp)(int8_t, int8_t); |
| 31 typedef int (*Int8CompareOp)(int8_t, int8_t); |
29 typedef int8_t (*Int8ShiftOp)(int8_t, int); | 32 typedef int8_t (*Int8ShiftOp)(int8_t, int); |
30 | 33 |
31 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64 | 34 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64 |
32 #define SIMD_LOWERING_TARGET 1 | 35 #define SIMD_LOWERING_TARGET 1 |
33 #else | 36 #else |
34 #define SIMD_LOWERING_TARGET 0 | 37 #define SIMD_LOWERING_TARGET 0 |
35 #endif // !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64 | 38 #endif // !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64 |
36 | 39 |
37 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | |
38 int32_t Equal(float a, float b) { return a == b ? 1 : 0; } | |
39 | |
40 int32_t NotEqual(float a, float b) { return a != b ? 1 : 0; } | |
41 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | |
42 | |
43 #if SIMD_LOWERING_TARGET | |
44 int32_t Less(float a, float b) { return a < b ? 1 : 0; } | |
45 | |
46 int32_t LessEqual(float a, float b) { return a <= b ? 1 : 0; } | |
47 | |
48 int32_t Greater(float a, float b) { return a > b ? 1 : 0; } | |
49 | |
50 int32_t GreaterEqual(float a, float b) { return a >= b ? 1 : 0; } | |
51 #endif // SIMD_LOWERING_TARGET | |
52 | |
53 // Generic expected value functions. | 40 // Generic expected value functions. |
54 template <typename T> | 41 template <typename T> |
55 T Negate(T a) { | 42 T Negate(T a) { |
56 return -a; | 43 return -a; |
57 } | 44 } |
58 | 45 |
59 template <typename T> | 46 template <typename T> |
60 T Add(T a, T b) { | 47 T Add(T a, T b) { |
61 return a + b; | 48 return a + b; |
62 } | 49 } |
(...skipping 29 matching lines...) Expand all Loading... |
92 return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? a : b; | 79 return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? a : b; |
93 } | 80 } |
94 | 81 |
95 template <typename T> | 82 template <typename T> |
96 T UnsignedMaximum(T a, T b) { | 83 T UnsignedMaximum(T a, T b) { |
97 using UnsignedT = typename std::make_unsigned<T>::type; | 84 using UnsignedT = typename std::make_unsigned<T>::type; |
98 return static_cast<UnsignedT>(a) >= static_cast<UnsignedT>(b) ? a : b; | 85 return static_cast<UnsignedT>(a) >= static_cast<UnsignedT>(b) ? a : b; |
99 } | 86 } |
100 | 87 |
101 template <typename T> | 88 template <typename T> |
102 T Equal(T a, T b) { | 89 int Equal(T a, T b) { |
103 return a == b ? 1 : 0; | 90 return a == b ? 1 : 0; |
104 } | 91 } |
105 | 92 |
106 template <typename T> | 93 template <typename T> |
107 T NotEqual(T a, T b) { | 94 int NotEqual(T a, T b) { |
108 return a != b ? 1 : 0; | 95 return a != b ? 1 : 0; |
109 } | 96 } |
110 | 97 |
111 template <typename T> | 98 template <typename T> |
112 T Greater(T a, T b) { | 99 int Less(T a, T b) { |
| 100 return a < b ? 1 : 0; |
| 101 } |
| 102 |
| 103 template <typename T> |
| 104 int LessEqual(T a, T b) { |
| 105 return a <= b ? 1 : 0; |
| 106 } |
| 107 |
| 108 template <typename T> |
| 109 int Greater(T a, T b) { |
113 return a > b ? 1 : 0; | 110 return a > b ? 1 : 0; |
114 } | 111 } |
115 | 112 |
116 template <typename T> | 113 template <typename T> |
117 T GreaterEqual(T a, T b) { | 114 int GreaterEqual(T a, T b) { |
118 return a >= b ? 1 : 0; | 115 return a >= b ? 1 : 0; |
119 } | 116 } |
120 | 117 |
121 template <typename T> | 118 template <typename T> |
122 T Less(T a, T b) { | 119 int UnsignedLess(T a, T b) { |
123 return a < b ? 1 : 0; | 120 using UnsignedT = typename std::make_unsigned<T>::type; |
| 121 return static_cast<UnsignedT>(a) < static_cast<UnsignedT>(b) ? 1 : 0; |
124 } | 122 } |
125 | 123 |
126 template <typename T> | 124 template <typename T> |
127 T LessEqual(T a, T b) { | 125 int UnsignedLessEqual(T a, T b) { |
128 return a <= b ? 1 : 0; | 126 using UnsignedT = typename std::make_unsigned<T>::type; |
| 127 return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? 1 : 0; |
129 } | 128 } |
130 | 129 |
131 template <typename T> | 130 template <typename T> |
132 T UnsignedGreater(T a, T b) { | 131 int UnsignedGreater(T a, T b) { |
133 using UnsignedT = typename std::make_unsigned<T>::type; | 132 using UnsignedT = typename std::make_unsigned<T>::type; |
134 return static_cast<UnsignedT>(a) > static_cast<UnsignedT>(b) ? 1 : 0; | 133 return static_cast<UnsignedT>(a) > static_cast<UnsignedT>(b) ? 1 : 0; |
135 } | 134 } |
136 | 135 |
137 template <typename T> | 136 template <typename T> |
138 T UnsignedGreaterEqual(T a, T b) { | 137 int UnsignedGreaterEqual(T a, T b) { |
139 using UnsignedT = typename std::make_unsigned<T>::type; | 138 using UnsignedT = typename std::make_unsigned<T>::type; |
140 return static_cast<UnsignedT>(a) >= static_cast<UnsignedT>(b) ? 1 : 0; | 139 return static_cast<UnsignedT>(a) >= static_cast<UnsignedT>(b) ? 1 : 0; |
141 } | 140 } |
142 | 141 |
143 template <typename T> | 142 template <typename T> |
144 T UnsignedLess(T a, T b) { | |
145 using UnsignedT = typename std::make_unsigned<T>::type; | |
146 return static_cast<UnsignedT>(a) < static_cast<UnsignedT>(b) ? 1 : 0; | |
147 } | |
148 | |
149 template <typename T> | |
150 T UnsignedLessEqual(T a, T b) { | |
151 using UnsignedT = typename std::make_unsigned<T>::type; | |
152 return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? 1 : 0; | |
153 } | |
154 | |
155 template <typename T> | |
156 T LogicalShiftLeft(T a, int shift) { | 143 T LogicalShiftLeft(T a, int shift) { |
157 return a << shift; | 144 return a << shift; |
158 } | 145 } |
159 | 146 |
160 template <typename T> | 147 template <typename T> |
161 T LogicalShiftRight(T a, int shift) { | 148 T LogicalShiftRight(T a, int shift) { |
162 using UnsignedT = typename std::make_unsigned<T>::type; | 149 using UnsignedT = typename std::make_unsigned<T>::type; |
163 return static_cast<UnsignedT>(a) >> shift; | 150 return static_cast<UnsignedT>(a) >> shift; |
164 } | 151 } |
165 | 152 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 template <typename T> | 217 template <typename T> |
231 T LogicalNot(T a) { | 218 T LogicalNot(T a) { |
232 return a == 0 ? 1 : 0; | 219 return a == 0 ? 1 : 0; |
233 } | 220 } |
234 | 221 |
235 template <typename T> | 222 template <typename T> |
236 T Sqrt(T a) { | 223 T Sqrt(T a) { |
237 return std::sqrt(a); | 224 return std::sqrt(a); |
238 } | 225 } |
239 | 226 |
| 227 template <typename T> |
| 228 T Recip(T a) { |
| 229 return 1.0f / a; |
| 230 } |
| 231 |
| 232 template <typename T> |
| 233 T RecipSqrt(T a) { |
| 234 return 1.0f / std::sqrt(a); |
| 235 } |
| 236 |
| 237 template <typename T> |
| 238 T RecipRefine(T a, T b) { |
| 239 return 2.0f - a * b; |
| 240 } |
| 241 |
| 242 template <typename T> |
| 243 T RecipSqrtRefine(T a, T b) { |
| 244 return (3.0f - a * b) * 0.5f; |
| 245 } |
| 246 |
240 } // namespace | 247 } // namespace |
241 | 248 |
242 #define WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lane_value, lane_index) \ | 249 #define WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lane_value, lane_index) \ |
243 WASM_IF(WASM_##LANE_TYPE##_NE(WASM_GET_LOCAL(lane_value), \ | 250 WASM_IF(WASM_##LANE_TYPE##_NE(WASM_GET_LOCAL(lane_value), \ |
244 WASM_SIMD_##TYPE##_EXTRACT_LANE( \ | 251 WASM_SIMD_##TYPE##_EXTRACT_LANE( \ |
245 lane_index, WASM_GET_LOCAL(value))), \ | 252 lane_index, WASM_GET_LOCAL(value))), \ |
246 WASM_RETURN1(WASM_ZERO)) | 253 WASM_RETURN1(WASM_ZERO)) |
247 | 254 |
248 #define WASM_SIMD_CHECK_F32_LANE(value, lane_value, lane_index) \ | |
249 WASM_IF(WASM_F32_NE(WASM_GET_LOCAL(lane_value), \ | |
250 WASM_SIMD_F32x4_EXTRACT_LANE(lane_index, \ | |
251 WASM_GET_LOCAL(value))), \ | |
252 WASM_RETURN1(WASM_ZERO)) | |
253 | |
254 #define WASM_SIMD_CHECK4(TYPE, value, LANE_TYPE, lv0, lv1, lv2, lv3) \ | 255 #define WASM_SIMD_CHECK4(TYPE, value, LANE_TYPE, lv0, lv1, lv2, lv3) \ |
255 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv0, 0) \ | 256 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv0, 0) \ |
256 , WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv1, 1), \ | 257 , WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv1, 1), \ |
257 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv2, 2), \ | 258 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv2, 2), \ |
258 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv3, 3) | 259 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv3, 3) |
259 | 260 |
260 #define WASM_SIMD_CHECK_SPLAT4(TYPE, value, LANE_TYPE, lv) \ | 261 #define WASM_SIMD_CHECK_SPLAT4(TYPE, value, LANE_TYPE, lv) \ |
261 WASM_SIMD_CHECK4(TYPE, value, LANE_TYPE, lv, lv, lv, lv) | 262 WASM_SIMD_CHECK4(TYPE, value, LANE_TYPE, lv, lv, lv, lv) |
262 | 263 |
263 #define WASM_SIMD_CHECK8(TYPE, value, LANE_TYPE, lv0, lv1, lv2, lv3, lv4, lv5, \ | 264 #define WASM_SIMD_CHECK8(TYPE, value, LANE_TYPE, lv0, lv1, lv2, lv3, lv4, lv5, \ |
(...skipping 27 matching lines...) Expand all Loading... |
291 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv11, 11), \ | 292 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv11, 11), \ |
292 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv12, 12), \ | 293 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv12, 12), \ |
293 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv13, 13), \ | 294 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv13, 13), \ |
294 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv14, 14), \ | 295 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv14, 14), \ |
295 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv15, 15) | 296 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv15, 15) |
296 | 297 |
297 #define WASM_SIMD_CHECK_SPLAT16(TYPE, value, LANE_TYPE, lv) \ | 298 #define WASM_SIMD_CHECK_SPLAT16(TYPE, value, LANE_TYPE, lv) \ |
298 WASM_SIMD_CHECK16(TYPE, value, LANE_TYPE, lv, lv, lv, lv, lv, lv, lv, lv, \ | 299 WASM_SIMD_CHECK16(TYPE, value, LANE_TYPE, lv, lv, lv, lv, lv, lv, lv, lv, \ |
299 lv, lv, lv, lv, lv, lv, lv, lv) | 300 lv, lv, lv, lv, lv, lv, lv, lv) |
300 | 301 |
| 302 #define WASM_SIMD_CHECK_F32_LANE(value, lane_value, lane_index) \ |
| 303 WASM_IF(WASM_F32_NE(WASM_GET_LOCAL(lane_value), \ |
| 304 WASM_SIMD_F32x4_EXTRACT_LANE(lane_index, \ |
| 305 WASM_GET_LOCAL(value))), \ |
| 306 WASM_RETURN1(WASM_ZERO)) |
| 307 |
301 #define WASM_SIMD_CHECK_F32x4(value, lv0, lv1, lv2, lv3) \ | 308 #define WASM_SIMD_CHECK_F32x4(value, lv0, lv1, lv2, lv3) \ |
302 WASM_SIMD_CHECK_F32_LANE(value, lv0, 0) \ | 309 WASM_SIMD_CHECK_F32_LANE(value, lv0, 0) \ |
303 , WASM_SIMD_CHECK_F32_LANE(value, lv1, 1), \ | 310 , WASM_SIMD_CHECK_F32_LANE(value, lv1, 1), \ |
304 WASM_SIMD_CHECK_F32_LANE(value, lv2, 2), \ | 311 WASM_SIMD_CHECK_F32_LANE(value, lv2, 2), \ |
305 WASM_SIMD_CHECK_F32_LANE(value, lv3, 3) | 312 WASM_SIMD_CHECK_F32_LANE(value, lv3, 3) |
306 | 313 |
307 #define WASM_SIMD_CHECK_SPLAT_F32x4(value, lv) \ | 314 #define WASM_SIMD_CHECK_SPLAT_F32x4(value, lv) \ |
308 WASM_SIMD_CHECK_F32x4(value, lv, lv, lv, lv) | 315 WASM_SIMD_CHECK_F32x4(value, lv, lv, lv, lv) |
309 | 316 |
| 317 #define WASM_SIMD_CHECK_F32_LANE_ESTIMATE(value, low, high, lane_index) \ |
| 318 WASM_IF(WASM_F32_GT(WASM_GET_LOCAL(low), \ |
| 319 WASM_SIMD_F32x4_EXTRACT_LANE(lane_index, \ |
| 320 WASM_GET_LOCAL(value))), \ |
| 321 WASM_RETURN1(WASM_ZERO)) \ |
| 322 , WASM_IF(WASM_F32_LT(WASM_GET_LOCAL(high), \ |
| 323 WASM_SIMD_F32x4_EXTRACT_LANE(lane_index, \ |
| 324 WASM_GET_LOCAL(value))), \ |
| 325 WASM_RETURN1(WASM_ZERO)) |
| 326 |
| 327 #define WASM_SIMD_CHECK_SPLAT_F32x4_ESTIMATE(value, low, high) \ |
| 328 WASM_SIMD_CHECK_F32_LANE_ESTIMATE(value, low, high, 0) \ |
| 329 , WASM_SIMD_CHECK_F32_LANE_ESTIMATE(value, low, high, 1), \ |
| 330 WASM_SIMD_CHECK_F32_LANE_ESTIMATE(value, low, high, 2), \ |
| 331 WASM_SIMD_CHECK_F32_LANE_ESTIMATE(value, low, high, 3) |
| 332 |
310 #define TO_BYTE(val) static_cast<byte>(val) | 333 #define TO_BYTE(val) static_cast<byte>(val) |
311 #define WASM_SIMD_OP(op) kSimdPrefix, TO_BYTE(op) | 334 #define WASM_SIMD_OP(op) kSimdPrefix, TO_BYTE(op) |
312 #define WASM_SIMD_SPLAT(Type, x) x, WASM_SIMD_OP(kExpr##Type##Splat) | 335 #define WASM_SIMD_SPLAT(Type, x) x, WASM_SIMD_OP(kExpr##Type##Splat) |
313 #define WASM_SIMD_UNOP(op, x) x, WASM_SIMD_OP(op) | 336 #define WASM_SIMD_UNOP(op, x) x, WASM_SIMD_OP(op) |
314 #define WASM_SIMD_BINOP(op, x, y) x, y, WASM_SIMD_OP(op) | 337 #define WASM_SIMD_BINOP(op, x, y) x, y, WASM_SIMD_OP(op) |
315 #define WASM_SIMD_SHIFT_OP(op, shift, x) x, WASM_SIMD_OP(op), TO_BYTE(shift) | 338 #define WASM_SIMD_SHIFT_OP(op, shift, x) x, WASM_SIMD_OP(op), TO_BYTE(shift) |
316 #define WASM_SIMD_SELECT(format, x, y, z) \ | 339 #define WASM_SIMD_SELECT(format, x, y, z) \ |
317 x, y, z, WASM_SIMD_OP(kExprS##format##Select) | 340 x, y, z, WASM_SIMD_OP(kExprS##format##Select) |
318 // Since boolean vectors can't be checked directly, materialize them into | 341 // Since boolean vectors can't be checked directly, materialize them into |
319 // integer vectors using a Select operation. | 342 // integer vectors using a Select operation. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 WASM_SET_LOCAL(simd2, WASM_SIMD_F32x4_FROM_U32x4(WASM_GET_LOCAL(simd0))), | 450 WASM_SET_LOCAL(simd2, WASM_SIMD_F32x4_FROM_U32x4(WASM_GET_LOCAL(simd0))), |
428 WASM_SIMD_CHECK_SPLAT_F32x4(simd2, expected_unsigned), | 451 WASM_SIMD_CHECK_SPLAT_F32x4(simd2, expected_unsigned), |
429 WASM_RETURN1(WASM_ONE)); | 452 WASM_RETURN1(WASM_ONE)); |
430 | 453 |
431 FOR_INT32_INPUTS(i) { | 454 FOR_INT32_INPUTS(i) { |
432 CHECK_EQ(1, r.Call(*i, static_cast<float>(*i), | 455 CHECK_EQ(1, r.Call(*i, static_cast<float>(*i), |
433 static_cast<float>(static_cast<uint32_t>(*i)))); | 456 static_cast<float>(static_cast<uint32_t>(*i)))); |
434 } | 457 } |
435 } | 458 } |
436 | 459 |
437 void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op) { | 460 void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op, |
| 461 float error = 0.0f) { |
438 FLAG_wasm_simd_prototype = true; | 462 FLAG_wasm_simd_prototype = true; |
439 WasmRunner<int32_t, float, float> r(kExecuteCompiled); | 463 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); |
440 byte a = 0; | 464 byte a = 0; |
441 byte expected = 1; | 465 byte low = 1; |
| 466 byte high = 2; |
442 byte simd = r.AllocateLocal(kWasmS128); | 467 byte simd = r.AllocateLocal(kWasmS128); |
443 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 468 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
444 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 469 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
445 WASM_SIMD_CHECK_SPLAT_F32x4(simd, expected), WASM_RETURN1(WASM_ONE)); | 470 WASM_SIMD_CHECK_SPLAT_F32x4_ESTIMATE(simd, low, high), |
| 471 WASM_RETURN1(WASM_ONE)); |
446 | 472 |
447 FOR_FLOAT32_INPUTS(i) { | 473 FOR_FLOAT32_INPUTS(i) { |
448 if (SkipFPTestInput(*i)) continue; | 474 if (SkipFPTestInput(*i)) continue; |
449 float expected = expected_op(*i); | 475 float expected = expected_op(*i); |
450 if (SkipFPTestResult(expected)) continue; | 476 if (SkipFPTestResult(expected)) continue; |
451 CHECK_EQ(1, r.Call(*i, expected)); | 477 float abs_error = std::abs(expected) * error; |
| 478 CHECK_EQ(1, r.Call(*i, expected - abs_error, expected + abs_error)); |
452 } | 479 } |
453 } | 480 } |
454 | 481 |
455 WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } | 482 WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } |
456 WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } | 483 WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } |
457 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 484 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
458 | 485 |
459 #if SIMD_LOWERING_TARGET | 486 #if SIMD_LOWERING_TARGET |
460 WASM_EXEC_COMPILED_TEST(F32x4Sqrt) { RunF32x4UnOpTest(kExprF32x4Sqrt, Sqrt); } | 487 WASM_EXEC_COMPILED_TEST(F32x4Sqrt) { RunF32x4UnOpTest(kExprF32x4Sqrt, Sqrt); } |
461 #endif // SIMD_LOWERING_TARGET | 488 #endif // SIMD_LOWERING_TARGET |
462 | 489 |
| 490 #if V8_TARGET_ARCH_ARM |
| 491 static const float kApproxError = 0.01f; |
| 492 |
| 493 WASM_EXEC_COMPILED_TEST(F32x4RecipApprox) { |
| 494 RunF32x4UnOpTest(kExprF32x4RecipApprox, Recip, kApproxError); |
| 495 } |
| 496 |
| 497 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtApprox) { |
| 498 RunF32x4UnOpTest(kExprF32x4RecipSqrtApprox, RecipSqrt, kApproxError); |
| 499 } |
| 500 #endif // V8_TARGET_ARCH_ARM |
| 501 |
463 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 502 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
464 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { | 503 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { |
465 FLAG_wasm_simd_prototype = true; | 504 FLAG_wasm_simd_prototype = true; |
466 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); | 505 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); |
467 byte a = 0; | 506 byte a = 0; |
468 byte b = 1; | 507 byte b = 1; |
469 byte expected = 2; | 508 byte expected = 2; |
470 byte simd0 = r.AllocateLocal(kWasmS128); | 509 byte simd0 = r.AllocateLocal(kWasmS128); |
471 byte simd1 = r.AllocateLocal(kWasmS128); | 510 byte simd1 = r.AllocateLocal(kWasmS128); |
472 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 511 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
473 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), | 512 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), |
474 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), | 513 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), |
475 WASM_GET_LOCAL(simd1))), | 514 WASM_GET_LOCAL(simd1))), |
476 WASM_SIMD_CHECK_SPLAT_F32x4(simd1, expected), WASM_RETURN1(WASM_ONE)); | 515 WASM_SIMD_CHECK_SPLAT_F32x4(simd1, expected), WASM_RETURN1(WASM_ONE)); |
477 | 516 |
478 FOR_FLOAT32_INPUTS(i) { | 517 FOR_FLOAT32_INPUTS(i) { |
479 if (SkipFPTestInput(*i)) continue; | 518 if (SkipFPTestInput(*i)) continue; |
480 FOR_FLOAT32_INPUTS(j) { | 519 FOR_FLOAT32_INPUTS(j) { |
481 if (SkipFPTestInput(*j)) continue; | 520 if (SkipFPTestInput(*j)) continue; |
482 float expected = expected_op(*i, *j); | 521 float expected = expected_op(*i, *j); |
483 if (SkipFPTestResult(expected)) continue; | 522 if (SkipFPTestResult(expected)) continue; |
484 CHECK_EQ(1, r.Call(*i, *j, expected)); | 523 CHECK_EQ(1, r.Call(*i, *j, expected)); |
485 } | 524 } |
486 } | 525 } |
487 } | 526 } |
488 | 527 |
489 WASM_EXEC_COMPILED_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } | 528 WASM_EXEC_COMPILED_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } |
490 WASM_EXEC_COMPILED_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } | 529 WASM_EXEC_COMPILED_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } |
| 530 WASM_EXEC_COMPILED_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } |
| 531 WASM_EXEC_COMPILED_TEST(F32x4_Min) { |
| 532 RunF32x4BinOpTest(kExprF32x4Min, Minimum); |
| 533 } |
| 534 WASM_EXEC_COMPILED_TEST(F32x4_Max) { |
| 535 RunF32x4BinOpTest(kExprF32x4Max, Maximum); |
| 536 } |
491 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 537 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
492 | 538 |
493 #if SIMD_LOWERING_TARGET | 539 #if SIMD_LOWERING_TARGET |
494 WASM_EXEC_COMPILED_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Mul, Mul); } | |
495 WASM_EXEC_COMPILED_TEST(F32x4Div) { RunF32x4BinOpTest(kExprF32x4Div, Div); } | 540 WASM_EXEC_COMPILED_TEST(F32x4Div) { RunF32x4BinOpTest(kExprF32x4Div, Div); } |
496 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Min) { | 541 #endif // SIMD_LOWERING_TARGET |
497 RunF32x4BinOpTest(kExprF32x4Min, Minimum); | 542 |
| 543 #if V8_TARGET_ARCH_ARM |
| 544 WASM_EXEC_COMPILED_TEST(F32x4RecipRefine) { |
| 545 RunF32x4BinOpTest(kExprF32x4RecipRefine, RecipRefine); |
498 } | 546 } |
499 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Max) { | 547 |
500 RunF32x4BinOpTest(kExprF32x4Max, Maximum); | 548 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtRefine) { |
| 549 RunF32x4BinOpTest(kExprF32x4RecipSqrtRefine, RecipSqrtRefine); |
501 } | 550 } |
502 #endif // SIMD_LOWERING_TARGET | 551 #endif // V8_TARGET_ARCH_ARM |
503 | 552 |
504 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 553 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
505 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { | 554 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { |
506 FLAG_wasm_simd_prototype = true; | 555 FLAG_wasm_simd_prototype = true; |
507 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); | 556 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); |
508 byte a = 0; | 557 byte a = 0; |
509 byte b = 1; | 558 byte b = 1; |
510 byte expected = 2; | 559 byte expected = 2; |
511 byte simd0 = r.AllocateLocal(kWasmS128); | 560 byte simd0 = r.AllocateLocal(kWasmS128); |
512 byte simd1 = r.AllocateLocal(kWasmS128); | 561 byte simd1 = r.AllocateLocal(kWasmS128); |
513 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 562 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
514 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), | 563 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), |
515 WASM_SET_LOCAL(simd1, | 564 WASM_SET_LOCAL(simd1, |
516 WASM_SIMD_MATERIALIZE_BOOLS( | 565 WASM_SIMD_MATERIALIZE_BOOLS( |
517 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), | 566 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), |
518 WASM_GET_LOCAL(simd1)))), | 567 WASM_GET_LOCAL(simd1)))), |
519 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); | 568 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); |
520 | 569 |
521 FOR_FLOAT32_INPUTS(i) { | 570 FOR_FLOAT32_INPUTS(i) { |
522 if (SkipFPTestInput(*i)) continue; | 571 if (SkipFPTestInput(*i)) continue; |
523 FOR_FLOAT32_INPUTS(j) { | 572 FOR_FLOAT32_INPUTS(j) { |
524 if (SkipFPTestInput(*j)) continue; | 573 if (SkipFPTestInput(*j)) continue; |
525 float diff = *i - *j; | 574 float diff = *i - *j; |
526 if (SkipFPTestResult(diff)) continue; | 575 if (SkipFPTestResult(diff)) continue; |
527 CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); | 576 CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); |
528 } | 577 } |
529 } | 578 } |
530 } | 579 } |
531 | 580 |
532 WASM_EXEC_COMPILED_TEST(F32x4Equal) { | 581 WASM_EXEC_COMPILED_TEST(F32x4Eq) { RunF32x4CompareOpTest(kExprF32x4Eq, Equal); } |
533 RunF32x4CompareOpTest(kExprF32x4Eq, Equal); | 582 |
| 583 WASM_EXEC_COMPILED_TEST(F32x4Ne) { |
| 584 RunF32x4CompareOpTest(kExprF32x4Ne, NotEqual); |
534 } | 585 } |
535 | 586 |
536 WASM_EXEC_COMPILED_TEST(F32x4NotEqual) { | 587 WASM_EXEC_COMPILED_TEST(F32x4Gt) { |
537 RunF32x4CompareOpTest(kExprF32x4Ne, NotEqual); | 588 RunF32x4CompareOpTest(kExprF32x4Gt, Greater); |
| 589 } |
| 590 |
| 591 WASM_EXEC_COMPILED_TEST(F32x4Ge) { |
| 592 RunF32x4CompareOpTest(kExprF32x4Ge, GreaterEqual); |
| 593 } |
| 594 |
| 595 WASM_EXEC_COMPILED_TEST(F32x4Lt) { RunF32x4CompareOpTest(kExprF32x4Lt, Less); } |
| 596 |
| 597 WASM_EXEC_COMPILED_TEST(F32x4Le) { |
| 598 RunF32x4CompareOpTest(kExprF32x4Le, LessEqual); |
538 } | 599 } |
539 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 600 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
540 | 601 |
541 #if SIMD_LOWERING_TARGET | |
542 WASM_EXEC_COMPILED_TEST(F32x4LessThan) { | |
543 RunF32x4CompareOpTest(kExprF32x4Lt, Less); | |
544 } | |
545 WASM_EXEC_COMPILED_TEST(F32x4LessThanOrEqual) { | |
546 RunF32x4CompareOpTest(kExprF32x4Le, LessEqual); | |
547 } | |
548 WASM_EXEC_COMPILED_TEST(F32x4GreaterThan) { | |
549 RunF32x4CompareOpTest(kExprF32x4Gt, Greater); | |
550 } | |
551 WASM_EXEC_COMPILED_TEST(F32x4GreaterThanOrEqual) { | |
552 RunF32x4CompareOpTest(kExprF32x4Ge, GreaterEqual); | |
553 } | |
554 #endif // SIMD_LOWERING_TARGET | |
555 | |
556 WASM_EXEC_COMPILED_TEST(I32x4Splat) { | 602 WASM_EXEC_COMPILED_TEST(I32x4Splat) { |
557 FLAG_wasm_simd_prototype = true; | 603 FLAG_wasm_simd_prototype = true; |
558 | 604 |
559 // Store SIMD value in a local variable, use extract lane to check lane values | 605 // Store SIMD value in a local variable, use extract lane to check lane values |
560 // This test is not a test for ExtractLane as Splat does not create | 606 // This test is not a test for ExtractLane as Splat does not create |
561 // interesting SIMD values. | 607 // interesting SIMD values. |
562 // | 608 // |
563 // SetLocal(1, I32x4Splat(Local(0))); | 609 // SetLocal(1, I32x4Splat(Local(0))); |
564 // For each lane index | 610 // For each lane index |
565 // if(Local(0) != I32x4ExtractLane(Local(1), index) | 611 // if(Local(0) != I32x4ExtractLane(Local(1), index) |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); } | 946 WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); } |
901 | 947 |
902 WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } | 948 WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } |
903 | 949 |
904 WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); } | 950 WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); } |
905 | 951 |
906 WASM_EXEC_COMPILED_TEST(I32x4Min) { | 952 WASM_EXEC_COMPILED_TEST(I32x4Min) { |
907 RunI32x4BinOpTest(kExprI32x4MinS, Minimum); | 953 RunI32x4BinOpTest(kExprI32x4MinS, Minimum); |
908 } | 954 } |
909 | 955 |
910 WASM_EXEC_COMPILED_TEST(I32x4Max) { | 956 WASM_EXEC_COMPILED_TEST(I32x4MaxS) { |
911 RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); | 957 RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); |
912 } | 958 } |
913 | 959 |
914 WASM_EXEC_COMPILED_TEST(Ui32x4Min) { | 960 WASM_EXEC_COMPILED_TEST(I32x4MinU) { |
915 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); | 961 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); |
916 } | 962 } |
917 | 963 |
918 WASM_EXEC_COMPILED_TEST(Ui32x4Max) { | 964 WASM_EXEC_COMPILED_TEST(I32x4MaxU) { |
919 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); | 965 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); |
920 } | 966 } |
921 | 967 |
922 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { | 968 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32CompareOp expected_op) { |
923 FLAG_wasm_simd_prototype = true; | 969 FLAG_wasm_simd_prototype = true; |
924 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 970 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
925 byte a = 0; | 971 byte a = 0; |
926 byte b = 1; | 972 byte b = 1; |
927 byte expected = 2; | 973 byte expected = 2; |
928 byte simd0 = r.AllocateLocal(kWasmS128); | 974 byte simd0 = r.AllocateLocal(kWasmS128); |
929 byte simd1 = r.AllocateLocal(kWasmS128); | 975 byte simd1 = r.AllocateLocal(kWasmS128); |
930 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 976 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
931 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), | 977 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), |
932 WASM_SET_LOCAL(simd1, | 978 WASM_SET_LOCAL(simd1, |
933 WASM_SIMD_MATERIALIZE_BOOLS( | 979 WASM_SIMD_MATERIALIZE_BOOLS( |
934 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), | 980 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), |
935 WASM_GET_LOCAL(simd1)))), | 981 WASM_GET_LOCAL(simd1)))), |
936 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); | 982 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); |
937 | 983 |
938 FOR_INT32_INPUTS(i) { | 984 FOR_INT32_INPUTS(i) { |
939 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } | 985 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } |
940 } | 986 } |
941 } | 987 } |
942 | 988 |
943 WASM_EXEC_COMPILED_TEST(I32x4Equal) { | 989 WASM_EXEC_COMPILED_TEST(I32x4Eq) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); } |
944 RunI32x4CompareOpTest(kExprI32x4Eq, Equal); | |
945 } | |
946 | 990 |
947 WASM_EXEC_COMPILED_TEST(I32x4NotEqual) { | 991 WASM_EXEC_COMPILED_TEST(I32x4Ne) { |
948 RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); | 992 RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); |
949 } | 993 } |
950 | 994 |
951 WASM_EXEC_COMPILED_TEST(I32x4Greater) { | 995 WASM_EXEC_COMPILED_TEST(I32x4LtS) { |
| 996 RunI32x4CompareOpTest(kExprI32x4LtS, Less); |
| 997 } |
| 998 |
| 999 WASM_EXEC_COMPILED_TEST(I32x4LeS) { |
| 1000 RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual); |
| 1001 } |
| 1002 |
| 1003 WASM_EXEC_COMPILED_TEST(I32x4GtS) { |
952 RunI32x4CompareOpTest(kExprI32x4GtS, Greater); | 1004 RunI32x4CompareOpTest(kExprI32x4GtS, Greater); |
953 } | 1005 } |
954 | 1006 |
955 WASM_EXEC_COMPILED_TEST(I32x4GreaterEqual) { | 1007 WASM_EXEC_COMPILED_TEST(I32x4GeS) { |
956 RunI32x4CompareOpTest(kExprI32x4GeS, GreaterEqual); | 1008 RunI32x4CompareOpTest(kExprI32x4GeS, GreaterEqual); |
957 } | 1009 } |
958 | 1010 |
959 WASM_EXEC_COMPILED_TEST(I32x4Less) { | 1011 WASM_EXEC_COMPILED_TEST(I32x4LtU) { |
960 RunI32x4CompareOpTest(kExprI32x4LtS, Less); | 1012 RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess); |
961 } | 1013 } |
962 | 1014 |
963 WASM_EXEC_COMPILED_TEST(I32x4LessEqual) { | 1015 WASM_EXEC_COMPILED_TEST(I32x4LeU) { |
964 RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual); | 1016 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); |
965 } | 1017 } |
966 | 1018 |
967 WASM_EXEC_COMPILED_TEST(Ui32x4Greater) { | 1019 WASM_EXEC_COMPILED_TEST(I32x4GtU) { |
968 RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater); | 1020 RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater); |
969 } | 1021 } |
970 | 1022 |
971 WASM_EXEC_COMPILED_TEST(Ui32x4GreaterEqual) { | 1023 WASM_EXEC_COMPILED_TEST(I32x4GeU) { |
972 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); | 1024 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); |
973 } | 1025 } |
974 | 1026 |
975 WASM_EXEC_COMPILED_TEST(Ui32x4Less) { | |
976 RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess); | |
977 } | |
978 | |
979 WASM_EXEC_COMPILED_TEST(Ui32x4LessEqual) { | |
980 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); | |
981 } | |
982 | |
983 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, | 1027 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, |
984 int shift) { | 1028 int shift) { |
985 FLAG_wasm_simd_prototype = true; | 1029 FLAG_wasm_simd_prototype = true; |
986 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1030 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
987 byte a = 0; | 1031 byte a = 0; |
988 byte expected = 1; | 1032 byte expected = 1; |
989 byte simd = r.AllocateLocal(kWasmS128); | 1033 byte simd = r.AllocateLocal(kWasmS128); |
990 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 1034 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
991 WASM_SET_LOCAL( | 1035 WASM_SET_LOCAL( |
992 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), | 1036 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 WASM_GET_LOCAL(simd1))), | 1083 WASM_GET_LOCAL(simd1))), |
1040 WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); | 1084 WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); |
1041 | 1085 |
1042 FOR_INT16_INPUTS(i) { | 1086 FOR_INT16_INPUTS(i) { |
1043 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } | 1087 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } |
1044 } | 1088 } |
1045 } | 1089 } |
1046 | 1090 |
1047 WASM_EXEC_COMPILED_TEST(I16x8Add) { RunI16x8BinOpTest(kExprI16x8Add, Add); } | 1091 WASM_EXEC_COMPILED_TEST(I16x8Add) { RunI16x8BinOpTest(kExprI16x8Add, Add); } |
1048 | 1092 |
1049 WASM_EXEC_COMPILED_TEST(I16x8AddSaturate) { | 1093 WASM_EXEC_COMPILED_TEST(I16x8AddSaturateS) { |
1050 RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate); | 1094 RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate); |
1051 } | 1095 } |
1052 | 1096 |
1053 WASM_EXEC_COMPILED_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); } | 1097 WASM_EXEC_COMPILED_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); } |
1054 | 1098 |
1055 WASM_EXEC_COMPILED_TEST(I16x8SubSaturate) { | 1099 WASM_EXEC_COMPILED_TEST(I16x8SubSaturateS) { |
1056 RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate); | 1100 RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate); |
1057 } | 1101 } |
1058 | 1102 |
1059 WASM_EXEC_COMPILED_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); } | 1103 WASM_EXEC_COMPILED_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); } |
1060 | 1104 |
1061 WASM_EXEC_COMPILED_TEST(I16x8Min) { | 1105 WASM_EXEC_COMPILED_TEST(I16x8MinS) { |
1062 RunI16x8BinOpTest(kExprI16x8MinS, Minimum); | 1106 RunI16x8BinOpTest(kExprI16x8MinS, Minimum); |
1063 } | 1107 } |
1064 | 1108 |
1065 WASM_EXEC_COMPILED_TEST(I16x8Max) { | 1109 WASM_EXEC_COMPILED_TEST(I16x8MaxS) { |
1066 RunI16x8BinOpTest(kExprI16x8MaxS, Maximum); | 1110 RunI16x8BinOpTest(kExprI16x8MaxS, Maximum); |
1067 } | 1111 } |
1068 | 1112 |
1069 WASM_EXEC_COMPILED_TEST(Ui16x8AddSaturate) { | 1113 WASM_EXEC_COMPILED_TEST(I16x8AddSaturateU) { |
1070 RunI16x8BinOpTest(kExprI16x8AddSaturateU, UnsignedAddSaturate); | 1114 RunI16x8BinOpTest(kExprI16x8AddSaturateU, UnsignedAddSaturate); |
1071 } | 1115 } |
1072 | 1116 |
1073 WASM_EXEC_COMPILED_TEST(Ui16x8SubSaturate) { | 1117 WASM_EXEC_COMPILED_TEST(I16x8SubSaturateU) { |
1074 RunI16x8BinOpTest(kExprI16x8SubSaturateU, UnsignedSubSaturate); | 1118 RunI16x8BinOpTest(kExprI16x8SubSaturateU, UnsignedSubSaturate); |
1075 } | 1119 } |
1076 | 1120 |
1077 WASM_EXEC_COMPILED_TEST(Ui16x8Min) { | 1121 WASM_EXEC_COMPILED_TEST(I16x8MinU) { |
1078 RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum); | 1122 RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum); |
1079 } | 1123 } |
1080 | 1124 |
1081 WASM_EXEC_COMPILED_TEST(Ui16x8Max) { | 1125 WASM_EXEC_COMPILED_TEST(I16x8MaxU) { |
1082 RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum); | 1126 RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum); |
1083 } | 1127 } |
1084 | 1128 |
1085 void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { | 1129 void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16CompareOp expected_op) { |
1086 FLAG_wasm_simd_prototype = true; | 1130 FLAG_wasm_simd_prototype = true; |
1087 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1131 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1088 byte a = 0; | 1132 byte a = 0; |
1089 byte b = 1; | 1133 byte b = 1; |
1090 byte expected = 2; | 1134 byte expected = 2; |
1091 byte simd0 = r.AllocateLocal(kWasmS128); | 1135 byte simd0 = r.AllocateLocal(kWasmS128); |
1092 byte simd1 = r.AllocateLocal(kWasmS128); | 1136 byte simd1 = r.AllocateLocal(kWasmS128); |
1093 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), | 1137 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), |
1094 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), | 1138 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), |
1095 WASM_SET_LOCAL(simd1, | 1139 WASM_SET_LOCAL(simd1, |
1096 WASM_SIMD_MATERIALIZE_BOOLS( | 1140 WASM_SIMD_MATERIALIZE_BOOLS( |
1097 16x8, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), | 1141 16x8, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), |
1098 WASM_GET_LOCAL(simd1)))), | 1142 WASM_GET_LOCAL(simd1)))), |
1099 WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); | 1143 WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); |
1100 | 1144 |
1101 FOR_INT16_INPUTS(i) { | 1145 FOR_INT16_INPUTS(i) { |
1102 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } | 1146 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } |
1103 } | 1147 } |
1104 } | 1148 } |
1105 | 1149 |
1106 WASM_EXEC_COMPILED_TEST(I16x8Equal) { | 1150 WASM_EXEC_COMPILED_TEST(I16x8Eq) { RunI16x8CompareOpTest(kExprI16x8Eq, Equal); } |
1107 RunI16x8CompareOpTest(kExprI16x8Eq, Equal); | |
1108 } | |
1109 | 1151 |
1110 WASM_EXEC_COMPILED_TEST(I16x8NotEqual) { | 1152 WASM_EXEC_COMPILED_TEST(I16x8Ne) { |
1111 RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual); | 1153 RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual); |
1112 } | 1154 } |
1113 | 1155 |
1114 WASM_EXEC_COMPILED_TEST(I16x8Greater) { | 1156 WASM_EXEC_COMPILED_TEST(I16x8LtS) { |
| 1157 RunI16x8CompareOpTest(kExprI16x8LtS, Less); |
| 1158 } |
| 1159 |
| 1160 WASM_EXEC_COMPILED_TEST(I16x8LeS) { |
| 1161 RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual); |
| 1162 } |
| 1163 |
| 1164 WASM_EXEC_COMPILED_TEST(I16x8GtS) { |
1115 RunI16x8CompareOpTest(kExprI16x8GtS, Greater); | 1165 RunI16x8CompareOpTest(kExprI16x8GtS, Greater); |
1116 } | 1166 } |
1117 | 1167 |
1118 WASM_EXEC_COMPILED_TEST(I16x8GreaterEqual) { | 1168 WASM_EXEC_COMPILED_TEST(I16x8GeS) { |
1119 RunI16x8CompareOpTest(kExprI16x8GeS, GreaterEqual); | 1169 RunI16x8CompareOpTest(kExprI16x8GeS, GreaterEqual); |
1120 } | 1170 } |
1121 | 1171 |
1122 WASM_EXEC_COMPILED_TEST(I16x8Less) { | 1172 WASM_EXEC_COMPILED_TEST(I16x8GtU) { |
1123 RunI16x8CompareOpTest(kExprI16x8LtS, Less); | |
1124 } | |
1125 | |
1126 WASM_EXEC_COMPILED_TEST(I16x8LessEqual) { | |
1127 RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual); | |
1128 } | |
1129 | |
1130 WASM_EXEC_COMPILED_TEST(Ui16x8Greater) { | |
1131 RunI16x8CompareOpTest(kExprI16x8GtU, UnsignedGreater); | 1173 RunI16x8CompareOpTest(kExprI16x8GtU, UnsignedGreater); |
1132 } | 1174 } |
1133 | 1175 |
1134 WASM_EXEC_COMPILED_TEST(Ui16x8GreaterEqual) { | 1176 WASM_EXEC_COMPILED_TEST(I16x8GeU) { |
1135 RunI16x8CompareOpTest(kExprI16x8GeU, UnsignedGreaterEqual); | 1177 RunI16x8CompareOpTest(kExprI16x8GeU, UnsignedGreaterEqual); |
1136 } | 1178 } |
1137 | 1179 |
1138 WASM_EXEC_COMPILED_TEST(Ui16x8Less) { | 1180 WASM_EXEC_COMPILED_TEST(I16x8LtU) { |
1139 RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); | 1181 RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); |
1140 } | 1182 } |
1141 | 1183 |
1142 WASM_EXEC_COMPILED_TEST(Ui16x8LessEqual) { | 1184 WASM_EXEC_COMPILED_TEST(I16x8LeU) { |
1143 RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual); | 1185 RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual); |
1144 } | 1186 } |
1145 | 1187 |
1146 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, | 1188 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, |
1147 int shift) { | 1189 int shift) { |
1148 FLAG_wasm_simd_prototype = true; | 1190 FLAG_wasm_simd_prototype = true; |
1149 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1191 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1150 byte a = 0; | 1192 byte a = 0; |
1151 byte expected = 1; | 1193 byte expected = 1; |
1152 byte simd = r.AllocateLocal(kWasmS128); | 1194 byte simd = r.AllocateLocal(kWasmS128); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 WASM_GET_LOCAL(simd1))), | 1241 WASM_GET_LOCAL(simd1))), |
1200 WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); | 1242 WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); |
1201 | 1243 |
1202 FOR_INT8_INPUTS(i) { | 1244 FOR_INT8_INPUTS(i) { |
1203 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } | 1245 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } |
1204 } | 1246 } |
1205 } | 1247 } |
1206 | 1248 |
1207 WASM_EXEC_COMPILED_TEST(I8x16Add) { RunI8x16BinOpTest(kExprI8x16Add, Add); } | 1249 WASM_EXEC_COMPILED_TEST(I8x16Add) { RunI8x16BinOpTest(kExprI8x16Add, Add); } |
1208 | 1250 |
1209 WASM_EXEC_COMPILED_TEST(I8x16AddSaturate) { | 1251 WASM_EXEC_COMPILED_TEST(I8x16AddSaturateS) { |
1210 RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate); | 1252 RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate); |
1211 } | 1253 } |
1212 | 1254 |
1213 WASM_EXEC_COMPILED_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); } | 1255 WASM_EXEC_COMPILED_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); } |
1214 | 1256 |
1215 WASM_EXEC_COMPILED_TEST(I8x16SubSaturate) { | 1257 WASM_EXEC_COMPILED_TEST(I8x16SubSaturateS) { |
1216 RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate); | 1258 RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate); |
1217 } | 1259 } |
1218 | 1260 |
1219 WASM_EXEC_COMPILED_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); } | 1261 WASM_EXEC_COMPILED_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); } |
1220 | 1262 |
1221 WASM_EXEC_COMPILED_TEST(I8x16Min) { | 1263 WASM_EXEC_COMPILED_TEST(I8x16MinS) { |
1222 RunI8x16BinOpTest(kExprI8x16MinS, Minimum); | 1264 RunI8x16BinOpTest(kExprI8x16MinS, Minimum); |
1223 } | 1265 } |
1224 | 1266 |
1225 WASM_EXEC_COMPILED_TEST(I8x16Max) { | 1267 WASM_EXEC_COMPILED_TEST(I8x16MaxS) { |
1226 RunI8x16BinOpTest(kExprI8x16MaxS, Maximum); | 1268 RunI8x16BinOpTest(kExprI8x16MaxS, Maximum); |
1227 } | 1269 } |
1228 | 1270 |
1229 WASM_EXEC_COMPILED_TEST(Ui8x16AddSaturate) { | 1271 WASM_EXEC_COMPILED_TEST(I8x16AddSaturateU) { |
1230 RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate); | 1272 RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate); |
1231 } | 1273 } |
1232 | 1274 |
1233 WASM_EXEC_COMPILED_TEST(Ui8x16SubSaturate) { | 1275 WASM_EXEC_COMPILED_TEST(I8x16SubSaturateU) { |
1234 RunI8x16BinOpTest(kExprI8x16SubSaturateU, UnsignedSubSaturate); | 1276 RunI8x16BinOpTest(kExprI8x16SubSaturateU, UnsignedSubSaturate); |
1235 } | 1277 } |
1236 | 1278 |
1237 WASM_EXEC_COMPILED_TEST(Ui8x16Min) { | 1279 WASM_EXEC_COMPILED_TEST(I8x16MinU) { |
1238 RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum); | 1280 RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum); |
1239 } | 1281 } |
1240 | 1282 |
1241 WASM_EXEC_COMPILED_TEST(Ui8x16Max) { | 1283 WASM_EXEC_COMPILED_TEST(I8x16MaxU) { |
1242 RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum); | 1284 RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum); |
1243 } | 1285 } |
1244 | 1286 |
1245 void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { | 1287 void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8CompareOp expected_op) { |
1246 FLAG_wasm_simd_prototype = true; | 1288 FLAG_wasm_simd_prototype = true; |
1247 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1289 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1248 byte a = 0; | 1290 byte a = 0; |
1249 byte b = 1; | 1291 byte b = 1; |
1250 byte expected = 2; | 1292 byte expected = 2; |
1251 byte simd0 = r.AllocateLocal(kWasmS128); | 1293 byte simd0 = r.AllocateLocal(kWasmS128); |
1252 byte simd1 = r.AllocateLocal(kWasmS128); | 1294 byte simd1 = r.AllocateLocal(kWasmS128); |
1253 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), | 1295 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), |
1254 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), | 1296 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), |
1255 WASM_SET_LOCAL(simd1, | 1297 WASM_SET_LOCAL(simd1, |
1256 WASM_SIMD_MATERIALIZE_BOOLS( | 1298 WASM_SIMD_MATERIALIZE_BOOLS( |
1257 8x16, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), | 1299 8x16, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), |
1258 WASM_GET_LOCAL(simd1)))), | 1300 WASM_GET_LOCAL(simd1)))), |
1259 WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); | 1301 WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); |
1260 | 1302 |
1261 FOR_INT8_INPUTS(i) { | 1303 FOR_INT8_INPUTS(i) { |
1262 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } | 1304 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } |
1263 } | 1305 } |
1264 } | 1306 } |
1265 | 1307 |
1266 WASM_EXEC_COMPILED_TEST(I8x16Equal) { | 1308 WASM_EXEC_COMPILED_TEST(I8x16Eq) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); } |
1267 RunI8x16CompareOpTest(kExprI8x16Eq, Equal); | |
1268 } | |
1269 | 1309 |
1270 WASM_EXEC_COMPILED_TEST(I8x16NotEqual) { | 1310 WASM_EXEC_COMPILED_TEST(I8x16Ne) { |
1271 RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); | 1311 RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); |
1272 } | 1312 } |
1273 | 1313 |
1274 WASM_EXEC_COMPILED_TEST(I8x16Greater) { | 1314 WASM_EXEC_COMPILED_TEST(I8x16GtS) { |
1275 RunI8x16CompareOpTest(kExprI8x16GtS, Greater); | 1315 RunI8x16CompareOpTest(kExprI8x16GtS, Greater); |
1276 } | 1316 } |
1277 | 1317 |
1278 WASM_EXEC_COMPILED_TEST(I8x16GreaterEqual) { | 1318 WASM_EXEC_COMPILED_TEST(I8x16GeS) { |
1279 RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); | 1319 RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); |
1280 } | 1320 } |
1281 | 1321 |
1282 WASM_EXEC_COMPILED_TEST(I8x16Less) { | 1322 WASM_EXEC_COMPILED_TEST(I8x16LtS) { |
1283 RunI8x16CompareOpTest(kExprI8x16LtS, Less); | 1323 RunI8x16CompareOpTest(kExprI8x16LtS, Less); |
1284 } | 1324 } |
1285 | 1325 |
1286 WASM_EXEC_COMPILED_TEST(I8x16LessEqual) { | 1326 WASM_EXEC_COMPILED_TEST(I8x16LeS) { |
1287 RunI8x16CompareOpTest(kExprI8x16LeS, LessEqual); | 1327 RunI8x16CompareOpTest(kExprI8x16LeS, LessEqual); |
1288 } | 1328 } |
1289 | 1329 |
1290 WASM_EXEC_COMPILED_TEST(Ui8x16Greater) { | 1330 WASM_EXEC_COMPILED_TEST(I8x16GtU) { |
1291 RunI8x16CompareOpTest(kExprI8x16GtU, UnsignedGreater); | 1331 RunI8x16CompareOpTest(kExprI8x16GtU, UnsignedGreater); |
1292 } | 1332 } |
1293 | 1333 |
1294 WASM_EXEC_COMPILED_TEST(Ui8x16GreaterEqual) { | 1334 WASM_EXEC_COMPILED_TEST(I8x16GeU) { |
1295 RunI8x16CompareOpTest(kExprI8x16GeU, UnsignedGreaterEqual); | 1335 RunI8x16CompareOpTest(kExprI8x16GeU, UnsignedGreaterEqual); |
1296 } | 1336 } |
1297 | 1337 |
1298 WASM_EXEC_COMPILED_TEST(Ui8x16Less) { | 1338 WASM_EXEC_COMPILED_TEST(I8x16LtU) { |
1299 RunI8x16CompareOpTest(kExprI8x16LtU, UnsignedLess); | 1339 RunI8x16CompareOpTest(kExprI8x16LtU, UnsignedLess); |
1300 } | 1340 } |
1301 | 1341 |
1302 WASM_EXEC_COMPILED_TEST(Ui8x16LessEqual) { | 1342 WASM_EXEC_COMPILED_TEST(I8x16LeU) { |
1303 RunI8x16CompareOpTest(kExprI8x16LeU, UnsignedLessEqual); | 1343 RunI8x16CompareOpTest(kExprI8x16LeU, UnsignedLessEqual); |
1304 } | 1344 } |
1305 | 1345 |
1306 void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op, | 1346 void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op, |
1307 int shift) { | 1347 int shift) { |
1308 FLAG_wasm_simd_prototype = true; | 1348 FLAG_wasm_simd_prototype = true; |
1309 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1349 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1310 byte a = 0; | 1350 byte a = 0; |
1311 byte expected = 1; | 1351 byte expected = 1; |
1312 byte simd = r.AllocateLocal(kWasmS128); | 1352 byte simd = r.AllocateLocal(kWasmS128); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0), | 1812 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0), |
1773 WASM_F32(65.0))), | 1813 WASM_F32(65.0))), |
1774 WASM_I32V(1)); | 1814 WASM_I32V(1)); |
1775 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } | 1815 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } |
1776 CHECK_EQ(*global, 13.5); | 1816 CHECK_EQ(*global, 13.5); |
1777 CHECK_EQ(*(global + 1), 45.5); | 1817 CHECK_EQ(*(global + 1), 45.5); |
1778 CHECK_EQ(*(global + 2), 32.25); | 1818 CHECK_EQ(*(global + 2), 32.25); |
1779 CHECK_EQ(*(global + 3), 65.0); | 1819 CHECK_EQ(*(global + 3), 65.0); |
1780 } | 1820 } |
1781 #endif // SIMD_LOWERING_TARGET | 1821 #endif // SIMD_LOWERING_TARGET |
OLD | NEW |