| 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 "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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 Node* minus_one = R.Constant<int32_t>(-1); | 470 Node* minus_one = R.Constant<int32_t>(-1); |
| 471 | 471 |
| 472 R.CheckBinop(x, x, one); // x / 1 => x | 472 R.CheckBinop(x, x, one); // x / 1 => x |
| 473 // TODO(titzer): // 0 / x => 0 if x != 0 | 473 // TODO(titzer): // 0 / x => 0 if x != 0 |
| 474 // TODO(titzer): // x / 2^n => x >> n and round | 474 // TODO(titzer): // x / 2^n => x >> n and round |
| 475 R.CheckFoldBinop<int32_t>(0, R.machine.Int32Sub(), x, x, | 475 R.CheckFoldBinop<int32_t>(0, R.machine.Int32Sub(), x, x, |
| 476 minus_one); // x / -1 => 0 - x | 476 minus_one); // x / -1 => 0 - x |
| 477 } | 477 } |
| 478 | 478 |
| 479 | 479 |
| 480 TEST(ReduceInt32UDiv) { | 480 TEST(ReduceUint32Div) { |
| 481 ReducerTester R; | 481 ReducerTester R; |
| 482 R.binop = R.machine.Int32UDiv(); | 482 R.binop = R.machine.Uint32Div(); |
| 483 | 483 |
| 484 FOR_UINT32_INPUTS(pl) { | 484 FOR_UINT32_INPUTS(pl) { |
| 485 FOR_UINT32_INPUTS(pr) { | 485 FOR_UINT32_INPUTS(pr) { |
| 486 uint32_t x = *pl, y = *pr; | 486 uint32_t x = *pl, y = *pr; |
| 487 if (y == 0) continue; // TODO(titzer): test / 0 | 487 if (y == 0) continue; // TODO(titzer): test / 0 |
| 488 R.CheckFoldBinop<int32_t>(x / y, x, y); | 488 R.CheckFoldBinop<int32_t>(x / y, x, y); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 | 491 |
| 492 R.CheckDontPutConstantOnRight(41311); | 492 R.CheckDontPutConstantOnRight(41311); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 523 R.CheckDontPutConstantOnRight(-4401); | 523 R.CheckDontPutConstantOnRight(-4401); |
| 524 | 524 |
| 525 Node* x = R.Parameter(); | 525 Node* x = R.Parameter(); |
| 526 Node* one = R.Constant<int32_t>(1); | 526 Node* one = R.Constant<int32_t>(1); |
| 527 | 527 |
| 528 R.CheckFoldBinop<int32_t>(0, x, one); // x % 1 => 0 | 528 R.CheckFoldBinop<int32_t>(0, x, one); // x % 1 => 0 |
| 529 // TODO(titzer): // x % 2^n => x & 2^n-1 and round | 529 // TODO(titzer): // x % 2^n => x & 2^n-1 and round |
| 530 } | 530 } |
| 531 | 531 |
| 532 | 532 |
| 533 TEST(ReduceInt32UMod) { | 533 TEST(ReduceUint32Mod) { |
| 534 ReducerTester R; | 534 ReducerTester R; |
| 535 R.binop = R.machine.Int32UMod(); | 535 R.binop = R.machine.Uint32Mod(); |
| 536 | 536 |
| 537 FOR_INT32_INPUTS(pl) { | 537 FOR_INT32_INPUTS(pl) { |
| 538 FOR_INT32_INPUTS(pr) { | 538 FOR_INT32_INPUTS(pr) { |
| 539 uint32_t x = *pl, y = *pr; | 539 uint32_t x = *pl, y = *pr; |
| 540 if (y == 0) continue; // TODO(titzer): test x % 0 | 540 if (y == 0) continue; // TODO(titzer): test x % 0 |
| 541 R.CheckFoldBinop<int32_t>(x % y, x, y); | 541 R.CheckFoldBinop<int32_t>(x % y, x, y); |
| 542 } | 542 } |
| 543 } | 543 } |
| 544 | 544 |
| 545 R.CheckDontPutConstantOnRight(417); | 545 R.CheckDontPutConstantOnRight(417); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 // TODO(titzer): test MachineOperatorReducer for Word64Shl | 812 // TODO(titzer): test MachineOperatorReducer for Word64Shl |
| 813 // TODO(titzer): test MachineOperatorReducer for Word64Shr | 813 // TODO(titzer): test MachineOperatorReducer for Word64Shr |
| 814 // TODO(titzer): test MachineOperatorReducer for Word64Sar | 814 // TODO(titzer): test MachineOperatorReducer for Word64Sar |
| 815 // TODO(titzer): test MachineOperatorReducer for Word64Equal | 815 // TODO(titzer): test MachineOperatorReducer for Word64Equal |
| 816 // TODO(titzer): test MachineOperatorReducer for Word64Not | 816 // TODO(titzer): test MachineOperatorReducer for Word64Not |
| 817 // TODO(titzer): test MachineOperatorReducer for Int64Add | 817 // TODO(titzer): test MachineOperatorReducer for Int64Add |
| 818 // TODO(titzer): test MachineOperatorReducer for Int64Sub | 818 // TODO(titzer): test MachineOperatorReducer for Int64Sub |
| 819 // TODO(titzer): test MachineOperatorReducer for Int64Mul | 819 // TODO(titzer): test MachineOperatorReducer for Int64Mul |
| 820 // TODO(titzer): test MachineOperatorReducer for Int64UMul | 820 // TODO(titzer): test MachineOperatorReducer for Int64UMul |
| 821 // TODO(titzer): test MachineOperatorReducer for Int64Div | 821 // TODO(titzer): test MachineOperatorReducer for Int64Div |
| 822 // TODO(titzer): test MachineOperatorReducer for Int64UDiv | 822 // TODO(titzer): test MachineOperatorReducer for Uint64Div |
| 823 // TODO(titzer): test MachineOperatorReducer for Int64Mod | 823 // TODO(titzer): test MachineOperatorReducer for Int64Mod |
| 824 // TODO(titzer): test MachineOperatorReducer for Int64UMod | 824 // TODO(titzer): test MachineOperatorReducer for Uint64Mod |
| 825 // TODO(titzer): test MachineOperatorReducer for Int64Neg | 825 // TODO(titzer): test MachineOperatorReducer for Int64Neg |
| 826 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 | 826 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 |
| 827 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 | 827 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 |
| 828 // TODO(titzer): test MachineOperatorReducer for Float64Compare | 828 // TODO(titzer): test MachineOperatorReducer for Float64Compare |
| OLD | NEW |