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

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

Issue 801263002: [turbofan] Correctify TruncateFloat64ToInt32 reduction in MachineOperatorReducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 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"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 Reduction reduction = Reduce(graph()->NewNode( 462 Reduction reduction = Reduce(graph()->NewNode(
463 machine()->TruncateFloat64ToInt32(), 463 machine()->TruncateFloat64ToInt32(),
464 graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p1, merge))); 464 graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p1, merge)));
465 ASSERT_TRUE(reduction.Changed()); 465 ASSERT_TRUE(reduction.Changed());
466 EXPECT_THAT(reduction.replacement(), 466 EXPECT_THAT(reduction.replacement(),
467 IsPhi(kMachInt32, IsTruncateFloat64ToInt32(p0), 467 IsPhi(kMachInt32, IsTruncateFloat64ToInt32(p0),
468 IsTruncateFloat64ToInt32(p1), merge)); 468 IsTruncateFloat64ToInt32(p1), merge));
469 } 469 }
470 470
471 471
472 TEST_F(MachineOperatorReducerTest,
473 TruncateFloat64ToInt32WithPhiAndChangeInt32ToFloat64) {
474 Node* const p0 = Parameter(0);
475 Node* const merge = graph()->start();
476 Node* const truncate = graph()->NewNode(
477 machine()->TruncateFloat64ToInt32(),
478 graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p0, merge));
479 truncate->InputAt(0)->ReplaceInput(
480 1, graph()->NewNode(machine()->ChangeInt32ToFloat64(), truncate));
481 Reduction reduction = Reduce(truncate);
482 ASSERT_TRUE(reduction.Changed());
483 Capture<Node*> phi;
484 EXPECT_THAT(
485 reduction.replacement(),
486 AllOf(CaptureEq(&phi), IsPhi(kMachInt32, IsTruncateFloat64ToInt32(p0),
487 CaptureEq(&phi), merge)));
488 }
489
490
472 // ----------------------------------------------------------------------------- 491 // -----------------------------------------------------------------------------
473 // TruncateInt64ToInt32 492 // TruncateInt64ToInt32
474 493
475 494
476 TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32WithChangeInt32ToInt64) { 495 TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32WithChangeInt32ToInt64) {
477 Node* value = Parameter(0); 496 Node* value = Parameter(0);
478 Reduction reduction = Reduce(graph()->NewNode( 497 Reduction reduction = Reduce(graph()->NewNode(
479 machine()->TruncateInt64ToInt32(), 498 machine()->TruncateInt64ToInt32(),
480 graph()->NewNode(machine()->ChangeInt32ToInt64(), value))); 499 graph()->NewNode(machine()->ChangeInt32ToInt64(), value)));
481 ASSERT_TRUE(reduction.Changed()); 500 ASSERT_TRUE(reduction.Changed());
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 Reduction r = Reduce(node); 1350 Reduction r = Reduce(node);
1332 ASSERT_TRUE(r.Changed()); 1351 ASSERT_TRUE(r.Changed());
1333 EXPECT_THAT(r.replacement(), 1352 EXPECT_THAT(r.replacement(),
1334 IsStore(rep, base, index, value, effect, control)); 1353 IsStore(rep, base, index, value, effect, control));
1335 } 1354 }
1336 } 1355 }
1337 1356
1338 } // namespace compiler 1357 } // namespace compiler
1339 } // namespace internal 1358 } // namespace internal
1340 } // namespace v8 1359 } // namespace v8
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