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 "src/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
7 #include "src/compiler/node.h" | 7 #include "src/compiler/node.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
10 #include "test/unittests/compiler/graph-reducer-unittest.h" | 10 #include "test/unittests/compiler/graph-reducer-unittest.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 const Operator kMockOpControl(IrOpcode::kDead, Operator::kNoProperties, | 283 const Operator kMockOpControl(IrOpcode::kDead, Operator::kNoProperties, |
284 "MockOpControl", 0, 0, 1, 1, 0, 1); | 284 "MockOpControl", 0, 0, 1, 1, 0, 1); |
285 | 285 |
286 } // namespace | 286 } // namespace |
287 | 287 |
288 | 288 |
289 TEST_F(AdvancedReducerTest, ReplaceWithValue_ValueUse) { | 289 TEST_F(AdvancedReducerTest, ReplaceWithValue_ValueUse) { |
290 CommonOperatorBuilder common(zone()); | 290 CommonOperatorBuilder common(zone()); |
291 Node* node = graph()->NewNode(&kMockOperator); | 291 Node* node = graph()->NewNode(&kMockOperator); |
292 Node* start = graph()->NewNode(common.Start(1)); | 292 Node* start = graph()->NewNode(common.Start(1)); |
293 Node* zero = graph()->NewNode(common.Int32Constant(0)); | 293 Node* use_value = graph()->NewNode(common.Return(), node, start, start); |
294 Node* use_value = graph()->NewNode(common.Return(), zero, node, start, start); | |
295 Node* replacement = graph()->NewNode(&kMockOperator); | 294 Node* replacement = graph()->NewNode(&kMockOperator); |
296 GraphReducer graph_reducer(zone(), graph(), nullptr); | 295 GraphReducer graph_reducer(zone(), graph(), nullptr); |
297 ReplaceWithValueReducer r(&graph_reducer); | 296 ReplaceWithValueReducer r(&graph_reducer); |
298 r.ReplaceWithValue(node, replacement); | 297 r.ReplaceWithValue(node, replacement); |
299 EXPECT_EQ(replacement, use_value->InputAt(1)); | 298 EXPECT_EQ(replacement, use_value->InputAt(0)); |
300 EXPECT_EQ(0, node->UseCount()); | 299 EXPECT_EQ(0, node->UseCount()); |
301 EXPECT_EQ(1, replacement->UseCount()); | 300 EXPECT_EQ(1, replacement->UseCount()); |
302 EXPECT_THAT(replacement->uses(), ElementsAre(use_value)); | 301 EXPECT_THAT(replacement->uses(), ElementsAre(use_value)); |
303 } | 302 } |
304 | 303 |
305 | 304 |
306 TEST_F(AdvancedReducerTest, ReplaceWithValue_EffectUse) { | 305 TEST_F(AdvancedReducerTest, ReplaceWithValue_EffectUse) { |
307 CommonOperatorBuilder common(zone()); | 306 CommonOperatorBuilder common(zone()); |
308 Node* start = graph()->NewNode(common.Start(1)); | 307 Node* start = graph()->NewNode(common.Start(1)); |
309 Node* node = graph()->NewNode(&kMockOpEffect, start); | 308 Node* node = graph()->NewNode(&kMockOpEffect, start); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 EXPECT_EQ(&kOpC0, n1->op()); | 850 EXPECT_EQ(&kOpC0, n1->op()); |
852 EXPECT_EQ(&kOpC1, end->op()); | 851 EXPECT_EQ(&kOpC1, end->op()); |
853 EXPECT_EQ(n1, end->InputAt(0)); | 852 EXPECT_EQ(n1, end->InputAt(0)); |
854 } | 853 } |
855 } | 854 } |
856 } | 855 } |
857 | 856 |
858 } // namespace compiler | 857 } // namespace compiler |
859 } // namespace internal | 858 } // namespace internal |
860 } // namespace v8 | 859 } // namespace v8 |
OLD | NEW |