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

Side by Side Diff: test/cctest/wasm/test-run-wasm-simd-lowering.cc

Issue 2713613005: [wasm]implement simd lowering for F32x4 and I32x4 binops (Closed)
Patch Set: [wasm]implement simd lowering for F32x4 and I32x4 binops Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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"
6 #include "src/wasm/wasm-module.h" 5 #include "src/wasm/wasm-module.h"
7 6
8 #include "test/cctest/cctest.h" 7 #include "test/cctest/wasm/test-wasm-simd-common.h"
9 #include "test/cctest/compiler/value-helper.h"
10 #include "test/cctest/wasm/wasm-run-utils.h"
11 #include "test/common/wasm/test-signatures.h"
12 8
13 using namespace v8::base; 9 using namespace v8::base;
14 using namespace v8::internal; 10 using namespace v8::internal;
15 using namespace v8::internal::compiler; 11 using namespace v8::internal::compiler;
16 using namespace v8::internal::wasm; 12 using namespace v8::internal::wasm;
17 13
18 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat) { 14 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat) {
19 FLAG_wasm_simd_prototype = true; 15 TestWasmSimdCommon::RunI32x4SplatTest();
20 WasmRunner<int32_t> r(kExecuteCompiled);
21 BUILD(r,
22 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(5))));
23 FOR_INT32_INPUTS(i) { CHECK_EQ(5, r.Call()); }
24 }
25
26 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Add) {
27 FLAG_wasm_simd_prototype = true;
28 WasmRunner<int32_t> r(kExecuteCompiled);
29 BUILD(r, WASM_SIMD_I32x4_EXTRACT_LANE(
30 0, WASM_SIMD_I32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)),
31 WASM_SIMD_I32x4_SPLAT(WASM_I32V(6)))));
32 FOR_INT32_INPUTS(i) { CHECK_EQ(11, r.Call()); }
33 } 16 }
34 17
35 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Splat) { 18 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Splat) {
36 FLAG_wasm_simd_prototype = true; 19 TestWasmSimdCommon::RunF32x4SplatTest();
37 WasmRunner<int32_t> r(kExecuteCompiled); 20 }
38 BUILD(r, 21
39 WASM_IF_ELSE_I(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( 22 #define I32X4_BINOP_TEST(test_name, simd_op, func) \
40 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(9.5))), 23 WASM_EXEC_COMPILED_TEST(test_name) { \
41 WASM_F32(9.5)), 24 TestWasmSimdCommon::RunI32x4BinOpTest(simd_op, func); \
42 WASM_I32V(1), WASM_I32V(0))); 25 }
43 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 26 I32X4_BINOP_TEST(Simd_I32x4_Add, kExprI32x4Add, Add)
27 I32X4_BINOP_TEST(Simd_I32x4_Sub, kExprI32x4Sub, Sub)
28 I32X4_BINOP_TEST(Simd_I32x4_Mul, kExprI32x4Mul, Mul)
29 I32X4_BINOP_TEST(Simd_128_And, kExprS128And, And)
30 I32X4_BINOP_TEST(Simd_128_Or, kExprS128Or, Or)
31 I32X4_BINOP_TEST(Simd_128_Xor, kExprS128Xor, Xor)
32 #undef I32X4_BINOP_TEST
33
34 #define F32X4_BINOP_TEST(op, name) \
35 WASM_EXEC_COMPILED_TEST(Simd_F32x4_##name) { \
36 TestWasmSimdCommon::RunF32x4BinOpTest(kExprF32x4##op, name); \
37 }
38 F32X4_BINOP_TEST(Add, Add)
39 F32X4_BINOP_TEST(Sub, Sub)
40 F32X4_BINOP_TEST(Mul, Mul)
41 F32X4_BINOP_TEST(Div, Div)
42 #undef F32X4_BINOP_TEST
43 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Min) {
44 TestWasmSimdCommon::RunF32x4BinOpTest(kExprF32x4Min, Minimum, true);
45 }
46 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Max) {
47 TestWasmSimdCommon::RunF32x4BinOpTest(kExprF32x4Max, Maximum, true);
44 } 48 }
45 49
46 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Extract_With_F32x4) { 50 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Extract_With_F32x4) {
47 FLAG_wasm_simd_prototype = true; 51 FLAG_wasm_simd_prototype = true;
48 WasmRunner<int32_t> r(kExecuteCompiled); 52 WasmRunner<int32_t> r(kExecuteCompiled);
49 BUILD(r, WASM_IF_ELSE_I( 53 BUILD(r, WASM_IF_ELSE_I(
50 WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( 54 WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE(
51 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))), 55 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))),
52 WASM_I32_REINTERPRET_F32(WASM_F32(30.5))), 56 WASM_I32_REINTERPRET_F32(WASM_F32(30.5))),
53 WASM_I32V(1), WASM_I32V(0))); 57 WASM_I32V(1), WASM_I32V(0)));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 FLAG_wasm_simd_prototype = true; 103 FLAG_wasm_simd_prototype = true;
100 WasmRunner<int32_t> r(kExecuteCompiled); 104 WasmRunner<int32_t> r(kExecuteCompiled);
101 r.AllocateLocal(kWasmS128); 105 r.AllocateLocal(kWasmS128);
102 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), 106 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
103 107
104 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0))); 108 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0)));
105 FOR_INT32_INPUTS(i) { CHECK_EQ(31, r.Call()); } 109 FOR_INT32_INPUTS(i) { CHECK_EQ(31, r.Call()); }
106 } 110 }
107 111
108 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) { 112 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) {
109 FLAG_wasm_simd_prototype = true; 113 TestWasmSimdCommon::RunI32x4ReplaceLaneTest();
110 WasmRunner<int32_t> r(kExecuteCompiled);
111 r.AllocateLocal(kWasmS128);
112 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
113 WASM_SET_LOCAL(0, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(0),
114 WASM_I32V(53))),
115 WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(0)));
116 FOR_INT32_INPUTS(i) { CHECK_EQ(53, r.Call()); }
117 } 114 }
118 115
119 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) { 116 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) {
120 FLAG_wasm_simd_prototype = true; 117 TestWasmSimdCommon::RunF32x4ReplaceLaneTest();
121 WasmRunner<int32_t> r(kExecuteCompiled);
122 r.AllocateLocal(kWasmF32);
123 r.AllocateLocal(kWasmS128);
124 BUILD(r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(23.5))),
125 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(1),
126 WASM_F32(65.25))),
127 WASM_SET_LOCAL(0, WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1))),
128 WASM_IF(WASM_F32_EQ(WASM_GET_LOCAL(0), WASM_F32(65.25)),
129 WASM_RETURN1(WASM_I32V(1))),
130 WASM_I32V(0));
131 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
132 } 118 }
133 119
134 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) { 120 WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) {
135 FLAG_wasm_simd_prototype = true; 121 FLAG_wasm_simd_prototype = true;
136 WasmRunner<int32_t> r(kExecuteCompiled); 122 WasmRunner<int32_t> r(kExecuteCompiled);
137 r.AllocateLocal(kWasmI32); 123 r.AllocateLocal(kWasmI32);
138 r.AllocateLocal(kWasmS128); 124 r.AllocateLocal(kWasmS128);
139 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE( 125 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE(
140 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))), 126 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))),
141 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))), 127 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))),
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 WASM_SET_LOCAL(0, WASM_I32V(1)), 273 WASM_SET_LOCAL(0, WASM_I32V(1)),
288 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)), 274 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)),
289 WASM_F32(27.25)), 275 WASM_F32(27.25)),
290 WASM_SET_LOCAL(0, WASM_I32V(0))), 276 WASM_SET_LOCAL(0, WASM_I32V(0))),
291 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)), 277 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)),
292 WASM_F32(25.5)), 278 WASM_F32(25.5)),
293 WASM_SET_LOCAL(0, WASM_I32V(0))), 279 WASM_SET_LOCAL(0, WASM_I32V(0))),
294 WASM_GET_LOCAL(0)); 280 WASM_GET_LOCAL(0));
295 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); } 281 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
296 } 282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698