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

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

Issue 847113002: [turbofan] Reduce Word32And masking with shifted inputs. (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
« 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 IsInt32Constant(bit_cast<int32_t>( 494 IsInt32Constant(bit_cast<int32_t>(
495 static_cast<uint32_t>(bit_cast<uint64_t>(x))))); 495 static_cast<uint32_t>(bit_cast<uint64_t>(x)))));
496 } 496 }
497 } 497 }
498 498
499 499
500 // ----------------------------------------------------------------------------- 500 // -----------------------------------------------------------------------------
501 // Word32And 501 // Word32And
502 502
503 503
504 TEST_F(MachineOperatorReducerTest, Word32AndWithWord32ShlWithConstant) {
505 Node* const p0 = Parameter(0);
506
507 TRACED_FORRANGE(int32_t, l, 1, 31) {
508 TRACED_FORRANGE(int32_t, k, 1, l) {
509 // (x << L) & (-1 << K) => x << L
510 Reduction const r1 = Reduce(graph()->NewNode(
511 machine()->Word32And(),
512 graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(l)),
513 Int32Constant(-1 << k)));
514 ASSERT_TRUE(r1.Changed());
515 EXPECT_THAT(r1.replacement(), IsWord32Shl(p0, IsInt32Constant(l)));
516
517 // (-1 << K) & (x << L) => x << L
518 Reduction const r2 = Reduce(graph()->NewNode(
519 machine()->Word32And(), Int32Constant(-1 << k),
520 graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(l))));
521 ASSERT_TRUE(r2.Changed());
522 EXPECT_THAT(r2.replacement(), IsWord32Shl(p0, IsInt32Constant(l)));
523 }
524 }
525 }
526
527
504 TEST_F(MachineOperatorReducerTest, Word32AndWithWord32AndWithConstant) { 528 TEST_F(MachineOperatorReducerTest, Word32AndWithWord32AndWithConstant) {
505 Node* const p0 = Parameter(0); 529 Node* const p0 = Parameter(0);
506 530
507 TRACED_FOREACH(int32_t, k, kInt32Values) { 531 TRACED_FOREACH(int32_t, k, kInt32Values) {
508 TRACED_FOREACH(int32_t, l, kInt32Values) { 532 TRACED_FOREACH(int32_t, l, kInt32Values) {
509 if (k == 0 || k == -1 || l == 0 || l == -1) continue; 533 if (k == 0 || k == -1 || l == 0 || l == -1) continue;
510 534
511 // (x & K) & L => x & (K & L) 535 // (x & K) & L => x & (K & L)
512 Reduction const r1 = Reduce(graph()->NewNode( 536 Reduction const r1 = Reduce(graph()->NewNode(
513 machine()->Word32And(), 537 machine()->Word32And(),
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 Reduction r = Reduce(node); 1417 Reduction r = Reduce(node);
1394 ASSERT_TRUE(r.Changed()); 1418 ASSERT_TRUE(r.Changed());
1395 EXPECT_THAT(r.replacement(), 1419 EXPECT_THAT(r.replacement(),
1396 IsStore(rep, base, index, value, effect, control)); 1420 IsStore(rep, base, index, value, effect, control));
1397 } 1421 }
1398 } 1422 }
1399 1423
1400 } // namespace compiler 1424 } // namespace compiler
1401 } // namespace internal 1425 } // namespace internal
1402 } // namespace v8 1426 } // 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