| 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* use_value = graph()->NewNode(common.Return(), node, start, start); | 293 Node* zero = graph()->NewNode(common.Int32Constant(0)); |
| 294 Node* use_value = graph()->NewNode(common.Return(), zero, node, start, start); |
| 294 Node* replacement = graph()->NewNode(&kMockOperator); | 295 Node* replacement = graph()->NewNode(&kMockOperator); |
| 295 GraphReducer graph_reducer(zone(), graph(), nullptr); | 296 GraphReducer graph_reducer(zone(), graph(), nullptr); |
| 296 ReplaceWithValueReducer r(&graph_reducer); | 297 ReplaceWithValueReducer r(&graph_reducer); |
| 297 r.ReplaceWithValue(node, replacement); | 298 r.ReplaceWithValue(node, replacement); |
| 298 EXPECT_EQ(replacement, use_value->InputAt(0)); | 299 EXPECT_EQ(replacement, use_value->InputAt(1)); |
| 299 EXPECT_EQ(0, node->UseCount()); | 300 EXPECT_EQ(0, node->UseCount()); |
| 300 EXPECT_EQ(1, replacement->UseCount()); | 301 EXPECT_EQ(1, replacement->UseCount()); |
| 301 EXPECT_THAT(replacement->uses(), ElementsAre(use_value)); | 302 EXPECT_THAT(replacement->uses(), ElementsAre(use_value)); |
| 302 } | 303 } |
| 303 | 304 |
| 304 | 305 |
| 305 TEST_F(AdvancedReducerTest, ReplaceWithValue_EffectUse) { | 306 TEST_F(AdvancedReducerTest, ReplaceWithValue_EffectUse) { |
| 306 CommonOperatorBuilder common(zone()); | 307 CommonOperatorBuilder common(zone()); |
| 307 Node* start = graph()->NewNode(common.Start(1)); | 308 Node* start = graph()->NewNode(common.Start(1)); |
| 308 Node* node = graph()->NewNode(&kMockOpEffect, start); | 309 Node* node = graph()->NewNode(&kMockOpEffect, start); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 EXPECT_EQ(&kOpC0, n1->op()); | 851 EXPECT_EQ(&kOpC0, n1->op()); |
| 851 EXPECT_EQ(&kOpC1, end->op()); | 852 EXPECT_EQ(&kOpC1, end->op()); |
| 852 EXPECT_EQ(n1, end->InputAt(0)); | 853 EXPECT_EQ(n1, end->InputAt(0)); |
| 853 } | 854 } |
| 854 } | 855 } |
| 855 } | 856 } |
| 856 | 857 |
| 857 } // namespace compiler | 858 } // namespace compiler |
| 858 } // namespace internal | 859 } // namespace internal |
| 859 } // namespace v8 | 860 } // namespace v8 |
| OLD | NEW |