| 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/common-operator-reducer.h" | 6 #include "src/compiler/common-operator-reducer.h" |
| 7 #include "src/compiler/js-graph.h" | |
| 8 #include "src/compiler/js-operator.h" | 7 #include "src/compiler/js-operator.h" |
| 9 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
| 10 #include "src/compiler/machine-type.h" | 9 #include "src/compiler/machine-type.h" |
| 11 #include "src/compiler/operator.h" | 10 #include "src/compiler/operator.h" |
| 11 #include "test/unittests/compiler/graph-reducer-unittest.h" |
| 12 #include "test/unittests/compiler/graph-unittest.h" | 12 #include "test/unittests/compiler/graph-unittest.h" |
| 13 #include "test/unittests/compiler/node-test-utils.h" | 13 #include "test/unittests/compiler/node-test-utils.h" |
| 14 | 14 |
| 15 using testing::StrictMock; |
| 16 |
| 15 namespace v8 { | 17 namespace v8 { |
| 16 namespace internal { | 18 namespace internal { |
| 17 namespace compiler { | 19 namespace compiler { |
| 18 | 20 |
| 19 class CommonOperatorReducerTest : public GraphTest { | 21 class CommonOperatorReducerTest : public GraphTest { |
| 20 public: | 22 public: |
| 21 explicit CommonOperatorReducerTest(int num_parameters = 1) | 23 explicit CommonOperatorReducerTest(int num_parameters = 1) |
| 22 : GraphTest(num_parameters), machine_(zone()) {} | 24 : GraphTest(num_parameters), machine_(zone()) {} |
| 23 ~CommonOperatorReducerTest() override {} | 25 ~CommonOperatorReducerTest() override {} |
| 24 | 26 |
| 25 protected: | 27 protected: |
| 28 Reduction Reduce( |
| 29 AdvancedReducer::Editor* editor, Node* node, |
| 30 MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags) { |
| 31 JSOperatorBuilder javascript(zone()); |
| 32 MachineOperatorBuilder machine(zone(), kMachPtr, flags); |
| 33 CommonOperatorReducer reducer(editor, graph(), common(), &machine); |
| 34 return reducer.Reduce(node); |
| 35 } |
| 36 |
| 26 Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = | 37 Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = |
| 27 MachineOperatorBuilder::kNoFlags) { | 38 MachineOperatorBuilder::kNoFlags) { |
| 28 JSOperatorBuilder javascript(zone()); | 39 StrictMock<MockAdvancedReducerEditor> editor; |
| 29 MachineOperatorBuilder machine(zone(), kMachPtr, flags); | 40 return Reduce(&editor, node, flags); |
| 30 JSGraph jsgraph(isolate(), graph(), common(), &javascript, &machine); | |
| 31 CommonOperatorReducer reducer(&jsgraph); | |
| 32 return reducer.Reduce(node); | |
| 33 } | 41 } |
| 34 | 42 |
| 35 MachineOperatorBuilder* machine() { return &machine_; } | 43 MachineOperatorBuilder* machine() { return &machine_; } |
| 36 | 44 |
| 37 private: | 45 private: |
| 38 MachineOperatorBuilder machine_; | 46 MachineOperatorBuilder machine_; |
| 39 }; | 47 }; |
| 40 | 48 |
| 41 | 49 |
| 42 namespace { | 50 namespace { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 54 | 62 |
| 55 const Operator kOp0(0, Operator::kNoProperties, "Op0", 0, 0, 0, 1, 1, 0); | 63 const Operator kOp0(0, Operator::kNoProperties, "Op0", 0, 0, 0, 1, 1, 0); |
| 56 | 64 |
| 57 } // namespace | 65 } // namespace |
| 58 | 66 |
| 59 | 67 |
| 60 // ----------------------------------------------------------------------------- | 68 // ----------------------------------------------------------------------------- |
| 61 // EffectPhi | 69 // EffectPhi |
| 62 | 70 |
| 63 | 71 |
| 64 TEST_F(CommonOperatorReducerTest, RedundantEffectPhi) { | 72 TEST_F(CommonOperatorReducerTest, EffectPhiWithMerge) { |
| 65 const int kMaxInputs = 64; | 73 const int kMaxInputs = 64; |
| 66 Node* inputs[kMaxInputs]; | 74 Node* inputs[kMaxInputs]; |
| 67 Node* const input = graph()->NewNode(&kOp0); | 75 Node* const input = graph()->NewNode(&kOp0); |
| 68 TRACED_FORRANGE(int, input_count, 2, kMaxInputs - 1) { | 76 TRACED_FORRANGE(int, input_count, 2, kMaxInputs - 1) { |
| 69 int const value_input_count = input_count - 1; | 77 int const value_input_count = input_count - 1; |
| 70 for (int i = 0; i < value_input_count; ++i) { | 78 for (int i = 0; i < value_input_count; ++i) { |
| 79 inputs[i] = graph()->start(); |
| 80 } |
| 81 Node* const merge = graph()->NewNode(common()->Merge(value_input_count), |
| 82 value_input_count, inputs); |
| 83 for (int i = 0; i < value_input_count; ++i) { |
| 71 inputs[i] = input; | 84 inputs[i] = input; |
| 72 } | 85 } |
| 73 inputs[value_input_count] = graph()->start(); | 86 inputs[value_input_count] = merge; |
| 74 Reduction r = Reduce(graph()->NewNode( | 87 StrictMock<MockAdvancedReducerEditor> editor; |
| 75 common()->EffectPhi(value_input_count), input_count, inputs)); | 88 EXPECT_CALL(editor, Revisit(merge)); |
| 89 Reduction r = |
| 90 Reduce(&editor, graph()->NewNode(common()->EffectPhi(value_input_count), |
| 91 input_count, inputs)); |
| 76 ASSERT_TRUE(r.Changed()); | 92 ASSERT_TRUE(r.Changed()); |
| 77 EXPECT_EQ(input, r.replacement()); | 93 EXPECT_EQ(input, r.replacement()); |
| 78 } | 94 } |
| 79 } | 95 } |
| 80 | 96 |
| 81 | 97 |
| 98 TEST_F(CommonOperatorReducerTest, EffectPhiWithLoop) { |
| 99 Node* const e0 = graph()->NewNode(&kOp0); |
| 100 Node* const loop = |
| 101 graph()->NewNode(common()->Loop(2), graph()->start(), graph()->start()); |
| 102 loop->ReplaceInput(1, loop); |
| 103 Node* const ephi = graph()->NewNode(common()->EffectPhi(2), e0, e0, loop); |
| 104 ephi->ReplaceInput(1, ephi); |
| 105 StrictMock<MockAdvancedReducerEditor> editor; |
| 106 EXPECT_CALL(editor, Revisit(loop)); |
| 107 Reduction const r = Reduce(&editor, ephi); |
| 108 ASSERT_TRUE(r.Changed()); |
| 109 EXPECT_EQ(e0, r.replacement()); |
| 110 } |
| 111 |
| 112 |
| 82 // ----------------------------------------------------------------------------- | 113 // ----------------------------------------------------------------------------- |
| 83 // Phi | 114 // Phi |
| 84 | 115 |
| 85 | 116 |
| 86 TEST_F(CommonOperatorReducerTest, RedundantPhi) { | 117 TEST_F(CommonOperatorReducerTest, PhiWithMerge) { |
| 87 const int kMaxInputs = 64; | 118 const int kMaxInputs = 64; |
| 88 Node* inputs[kMaxInputs]; | 119 Node* inputs[kMaxInputs]; |
| 89 Node* const input = graph()->NewNode(&kOp0); | 120 Node* const input = graph()->NewNode(&kOp0); |
| 90 TRACED_FORRANGE(int, input_count, 2, kMaxInputs - 1) { | 121 TRACED_FORRANGE(int, input_count, 2, kMaxInputs - 1) { |
| 91 int const value_input_count = input_count - 1; | 122 int const value_input_count = input_count - 1; |
| 92 TRACED_FOREACH(MachineType, type, kMachineTypes) { | 123 TRACED_FOREACH(MachineType, type, kMachineTypes) { |
| 93 for (int i = 0; i < value_input_count; ++i) { | 124 for (int i = 0; i < value_input_count; ++i) { |
| 94 inputs[i] = graph()->start(); | 125 inputs[i] = graph()->start(); |
| 95 } | 126 } |
| 96 Node* merge = graph()->NewNode(common()->Merge(value_input_count), | 127 Node* const merge = graph()->NewNode(common()->Merge(value_input_count), |
| 97 value_input_count, inputs); | 128 value_input_count, inputs); |
| 98 for (int i = 0; i < value_input_count; ++i) { | 129 for (int i = 0; i < value_input_count; ++i) { |
| 99 inputs[i] = input; | 130 inputs[i] = input; |
| 100 } | 131 } |
| 101 inputs[value_input_count] = merge; | 132 inputs[value_input_count] = merge; |
| 102 Reduction r = Reduce(graph()->NewNode( | 133 StrictMock<MockAdvancedReducerEditor> editor; |
| 103 common()->Phi(type, value_input_count), input_count, inputs)); | 134 EXPECT_CALL(editor, Revisit(merge)); |
| 135 Reduction r = Reduce( |
| 136 &editor, graph()->NewNode(common()->Phi(type, value_input_count), |
| 137 input_count, inputs)); |
| 104 ASSERT_TRUE(r.Changed()); | 138 ASSERT_TRUE(r.Changed()); |
| 105 EXPECT_EQ(input, r.replacement()); | 139 EXPECT_EQ(input, r.replacement()); |
| 106 } | 140 } |
| 107 } | 141 } |
| 108 } | 142 } |
| 109 | 143 |
| 110 | 144 |
| 145 TEST_F(CommonOperatorReducerTest, PhiWithLoop) { |
| 146 Node* const p0 = Parameter(0); |
| 147 Node* const loop = |
| 148 graph()->NewNode(common()->Loop(2), graph()->start(), graph()->start()); |
| 149 loop->ReplaceInput(1, loop); |
| 150 Node* const phi = |
| 151 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); |
| 152 phi->ReplaceInput(1, phi); |
| 153 StrictMock<MockAdvancedReducerEditor> editor; |
| 154 EXPECT_CALL(editor, Revisit(loop)); |
| 155 Reduction const r = Reduce(&editor, phi); |
| 156 ASSERT_TRUE(r.Changed()); |
| 157 EXPECT_EQ(p0, r.replacement()); |
| 158 } |
| 159 |
| 160 |
| 111 TEST_F(CommonOperatorReducerTest, PhiToFloat32Abs) { | 161 TEST_F(CommonOperatorReducerTest, PhiToFloat32Abs) { |
| 112 Node* p0 = Parameter(0); | 162 Node* p0 = Parameter(0); |
| 113 Node* c0 = Float32Constant(0.0); | 163 Node* c0 = Float32Constant(0.0); |
| 114 Node* check = graph()->NewNode(machine()->Float32LessThan(), c0, p0); | 164 Node* check = graph()->NewNode(machine()->Float32LessThan(), c0, p0); |
| 115 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); | 165 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
| 116 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 166 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 117 Node* vtrue = p0; | 167 Node* vtrue = p0; |
| 118 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 168 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 119 Node* vfalse = graph()->NewNode(machine()->Float32Sub(), c0, p0); | 169 Node* vfalse = graph()->NewNode(machine()->Float32Sub(), c0, p0); |
| 120 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 170 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 121 Node* phi = | 171 Node* phi = |
| 122 graph()->NewNode(common()->Phi(kMachFloat32, 2), vtrue, vfalse, merge); | 172 graph()->NewNode(common()->Phi(kMachFloat32, 2), vtrue, vfalse, merge); |
| 123 Reduction r = Reduce(phi); | 173 StrictMock<MockAdvancedReducerEditor> editor; |
| 174 EXPECT_CALL(editor, Revisit(merge)); |
| 175 Reduction r = Reduce(&editor, phi); |
| 124 ASSERT_TRUE(r.Changed()); | 176 ASSERT_TRUE(r.Changed()); |
| 125 EXPECT_THAT(r.replacement(), IsFloat32Abs(p0)); | 177 EXPECT_THAT(r.replacement(), IsFloat32Abs(p0)); |
| 126 } | 178 } |
| 127 | 179 |
| 128 | 180 |
| 129 TEST_F(CommonOperatorReducerTest, PhiToFloat64Abs) { | 181 TEST_F(CommonOperatorReducerTest, PhiToFloat64Abs) { |
| 130 Node* p0 = Parameter(0); | 182 Node* p0 = Parameter(0); |
| 131 Node* c0 = Float64Constant(0.0); | 183 Node* c0 = Float64Constant(0.0); |
| 132 Node* check = graph()->NewNode(machine()->Float64LessThan(), c0, p0); | 184 Node* check = graph()->NewNode(machine()->Float64LessThan(), c0, p0); |
| 133 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); | 185 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
| 134 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 186 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 135 Node* vtrue = p0; | 187 Node* vtrue = p0; |
| 136 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 188 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 137 Node* vfalse = graph()->NewNode(machine()->Float64Sub(), c0, p0); | 189 Node* vfalse = graph()->NewNode(machine()->Float64Sub(), c0, p0); |
| 138 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 190 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 139 Node* phi = | 191 Node* phi = |
| 140 graph()->NewNode(common()->Phi(kMachFloat64, 2), vtrue, vfalse, merge); | 192 graph()->NewNode(common()->Phi(kMachFloat64, 2), vtrue, vfalse, merge); |
| 141 Reduction r = Reduce(phi); | 193 StrictMock<MockAdvancedReducerEditor> editor; |
| 194 EXPECT_CALL(editor, Revisit(merge)); |
| 195 Reduction r = Reduce(&editor, phi); |
| 142 ASSERT_TRUE(r.Changed()); | 196 ASSERT_TRUE(r.Changed()); |
| 143 EXPECT_THAT(r.replacement(), IsFloat64Abs(p0)); | 197 EXPECT_THAT(r.replacement(), IsFloat64Abs(p0)); |
| 144 } | 198 } |
| 145 | 199 |
| 146 | 200 |
| 147 TEST_F(CommonOperatorReducerTest, PhiToFloat32Max) { | 201 TEST_F(CommonOperatorReducerTest, PhiToFloat32Max) { |
| 148 Node* p0 = Parameter(0); | 202 Node* p0 = Parameter(0); |
| 149 Node* p1 = Parameter(1); | 203 Node* p1 = Parameter(1); |
| 150 Node* check = graph()->NewNode(machine()->Float32LessThan(), p0, p1); | 204 Node* check = graph()->NewNode(machine()->Float32LessThan(), p0, p1); |
| 151 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); | 205 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
| 152 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 206 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 153 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 207 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 154 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 208 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 155 Node* phi = graph()->NewNode(common()->Phi(kMachFloat32, 2), p1, p0, merge); | 209 Node* phi = graph()->NewNode(common()->Phi(kMachFloat32, 2), p1, p0, merge); |
| 156 Reduction r = Reduce(phi, MachineOperatorBuilder::kFloat32Max); | 210 StrictMock<MockAdvancedReducerEditor> editor; |
| 211 EXPECT_CALL(editor, Revisit(merge)); |
| 212 Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat32Max); |
| 157 ASSERT_TRUE(r.Changed()); | 213 ASSERT_TRUE(r.Changed()); |
| 158 EXPECT_THAT(r.replacement(), IsFloat32Max(p1, p0)); | 214 EXPECT_THAT(r.replacement(), IsFloat32Max(p1, p0)); |
| 159 } | 215 } |
| 160 | 216 |
| 161 | 217 |
| 162 TEST_F(CommonOperatorReducerTest, PhiToFloat64Max) { | 218 TEST_F(CommonOperatorReducerTest, PhiToFloat64Max) { |
| 163 Node* p0 = Parameter(0); | 219 Node* p0 = Parameter(0); |
| 164 Node* p1 = Parameter(1); | 220 Node* p1 = Parameter(1); |
| 165 Node* check = graph()->NewNode(machine()->Float64LessThan(), p0, p1); | 221 Node* check = graph()->NewNode(machine()->Float64LessThan(), p0, p1); |
| 166 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); | 222 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
| 167 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 223 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 168 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 224 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 169 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 225 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 170 Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p1, p0, merge); | 226 Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p1, p0, merge); |
| 171 Reduction r = Reduce(phi, MachineOperatorBuilder::kFloat64Max); | 227 StrictMock<MockAdvancedReducerEditor> editor; |
| 228 EXPECT_CALL(editor, Revisit(merge)); |
| 229 Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat64Max); |
| 172 ASSERT_TRUE(r.Changed()); | 230 ASSERT_TRUE(r.Changed()); |
| 173 EXPECT_THAT(r.replacement(), IsFloat64Max(p1, p0)); | 231 EXPECT_THAT(r.replacement(), IsFloat64Max(p1, p0)); |
| 174 } | 232 } |
| 175 | 233 |
| 176 | 234 |
| 177 TEST_F(CommonOperatorReducerTest, PhiToFloat32Min) { | 235 TEST_F(CommonOperatorReducerTest, PhiToFloat32Min) { |
| 178 Node* p0 = Parameter(0); | 236 Node* p0 = Parameter(0); |
| 179 Node* p1 = Parameter(1); | 237 Node* p1 = Parameter(1); |
| 180 Node* check = graph()->NewNode(machine()->Float32LessThan(), p0, p1); | 238 Node* check = graph()->NewNode(machine()->Float32LessThan(), p0, p1); |
| 181 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); | 239 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
| 182 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 240 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 183 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 241 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 184 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 242 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 185 Node* phi = graph()->NewNode(common()->Phi(kMachFloat32, 2), p0, p1, merge); | 243 Node* phi = graph()->NewNode(common()->Phi(kMachFloat32, 2), p0, p1, merge); |
| 186 Reduction r = Reduce(phi, MachineOperatorBuilder::kFloat32Min); | 244 StrictMock<MockAdvancedReducerEditor> editor; |
| 245 EXPECT_CALL(editor, Revisit(merge)); |
| 246 Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat32Min); |
| 187 ASSERT_TRUE(r.Changed()); | 247 ASSERT_TRUE(r.Changed()); |
| 188 EXPECT_THAT(r.replacement(), IsFloat32Min(p0, p1)); | 248 EXPECT_THAT(r.replacement(), IsFloat32Min(p0, p1)); |
| 189 } | 249 } |
| 190 | 250 |
| 191 | 251 |
| 192 TEST_F(CommonOperatorReducerTest, PhiToFloat64Min) { | 252 TEST_F(CommonOperatorReducerTest, PhiToFloat64Min) { |
| 193 Node* p0 = Parameter(0); | 253 Node* p0 = Parameter(0); |
| 194 Node* p1 = Parameter(1); | 254 Node* p1 = Parameter(1); |
| 195 Node* check = graph()->NewNode(machine()->Float64LessThan(), p0, p1); | 255 Node* check = graph()->NewNode(machine()->Float64LessThan(), p0, p1); |
| 196 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); | 256 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
| 197 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 257 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 198 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 258 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 199 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 259 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 200 Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p1, merge); | 260 Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p1, merge); |
| 201 Reduction r = Reduce(phi, MachineOperatorBuilder::kFloat64Min); | 261 StrictMock<MockAdvancedReducerEditor> editor; |
| 262 EXPECT_CALL(editor, Revisit(merge)); |
| 263 Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat64Min); |
| 202 ASSERT_TRUE(r.Changed()); | 264 ASSERT_TRUE(r.Changed()); |
| 203 EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1)); | 265 EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1)); |
| 204 } | 266 } |
| 205 | 267 |
| 206 | 268 |
| 207 // ----------------------------------------------------------------------------- | 269 // ----------------------------------------------------------------------------- |
| 208 // Select | 270 // Select |
| 209 | 271 |
| 210 | 272 |
| 211 TEST_F(CommonOperatorReducerTest, RedundantSelect) { | 273 TEST_F(CommonOperatorReducerTest, SelectWithSameThenAndElse) { |
| 212 Node* const input = graph()->NewNode(&kOp0); | 274 Node* const input = graph()->NewNode(&kOp0); |
| 213 TRACED_FOREACH(BranchHint, hint, kBranchHints) { | 275 TRACED_FOREACH(BranchHint, hint, kBranchHints) { |
| 214 TRACED_FOREACH(MachineType, type, kMachineTypes) { | 276 TRACED_FOREACH(MachineType, type, kMachineTypes) { |
| 215 Reduction r = Reduce( | 277 Reduction r = Reduce( |
| 216 graph()->NewNode(common()->Select(type, hint), input, input, input)); | 278 graph()->NewNode(common()->Select(type, hint), input, input, input)); |
| 217 ASSERT_TRUE(r.Changed()); | 279 ASSERT_TRUE(r.Changed()); |
| 218 EXPECT_EQ(input, r.replacement()); | 280 EXPECT_EQ(input, r.replacement()); |
| 219 } | 281 } |
| 220 } | 282 } |
| 221 } | 283 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 Node* select = | 374 Node* select = |
| 313 graph()->NewNode(common()->Select(kMachFloat64), check, p0, p1); | 375 graph()->NewNode(common()->Select(kMachFloat64), check, p0, p1); |
| 314 Reduction r = Reduce(select, MachineOperatorBuilder::kFloat64Min); | 376 Reduction r = Reduce(select, MachineOperatorBuilder::kFloat64Min); |
| 315 ASSERT_TRUE(r.Changed()); | 377 ASSERT_TRUE(r.Changed()); |
| 316 EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1)); | 378 EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1)); |
| 317 } | 379 } |
| 318 | 380 |
| 319 } // namespace compiler | 381 } // namespace compiler |
| 320 } // namespace internal | 382 } // namespace internal |
| 321 } // namespace v8 | 383 } // namespace v8 |
| OLD | NEW |