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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-machine-operator-reducer.cc
diff --git a/test/cctest/compiler/test-machine-operator-reducer.cc b/test/cctest/compiler/test-machine-operator-reducer.cc
index ec14cd2467fc757d72791a1646662c79dcf609bb..b538fb7ff5fa00bd70e1b7580bb3fc655953b28a 100644
--- a/test/cctest/compiler/test-machine-operator-reducer.cc
+++ b/test/cctest/compiler/test-machine-operator-reducer.cc
@@ -52,11 +52,13 @@ double ValueOfOperator<double>(const Operator* op) {
class ReducerTester : public HandleAndZoneScope {
public:
- explicit ReducerTester(int num_parameters = 0)
+ explicit ReducerTester(
+ int num_parameters = 0,
+ MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags)
: isolate(main_isolate()),
binop(NULL),
unop(NULL),
- machine(main_zone()),
+ machine(main_zone(), kMachPtr, flags),
common(main_zone()),
graph(main_zone()),
javascript(main_zone()),
@@ -358,7 +360,36 @@ TEST(ReduceWord32Sar) {
}
-TEST(ReduceWord32Equal) {
+static void CheckJsShift(ReducerTester* R) {
+ DCHECK(R->machine.Word32ShiftIsSafe());
+
+ Node* x = R->Parameter(0);
+ Node* y = R->Parameter(1);
+ Node* thirty_one = R->Constant<int32_t>(0x1f);
+ Node* y_and_thirty_one =
+ R->graph.NewNode(R->machine.Word32And(), y, thirty_one);
+
+ // If the underlying machine shift instructions 'and' their right operand
+ // with 0x1f then: x << (y & 0x1f) => x << y
+ R->CheckFoldBinop(x, y, x, y_and_thirty_one);
+}
+
+
+TEST(ReduceJsShifts) {
+ ReducerTester R(0, MachineOperatorBuilder::kWord32ShiftIsSafe);
+
+ R.binop = R.machine.Word32Shl();
+ CheckJsShift(&R);
+
+ R.binop = R.machine.Word32Shr();
+ CheckJsShift(&R);
+
+ R.binop = R.machine.Word32Sar();
+ CheckJsShift(&R);
+}
+
+
+TEST(Word32Equal) {
ReducerTester R;
R.binop = R.machine.Word32Equal();
« 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