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

Side by Side Diff: test/unittests/compiler/js-builtin-reducer-unittest.cc

Issue 704463004: [turbofan] Turn various diamonds into selects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix cctest. 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 | Annotate | Revision Log
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/compiler/js-builtin-reducer.h" 5 #include "src/compiler/js-builtin-reducer.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/node-properties-inl.h" 7 #include "src/compiler/node-properties-inl.h"
8 #include "src/compiler/typer.h" 8 #include "src/compiler/typer.h"
9 #include "test/unittests/compiler/graph-unittest.h" 9 #include "test/unittests/compiler/graph-unittest.h"
10 #include "test/unittests/compiler/node-test-utils.h" 10 #include "test/unittests/compiler/node-test-utils.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), 81 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS),
82 fun, UndefinedConstant(), p0); 82 fun, UndefinedConstant(), p0);
83 Reduction r = Reduce(call); 83 Reduction r = Reduce(call);
84 84
85 if (t0->Is(Type::Unsigned32())) { 85 if (t0->Is(Type::Unsigned32())) {
86 ASSERT_TRUE(r.Changed()); 86 ASSERT_TRUE(r.Changed());
87 EXPECT_THAT(r.replacement(), p0); 87 EXPECT_THAT(r.replacement(), p0);
88 } else { 88 } else {
89 Capture<Node*> branch; 89 Capture<Node*> branch;
90 ASSERT_TRUE(r.Changed()); 90 ASSERT_TRUE(r.Changed());
91 EXPECT_THAT( 91 EXPECT_THAT(r.replacement(),
92 r.replacement(), 92 IsSelect(kMachNone, IsNumberLessThan(IsNumberConstant(0), p0),
93 IsPhi(kMachNone, p0, IsNumberSubtract(IsNumberConstant(0), p0), 93 p0, IsNumberSubtract(IsNumberConstant(0), p0)));
94 IsMerge(IsIfTrue(CaptureEq(&branch)),
95 IsIfFalse(AllOf(
96 CaptureEq(&branch),
97 IsBranch(IsNumberLessThan(IsNumberConstant(0), p0),
98 graph()->start()))))));
99 } 94 }
100 } 95 }
101 } 96 }
102 97
103 98
104 // ----------------------------------------------------------------------------- 99 // -----------------------------------------------------------------------------
105 // Math.sqrt 100 // Math.sqrt
106 101
107 102
108 TEST_F(JSBuiltinReducerTest, MathSqrt) { 103 TEST_F(JSBuiltinReducerTest, MathSqrt) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 TRACED_FOREACH(Type*, t1, kNumberTypes) { 159 TRACED_FOREACH(Type*, t1, kNumberTypes) {
165 Node* p0 = Parameter(t0, 0); 160 Node* p0 = Parameter(t0, 0);
166 Node* p1 = Parameter(t1, 1); 161 Node* p1 = Parameter(t1, 1);
167 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); 162 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
168 Node* call = graph()->NewNode( 163 Node* call = graph()->NewNode(
169 javascript()->CallFunction(4, NO_CALL_FUNCTION_FLAGS), fun, 164 javascript()->CallFunction(4, NO_CALL_FUNCTION_FLAGS), fun,
170 UndefinedConstant(), p0, p1); 165 UndefinedConstant(), p0, p1);
171 Reduction r = Reduce(call); 166 Reduction r = Reduce(call);
172 167
173 if (t0->Is(Type::Integral32()) && t1->Is(Type::Integral32())) { 168 if (t0->Is(Type::Integral32()) && t1->Is(Type::Integral32())) {
174 Capture<Node*> branch;
175 ASSERT_TRUE(r.Changed()); 169 ASSERT_TRUE(r.Changed());
176 EXPECT_THAT( 170 EXPECT_THAT(r.replacement(),
177 r.replacement(), 171 IsSelect(kMachNone, IsNumberLessThan(p1, p0), p1, p0));
178 IsPhi(kMachNone, p1, p0,
179 IsMerge(IsIfTrue(CaptureEq(&branch)),
180 IsIfFalse(AllOf(CaptureEq(&branch),
181 IsBranch(IsNumberLessThan(p0, p1),
182 graph()->start()))))));
183 } else { 172 } else {
184 ASSERT_FALSE(r.Changed()); 173 ASSERT_FALSE(r.Changed());
185 EXPECT_EQ(IrOpcode::kJSCallFunction, call->opcode()); 174 EXPECT_EQ(IrOpcode::kJSCallFunction, call->opcode());
186 } 175 }
187 } 176 }
188 } 177 }
189 } 178 }
190 179
191 180
192 // ----------------------------------------------------------------------------- 181 // -----------------------------------------------------------------------------
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), 296 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS),
308 fun, UndefinedConstant(), p0); 297 fun, UndefinedConstant(), p0);
309 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags); 298 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags);
310 299
311 ASSERT_FALSE(r.Changed()); 300 ASSERT_FALSE(r.Changed());
312 } 301 }
313 } 302 }
314 } // namespace compiler 303 } // namespace compiler
315 } // namespace internal 304 } // namespace internal
316 } // namespace v8 305 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/change-lowering-unittest.cc ('k') | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698