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

Side by Side Diff: test/mjsunit/wasm/float-constant-folding.js

Issue 2662363003: [wasm] Remove -0 -x = -x folding because of signalling NaNs. (Closed)
Patch Set: Rebase 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
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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 // Flags: --expose-wasm 5 // Flags: --expose-wasm
6 6
7 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 (function() { 10 (function() {
11 print("F32: sNaN - 0 = qNaN"); 11 print("F32: sNaN - 0 = qNaN");
12 var builder = new WasmModuleBuilder(); 12 var builder = new WasmModuleBuilder();
13 builder.addFunction("F32Sub0", kSig_i_i) 13 builder.addFunction("F32Sub0", kSig_i_i)
14 .addBody([ 14 .addBody([
15 kExprGetLocal, 0, 15 kExprGetLocal, 0,
16 kExprF32ReinterpretI32, 16 kExprF32ReinterpretI32,
17 kExprF32Const, 0x00, 0x00, 0x00, 0x00, // 0.0 17 kExprF32Const, 0x00, 0x00, 0x00, 0x00, // 0.0
18 kExprF32Sub, 18 kExprF32Sub,
19 kExprI32ReinterpretF32, 19 kExprI32ReinterpretF32,
20 ]) 20 ])
21 .exportFunc(); 21 .exportFunc();
22 var module = builder.instantiate(); 22 var module = builder.instantiate();
23 // F32Sub0(signalling_NaN) 23 // F32Sub0(signalling_NaN)
24 assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000)); 24 assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000));
25 })(); 25 })();
26 26
27 (function() { 27 (function() {
28 print("F32: -0 sNaN = qNaN");
29 var builder = new WasmModuleBuilder();
30 builder.addFunction("F32Sub0", kSig_i_i)
31 .addBody([
32 kExprF32Const, 0x00, 0x00, 0x00, 0x80, // 0.0
33 kExprGetLocal, 0,
34 kExprF32ReinterpretI32,
35 kExprF32Sub,
36 kExprI32ReinterpretF32,
37 ])
38 .exportFunc();
39 var module = builder.instantiate();
40 // F32Sub0(signalling_NaN)
41 assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000));
42 })();
43
44 (function() {
28 print("F32: sNaN - X = qNaN"); 45 print("F32: sNaN - X = qNaN");
29 var builder = new WasmModuleBuilder(); 46 var builder = new WasmModuleBuilder();
30 builder.addFunction("F32NaNSubX", kSig_i_i) 47 builder.addFunction("F32NaNSubX", kSig_i_i)
31 .addBody([ 48 .addBody([
32 kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, 49 kExprF32Const, 0x00, 0x00, 0xa0, 0x7f,
33 kExprF32Const, 0x12, 0x34, 0x56, 0x78, 50 kExprF32Const, 0x12, 0x34, 0x56, 0x78,
34 kExprF32Sub, 51 kExprF32Sub,
35 kExprI32ReinterpretF32, 52 kExprI32ReinterpretF32,
36 ]) 53 ])
37 .exportFunc(); 54 .exportFunc();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 kExprI64Const, 32, 102 kExprI64Const, 32,
86 kExprI64ShrU, 103 kExprI64ShrU,
87 kExprI32ConvertI64, 104 kExprI32ConvertI64,
88 ]) 105 ])
89 .exportFunc(); 106 .exportFunc();
90 var module = builder.instantiate(); 107 var module = builder.instantiate();
91 assertEquals(0x7ffa0000, module.exports.F64Sub0()); 108 assertEquals(0x7ffa0000, module.exports.F64Sub0());
92 })(); 109 })();
93 110
94 (function() { 111 (function() {
112 print("F64: -0 - sNaN = qNaN");
113 var builder = new WasmModuleBuilder();
114 builder.addFunction("F64Sub0", kSig_i_i)
115 .addBody([
116 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, // 0.0
117 kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00,
118 kExprF64ReinterpretI64,
119 kExprF64Sub,
120 kExprI64ReinterpretF64,
121 kExprI64Const, 32,
122 kExprI64ShrU,
123 kExprI32ConvertI64,
124 ])
125 .exportFunc();
126 var module = builder.instantiate();
127 assertEquals(0x7ffa0000, module.exports.F64Sub0());
128 })();
129
130 (function() {
95 print("F64: sNaN - X = qNaN"); 131 print("F64: sNaN - X = qNaN");
96 var builder = new WasmModuleBuilder(); 132 var builder = new WasmModuleBuilder();
97 builder.addFunction("F64NaNSubX", kSig_i_i) 133 builder.addFunction("F64NaNSubX", kSig_i_i)
98 .addBody([ 134 .addBody([
99 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, 135 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
100 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, 136 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
101 kExprF64Sub, 137 kExprF64Sub,
102 kExprI64ReinterpretF64, 138 kExprI64ReinterpretF64,
103 kExprI64Const, 32, 139 kExprI64Const, 32,
104 kExprI64ShrU, 140 kExprI64ShrU,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 kExprI64Const, 32, 213 kExprI64Const, 32,
178 kExprI64ShrU, 214 kExprI64ShrU,
179 kExprI32ConvertI64, 215 kExprI32ConvertI64,
180 ]) 216 ])
181 .exportFunc(); 217 .exportFunc();
182 var module = builder.instantiate(); 218 var module = builder.instantiate();
183 assertEquals(0x7ffa0000, module.exports.F64Div1()); 219 assertEquals(0x7ffa0000, module.exports.F64Div1());
184 })(); 220 })();
185 221
186 (function() { 222 (function() {
223 print("F64: sNaN / -1 = qNaN");
224 var builder = new WasmModuleBuilder();
225 builder.addFunction("F64Div1", kSig_i_i)
226 .addBody([
227 kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00,
228 kExprF64ReinterpretI64,
229 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xbf,
230 kExprF64Div,
231 kExprI64ReinterpretF64,
232 kExprI64Const, 32,
233 kExprI64ShrU,
234 kExprI32ConvertI64,
235 ])
236 .exportFunc();
237 var module = builder.instantiate();
238 assertEquals(0x7ffa0000, module.exports.F64Div1());
239 })();
240
241 (function() {
187 print("F64: X / sNaN = qNaN"); 242 print("F64: X / sNaN = qNaN");
188 var builder = new WasmModuleBuilder(); 243 var builder = new WasmModuleBuilder();
189 builder.addFunction("F64XDivNaN", kSig_i_i) 244 builder.addFunction("F64XDivNaN", kSig_i_i)
190 .addBody([ 245 .addBody([
191 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, 246 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
192 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, 247 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
193 kExprF64Div, 248 kExprF64Div,
194 kExprI64ReinterpretF64, 249 kExprI64ReinterpretF64,
195 kExprI64Const, 32, 250 kExprI64Const, 32,
196 kExprI64ShrU, 251 kExprI64ShrU,
(...skipping 14 matching lines...) Expand all
211 kExprF64Div, 266 kExprF64Div,
212 kExprI64ReinterpretF64, 267 kExprI64ReinterpretF64,
213 kExprI64Const, 32, 268 kExprI64Const, 32,
214 kExprI64ShrU, 269 kExprI64ShrU,
215 kExprI32ConvertI64, 270 kExprI32ConvertI64,
216 ]) 271 ])
217 .exportFunc(); 272 .exportFunc();
218 var module = builder.instantiate(); 273 var module = builder.instantiate();
219 assertEquals(0x7ffa0000, module.exports.F64NaNDivX()); 274 assertEquals(0x7ffa0000, module.exports.F64NaNDivX());
220 })(); 275 })();
OLDNEW
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698