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

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

Issue 732103002: [turbofan] remove redundant '& 0x1F' for shifts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments + ror fix Created 6 years, 1 month 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/x64/instruction-selector-x64.cc ('k') | test/mjsunit/asm/word32ror.js » ('j') | 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 "test/cctest/cctest.h" 5 #include "test/cctest/cctest.h"
6 6
7 #include "src/base/utils/random-number-generator.h" 7 #include "src/base/utils/random-number-generator.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/compiler/graph-inl.h" 9 #include "src/compiler/graph-inl.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 template <> 46 template <>
47 double ValueOfOperator<double>(const Operator* op) { 47 double ValueOfOperator<double>(const Operator* op) {
48 CHECK_EQ(IrOpcode::kFloat64Constant, op->opcode()); 48 CHECK_EQ(IrOpcode::kFloat64Constant, op->opcode());
49 return OpParameter<double>(op); 49 return OpParameter<double>(op);
50 } 50 }
51 51
52 52
53 class ReducerTester : public HandleAndZoneScope { 53 class ReducerTester : public HandleAndZoneScope {
54 public: 54 public:
55 explicit ReducerTester(int num_parameters = 0) 55 explicit ReducerTester(
56 int num_parameters = 0,
57 MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags)
56 : isolate(main_isolate()), 58 : isolate(main_isolate()),
57 binop(NULL), 59 binop(NULL),
58 unop(NULL), 60 unop(NULL),
59 machine(main_zone()), 61 machine(main_zone(), kMachPtr, flags),
60 common(main_zone()), 62 common(main_zone()),
61 graph(main_zone()), 63 graph(main_zone()),
62 javascript(main_zone()), 64 javascript(main_zone()),
63 typer(&graph, MaybeHandle<Context>()), 65 typer(&graph, MaybeHandle<Context>()),
64 jsgraph(&graph, &common, &javascript, &machine), 66 jsgraph(&graph, &common, &javascript, &machine),
65 maxuint32(Constant<int32_t>(kMaxUInt32)) { 67 maxuint32(Constant<int32_t>(kMaxUInt32)) {
66 Node* s = graph.NewNode(common.Start(num_parameters)); 68 Node* s = graph.NewNode(common.Start(num_parameters));
67 graph.SetStart(s); 69 graph.SetStart(s);
68 } 70 }
69 71
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 353
352 R.CheckDontPutConstantOnRight(44); 354 R.CheckDontPutConstantOnRight(44);
353 355
354 Node* x = R.Parameter(); 356 Node* x = R.Parameter();
355 Node* zero = R.Constant<int32_t>(0); 357 Node* zero = R.Constant<int32_t>(0);
356 358
357 R.CheckBinop(x, x, zero); // x >> 0 => x 359 R.CheckBinop(x, x, zero); // x >> 0 => x
358 } 360 }
359 361
360 362
361 TEST(ReduceWord32Equal) { 363 static void CheckJsShift(ReducerTester* R) {
364 DCHECK(R->machine.Word32ShiftIsSafe());
365
366 Node* x = R->Parameter(0);
367 Node* y = R->Parameter(1);
368 Node* thirty_one = R->Constant<int32_t>(0x1f);
369 Node* y_and_thirty_one =
370 R->graph.NewNode(R->machine.Word32And(), y, thirty_one);
371
372 // If the underlying machine shift instructions 'and' their right operand
373 // with 0x1f then: x << (y & 0x1f) => x << y
374 R->CheckFoldBinop(x, y, x, y_and_thirty_one);
375 }
376
377
378 TEST(ReduceJsShifts) {
379 ReducerTester R(0, MachineOperatorBuilder::kWord32ShiftIsSafe);
380
381 R.binop = R.machine.Word32Shl();
382 CheckJsShift(&R);
383
384 R.binop = R.machine.Word32Shr();
385 CheckJsShift(&R);
386
387 R.binop = R.machine.Word32Sar();
388 CheckJsShift(&R);
389 }
390
391
392 TEST(Word32Equal) {
362 ReducerTester R; 393 ReducerTester R;
363 R.binop = R.machine.Word32Equal(); 394 R.binop = R.machine.Word32Equal();
364 395
365 FOR_INT32_INPUTS(pl) { 396 FOR_INT32_INPUTS(pl) {
366 FOR_INT32_INPUTS(pr) { 397 FOR_INT32_INPUTS(pr) {
367 int32_t x = *pl, y = *pr; 398 int32_t x = *pl, y = *pr;
368 R.CheckFoldBinop<int32_t>(x == y ? 1 : 0, x, y); 399 R.CheckFoldBinop<int32_t>(x == y ? 1 : 0, x, y);
369 } 400 }
370 } 401 }
371 402
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 // TODO(titzer): test MachineOperatorReducer for Int64Mul 864 // TODO(titzer): test MachineOperatorReducer for Int64Mul
834 // TODO(titzer): test MachineOperatorReducer for Int64UMul 865 // TODO(titzer): test MachineOperatorReducer for Int64UMul
835 // TODO(titzer): test MachineOperatorReducer for Int64Div 866 // TODO(titzer): test MachineOperatorReducer for Int64Div
836 // TODO(titzer): test MachineOperatorReducer for Uint64Div 867 // TODO(titzer): test MachineOperatorReducer for Uint64Div
837 // TODO(titzer): test MachineOperatorReducer for Int64Mod 868 // TODO(titzer): test MachineOperatorReducer for Int64Mod
838 // TODO(titzer): test MachineOperatorReducer for Uint64Mod 869 // TODO(titzer): test MachineOperatorReducer for Uint64Mod
839 // TODO(titzer): test MachineOperatorReducer for Int64Neg 870 // TODO(titzer): test MachineOperatorReducer for Int64Neg
840 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 871 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64
841 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 872 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32
842 // TODO(titzer): test MachineOperatorReducer for Float64Compare 873 // TODO(titzer): test MachineOperatorReducer for Float64Compare
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | test/mjsunit/asm/word32ror.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698