OLD | NEW |
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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 machine()->Word32And(), | 519 machine()->Word32And(), |
520 graph()->NewNode(machine()->Word32And(), Int32Constant(k), p0), | 520 graph()->NewNode(machine()->Word32And(), Int32Constant(k), p0), |
521 Int32Constant(l))); | 521 Int32Constant(l))); |
522 ASSERT_TRUE(r2.Changed()); | 522 ASSERT_TRUE(r2.Changed()); |
523 EXPECT_THAT(r2.replacement(), IsWord32And(p0, IsInt32Constant(k & l))); | 523 EXPECT_THAT(r2.replacement(), IsWord32And(p0, IsInt32Constant(k & l))); |
524 } | 524 } |
525 } | 525 } |
526 } | 526 } |
527 | 527 |
528 | 528 |
| 529 TEST_F(MachineOperatorReducerTest, Word32AndWithInt32AddAndConstant) { |
| 530 Node* const p0 = Parameter(0); |
| 531 |
| 532 TRACED_FOREACH(int32_t, k, kInt32Values) { |
| 533 TRACED_FORRANGE(int32_t, l, 1, 31) { |
| 534 // (x + (K << L)) & (-1 << L) => (x & (-1 << L)) + (K << L) |
| 535 Reduction const r = Reduce(graph()->NewNode( |
| 536 machine()->Word32And(), |
| 537 graph()->NewNode(machine()->Int32Add(), p0, Int32Constant(k << l)), |
| 538 Int32Constant(-1 << l))); |
| 539 ASSERT_TRUE(r.Changed()); |
| 540 EXPECT_THAT(r.replacement(), |
| 541 IsInt32Add(IsWord32And(p0, IsInt32Constant(-1 << l)), |
| 542 IsInt32Constant(k << l))); |
| 543 } |
| 544 } |
| 545 } |
| 546 |
| 547 |
529 // ----------------------------------------------------------------------------- | 548 // ----------------------------------------------------------------------------- |
530 // Word32Xor | 549 // Word32Xor |
531 | 550 |
532 | 551 |
533 TEST_F(MachineOperatorReducerTest, Word32XorWithWord32XorAndMinusOne) { | 552 TEST_F(MachineOperatorReducerTest, Word32XorWithWord32XorAndMinusOne) { |
534 Node* const p0 = Parameter(0); | 553 Node* const p0 = Parameter(0); |
535 | 554 |
536 // (x ^ -1) ^ -1 => x | 555 // (x ^ -1) ^ -1 => x |
537 Reduction r1 = Reduce(graph()->NewNode( | 556 Reduction r1 = Reduce(graph()->NewNode( |
538 machine()->Word32Xor(), | 557 machine()->Word32Xor(), |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 Reduction r = Reduce(node); | 1266 Reduction r = Reduce(node); |
1248 ASSERT_TRUE(r.Changed()); | 1267 ASSERT_TRUE(r.Changed()); |
1249 EXPECT_THAT(r.replacement(), | 1268 EXPECT_THAT(r.replacement(), |
1250 IsStore(rep, base, index, value, effect, control)); | 1269 IsStore(rep, base, index, value, effect, control)); |
1251 } | 1270 } |
1252 } | 1271 } |
1253 | 1272 |
1254 } // namespace compiler | 1273 } // namespace compiler |
1255 } // namespace internal | 1274 } // namespace internal |
1256 } // namespace v8 | 1275 } // namespace v8 |
OLD | NEW |