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

Side by Side Diff: test/unittests/compiler/machine-operator-reducer-unittest.cc

Issue 831203003: [turbofan] Fix incorrect minus zero handling in the unit tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/base/bits.h" 5 #include "src/base/bits.h"
6 #include "src/base/division-by-constant.h" 6 #include "src/base/division-by-constant.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/machine-operator-reducer.h" 8 #include "src/compiler/machine-operator-reducer.h"
9 #include "src/compiler/typer.h" 9 #include "src/compiler/typer.h"
10 #include "test/unittests/compiler/graph-unittest.h" 10 #include "test/unittests/compiler/graph-unittest.h"
11 #include "test/unittests/compiler/node-test-utils.h" 11 #include "test/unittests/compiler/node-test-utils.h"
12 #include "testing/gmock-support.h" 12 #include "testing/gmock-support.h"
13 13
14 using testing::AllOf; 14 using testing::AllOf;
15 using testing::BitEq;
15 using testing::Capture; 16 using testing::Capture;
16 using testing::CaptureEq; 17 using testing::CaptureEq;
17 18
18 namespace v8 { 19 namespace v8 {
19 namespace internal { 20 namespace internal {
20 namespace compiler { 21 namespace compiler {
21 22
22 class MachineOperatorReducerTest : public TypedGraphTest { 23 class MachineOperatorReducerTest : public TypedGraphTest {
23 public: 24 public:
24 explicit MachineOperatorReducerTest(int num_parameters = 2) 25 explicit MachineOperatorReducerTest(int num_parameters = 2)
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 285
285 // ----------------------------------------------------------------------------- 286 // -----------------------------------------------------------------------------
286 // ChangeFloat64ToFloat32 287 // ChangeFloat64ToFloat32
287 288
288 289
289 TEST_F(MachineOperatorReducerTest, ChangeFloat64ToFloat32WithConstant) { 290 TEST_F(MachineOperatorReducerTest, ChangeFloat64ToFloat32WithConstant) {
290 TRACED_FOREACH(float, x, kFloat32Values) { 291 TRACED_FOREACH(float, x, kFloat32Values) {
291 Reduction reduction = Reduce(graph()->NewNode( 292 Reduction reduction = Reduce(graph()->NewNode(
292 machine()->ChangeFloat32ToFloat64(), Float32Constant(x))); 293 machine()->ChangeFloat32ToFloat64(), Float32Constant(x)));
293 ASSERT_TRUE(reduction.Changed()); 294 ASSERT_TRUE(reduction.Changed());
294 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(x)); 295 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(BitEq<double>(x)));
295 } 296 }
296 } 297 }
297 298
298 299
299 // ----------------------------------------------------------------------------- 300 // -----------------------------------------------------------------------------
300 // ChangeFloat64ToInt32 301 // ChangeFloat64ToInt32
301 302
302 303
303 TEST_F(MachineOperatorReducerTest, 304 TEST_F(MachineOperatorReducerTest,
304 ChangeFloat64ToInt32WithChangeInt32ToFloat64) { 305 ChangeFloat64ToInt32WithChangeInt32ToFloat64) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 349
349 // ----------------------------------------------------------------------------- 350 // -----------------------------------------------------------------------------
350 // ChangeInt32ToFloat64 351 // ChangeInt32ToFloat64
351 352
352 353
353 TEST_F(MachineOperatorReducerTest, ChangeInt32ToFloat64WithConstant) { 354 TEST_F(MachineOperatorReducerTest, ChangeInt32ToFloat64WithConstant) {
354 TRACED_FOREACH(int32_t, x, kInt32Values) { 355 TRACED_FOREACH(int32_t, x, kInt32Values) {
355 Reduction reduction = Reduce( 356 Reduction reduction = Reduce(
356 graph()->NewNode(machine()->ChangeInt32ToFloat64(), Int32Constant(x))); 357 graph()->NewNode(machine()->ChangeInt32ToFloat64(), Int32Constant(x)));
357 ASSERT_TRUE(reduction.Changed()); 358 ASSERT_TRUE(reduction.Changed());
358 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(FastI2D(x))); 359 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(BitEq(FastI2D(x))));
359 } 360 }
360 } 361 }
361 362
362 363
363 // ----------------------------------------------------------------------------- 364 // -----------------------------------------------------------------------------
364 // ChangeInt32ToInt64 365 // ChangeInt32ToInt64
365 366
366 367
367 TEST_F(MachineOperatorReducerTest, ChangeInt32ToInt64WithConstant) { 368 TEST_F(MachineOperatorReducerTest, ChangeInt32ToInt64WithConstant) {
368 TRACED_FOREACH(int32_t, x, kInt32Values) { 369 TRACED_FOREACH(int32_t, x, kInt32Values) {
369 Reduction reduction = Reduce( 370 Reduction reduction = Reduce(
370 graph()->NewNode(machine()->ChangeInt32ToInt64(), Int32Constant(x))); 371 graph()->NewNode(machine()->ChangeInt32ToInt64(), Int32Constant(x)));
371 ASSERT_TRUE(reduction.Changed()); 372 ASSERT_TRUE(reduction.Changed());
372 EXPECT_THAT(reduction.replacement(), IsInt64Constant(x)); 373 EXPECT_THAT(reduction.replacement(), IsInt64Constant(x));
373 } 374 }
374 } 375 }
375 376
376 377
377 // ----------------------------------------------------------------------------- 378 // -----------------------------------------------------------------------------
378 // ChangeUint32ToFloat64 379 // ChangeUint32ToFloat64
379 380
380 381
381 TEST_F(MachineOperatorReducerTest, ChangeUint32ToFloat64WithConstant) { 382 TEST_F(MachineOperatorReducerTest, ChangeUint32ToFloat64WithConstant) {
382 TRACED_FOREACH(uint32_t, x, kUint32Values) { 383 TRACED_FOREACH(uint32_t, x, kUint32Values) {
383 Reduction reduction = 384 Reduction reduction =
384 Reduce(graph()->NewNode(machine()->ChangeUint32ToFloat64(), 385 Reduce(graph()->NewNode(machine()->ChangeUint32ToFloat64(),
385 Int32Constant(bit_cast<int32_t>(x)))); 386 Int32Constant(bit_cast<int32_t>(x))));
386 ASSERT_TRUE(reduction.Changed()); 387 ASSERT_TRUE(reduction.Changed());
387 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(FastUI2D(x))); 388 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(BitEq(FastUI2D(x))));
388 } 389 }
389 } 390 }
390 391
391 392
392 // ----------------------------------------------------------------------------- 393 // -----------------------------------------------------------------------------
393 // ChangeUint32ToUint64 394 // ChangeUint32ToUint64
394 395
395 396
396 TEST_F(MachineOperatorReducerTest, ChangeUint32ToUint64WithConstant) { 397 TEST_F(MachineOperatorReducerTest, ChangeUint32ToUint64WithConstant) {
397 TRACED_FOREACH(uint32_t, x, kUint32Values) { 398 TRACED_FOREACH(uint32_t, x, kUint32Values) {
(...skipping 20 matching lines...) Expand all
418 ASSERT_TRUE(reduction.Changed()); 419 ASSERT_TRUE(reduction.Changed());
419 EXPECT_EQ(value, reduction.replacement()); 420 EXPECT_EQ(value, reduction.replacement());
420 } 421 }
421 422
422 423
423 TEST_F(MachineOperatorReducerTest, TruncateFloat64ToFloat32WithConstant) { 424 TEST_F(MachineOperatorReducerTest, TruncateFloat64ToFloat32WithConstant) {
424 TRACED_FOREACH(double, x, kFloat64Values) { 425 TRACED_FOREACH(double, x, kFloat64Values) {
425 Reduction reduction = Reduce(graph()->NewNode( 426 Reduction reduction = Reduce(graph()->NewNode(
426 machine()->TruncateFloat64ToFloat32(), Float64Constant(x))); 427 machine()->TruncateFloat64ToFloat32(), Float64Constant(x)));
427 ASSERT_TRUE(reduction.Changed()); 428 ASSERT_TRUE(reduction.Changed());
428 EXPECT_THAT(reduction.replacement(), IsFloat32Constant(DoubleToFloat32(x))); 429 EXPECT_THAT(reduction.replacement(),
430 IsFloat32Constant(BitEq(DoubleToFloat32(x))));
429 } 431 }
430 } 432 }
431 433
432 434
433 // ----------------------------------------------------------------------------- 435 // -----------------------------------------------------------------------------
434 // TruncateFloat64ToInt32 436 // TruncateFloat64ToInt32
435 437
436 438
437 TEST_F(MachineOperatorReducerTest, 439 TEST_F(MachineOperatorReducerTest,
438 TruncateFloat64ToInt32WithChangeInt32ToFloat64) { 440 TruncateFloat64ToInt32WithChangeInt32ToFloat64) {
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 // ----------------------------------------------------------------------------- 1263 // -----------------------------------------------------------------------------
1262 // Float64Mul 1264 // Float64Mul
1263 1265
1264 1266
1265 TEST_F(MachineOperatorReducerTest, Float64MulWithMinusOne) { 1267 TEST_F(MachineOperatorReducerTest, Float64MulWithMinusOne) {
1266 Node* const p0 = Parameter(0); 1268 Node* const p0 = Parameter(0);
1267 { 1269 {
1268 Reduction r = Reduce( 1270 Reduction r = Reduce(
1269 graph()->NewNode(machine()->Float64Mul(), p0, Float64Constant(-1.0))); 1271 graph()->NewNode(machine()->Float64Mul(), p0, Float64Constant(-1.0)));
1270 ASSERT_TRUE(r.Changed()); 1272 ASSERT_TRUE(r.Changed());
1271 EXPECT_THAT(r.replacement(), IsFloat64Sub(IsFloat64Constant(-0.0), p0)); 1273 EXPECT_THAT(r.replacement(),
1274 IsFloat64Sub(IsFloat64Constant(BitEq(-0.0)), p0));
1272 } 1275 }
1273 { 1276 {
1274 Reduction r = Reduce( 1277 Reduction r = Reduce(
1275 graph()->NewNode(machine()->Float64Mul(), Float64Constant(-1.0), p0)); 1278 graph()->NewNode(machine()->Float64Mul(), Float64Constant(-1.0), p0));
1276 ASSERT_TRUE(r.Changed()); 1279 ASSERT_TRUE(r.Changed());
1277 EXPECT_THAT(r.replacement(), IsFloat64Sub(IsFloat64Constant(-0.0), p0)); 1280 EXPECT_THAT(r.replacement(),
1281 IsFloat64Sub(IsFloat64Constant(BitEq(-0.0)), p0));
1278 } 1282 }
1279 } 1283 }
1280 1284
1281 1285
1282 // ----------------------------------------------------------------------------- 1286 // -----------------------------------------------------------------------------
1283 // Store 1287 // Store
1284 1288
1285 1289
1286 TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) { 1290 TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) {
1287 const StoreRepresentation rep(kRepWord8, kNoWriteBarrier); 1291 const StoreRepresentation rep(kRepWord8, kNoWriteBarrier);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 Reduction r = Reduce(node); 1374 Reduction r = Reduce(node);
1371 ASSERT_TRUE(r.Changed()); 1375 ASSERT_TRUE(r.Changed());
1372 EXPECT_THAT(r.replacement(), 1376 EXPECT_THAT(r.replacement(),
1373 IsStore(rep, base, index, value, effect, control)); 1377 IsStore(rep, base, index, value, effect, control));
1374 } 1378 }
1375 } 1379 }
1376 1380
1377 } // namespace compiler 1381 } // namespace compiler
1378 } // namespace internal 1382 } // namespace internal
1379 } // namespace v8 1383 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/js-typed-lowering-unittest.cc ('k') | test/unittests/compiler/simplified-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698