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

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

Issue 2167643002: [Turbofan] Make the -0 deopt case more efficient in multiplication. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/compiler/machine-operator-reducer.h" 5 #include "src/compiler/machine-operator-reducer.h"
6 #include "src/base/bits.h" 6 #include "src/base/bits.h"
7 #include "src/base/division-by-constant.h" 7 #include "src/base/division-by-constant.h"
8 #include "src/base/ieee754.h" 8 #include "src/base/ieee754.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/typer.h" 10 #include "src/compiler/typer.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 TEST_F(MachineOperatorReducerTest, 282 TEST_F(MachineOperatorReducerTest,
283 ChangeFloat64ToInt32WithChangeInt32ToFloat64) { 283 ChangeFloat64ToInt32WithChangeInt32ToFloat64) {
284 Node* value = Parameter(0); 284 Node* value = Parameter(0);
285 Reduction reduction = Reduce(graph()->NewNode( 285 Reduction reduction = Reduce(graph()->NewNode(
286 machine()->ChangeFloat64ToInt32(), 286 machine()->ChangeFloat64ToInt32(),
287 graph()->NewNode(machine()->ChangeInt32ToFloat64(), value))); 287 graph()->NewNode(machine()->ChangeInt32ToFloat64(), value)));
288 ASSERT_TRUE(reduction.Changed()); 288 ASSERT_TRUE(reduction.Changed());
289 EXPECT_EQ(value, reduction.replacement()); 289 EXPECT_EQ(value, reduction.replacement());
290 } 290 }
291 291
292
293 TEST_F(MachineOperatorReducerTest, ChangeFloat64ToInt32WithConstant) { 292 TEST_F(MachineOperatorReducerTest, ChangeFloat64ToInt32WithConstant) {
294 TRACED_FOREACH(int32_t, x, kInt32Values) { 293 TRACED_FOREACH(int32_t, x, kInt32Values) {
295 Reduction reduction = Reduce(graph()->NewNode( 294 Reduction reduction = Reduce(graph()->NewNode(
296 machine()->ChangeFloat64ToInt32(), Float64Constant(FastI2D(x)))); 295 machine()->ChangeFloat64ToInt32(), Float64Constant(FastI2D(x))));
297 ASSERT_TRUE(reduction.Changed()); 296 ASSERT_TRUE(reduction.Changed());
298 EXPECT_THAT(reduction.replacement(), IsInt32Constant(x)); 297 EXPECT_THAT(reduction.replacement(), IsInt32Constant(x));
299 } 298 }
300 } 299 }
301 300
302 301
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 IsInt32Constant(base::bits::SignedMulOverflow32(x, y, &z))); 1498 IsInt32Constant(base::bits::SignedMulOverflow32(x, y, &z)));
1500 1499
1501 r = Reduce(graph()->NewNode(common()->Projection(0), mul, control)); 1500 r = Reduce(graph()->NewNode(common()->Projection(0), mul, control));
1502 ASSERT_TRUE(r.Changed()); 1501 ASSERT_TRUE(r.Changed());
1503 EXPECT_THAT(r.replacement(), IsInt32Constant(z)); 1502 EXPECT_THAT(r.replacement(), IsInt32Constant(z));
1504 } 1503 }
1505 } 1504 }
1506 } 1505 }
1507 1506
1508 // ----------------------------------------------------------------------------- 1507 // -----------------------------------------------------------------------------
1508 // Int32LessThan
1509
1510 TEST_F(MachineOperatorReducerTest, Int32LessThanWithWord32Or) {
1511 // Node* control = graph()->start();
Benedikt Meurer 2016/07/20 17:37:44 Nit: Remove this line.
1512 Node* const p0 = Parameter(0);
1513 TRACED_FOREACH(int32_t, x, kInt32Values) {
1514 Node* word32_or =
1515 graph()->NewNode(machine()->Word32Or(), p0, Int32Constant(x));
1516 Node* less_than = graph()->NewNode(machine()->Int32LessThan(), word32_or,
1517 Int32Constant(0));
1518 Reduction r = Reduce(less_than);
1519 if (x < 0) {
1520 ASSERT_TRUE(r.Changed());
1521 EXPECT_THAT(r.replacement(), IsInt32Constant(1));
1522 } else {
1523 ASSERT_FALSE(r.Changed());
1524 }
1525 }
1526 }
1527
1528 // -----------------------------------------------------------------------------
1509 // Uint32LessThan 1529 // Uint32LessThan
1510 1530
1511 TEST_F(MachineOperatorReducerTest, Uint32LessThanWithWord32Sar) { 1531 TEST_F(MachineOperatorReducerTest, Uint32LessThanWithWord32Sar) {
1512 Node* const p0 = Parameter(0); 1532 Node* const p0 = Parameter(0);
1513 TRACED_FORRANGE(uint32_t, shift, 1, 3) { 1533 TRACED_FORRANGE(uint32_t, shift, 1, 3) {
1514 const uint32_t limit = (kMaxInt >> shift) - 1; 1534 const uint32_t limit = (kMaxInt >> shift) - 1;
1515 Node* const node = graph()->NewNode( 1535 Node* const node = graph()->NewNode(
1516 machine()->Uint32LessThan(), 1536 machine()->Uint32LessThan(),
1517 graph()->NewNode(machine()->Word32Sar(), p0, Uint32Constant(shift)), 1537 graph()->NewNode(machine()->Word32Sar(), p0, Uint32Constant(shift)),
1518 Uint32Constant(limit)); 1538 Uint32Constant(limit));
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 Reduction r = Reduce(node); 2050 Reduction r = Reduce(node);
2031 ASSERT_TRUE(r.Changed()); 2051 ASSERT_TRUE(r.Changed());
2032 EXPECT_THAT(r.replacement(), 2052 EXPECT_THAT(r.replacement(),
2033 IsStore(rep, base, index, value, effect, control)); 2053 IsStore(rep, base, index, value, effect, control));
2034 } 2054 }
2035 } 2055 }
2036 2056
2037 } // namespace compiler 2057 } // namespace compiler
2038 } // namespace internal 2058 } // namespace internal
2039 } // namespace v8 2059 } // namespace v8
OLDNEW
« src/compiler/machine-operator-reducer.cc ('K') | « test/mjsunit/compiler/math-mul.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698