Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/simd-scalar-lowering.h" | 5 #include "src/compiler/simd-scalar-lowering.h" |
| 6 #include "src/compiler/diamond.h" | 6 #include "src/compiler/diamond.h" |
| 7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 | 10 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 Signature<MachineRepresentation>* signature) { | 192 Signature<MachineRepresentation>* signature) { |
| 193 int result = static_cast<int>(signature->return_count()); | 193 int result = static_cast<int>(signature->return_count()); |
| 194 for (int i = 0; i < static_cast<int>(signature->return_count()); ++i) { | 194 for (int i = 0; i < static_cast<int>(signature->return_count()); ++i) { |
| 195 if (signature->GetReturn(i) == MachineRepresentation::kSimd128) { | 195 if (signature->GetReturn(i) == MachineRepresentation::kSimd128) { |
| 196 result += 3; | 196 result += 3; |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 return result; | 199 return result; |
| 200 } | 200 } |
| 201 | 201 |
| 202 constexpr int SimdScalarLowering::kLaneOffsets[]; | |
| 203 | |
| 202 void SimdScalarLowering::GetIndexNodes(Node* index, Node** new_indices) { | 204 void SimdScalarLowering::GetIndexNodes(Node* index, Node** new_indices) { |
| 203 new_indices[0] = index; | 205 int laneIndex = kLaneOffsets[0]; |
| 206 new_indices[laneIndex] = index; | |
| 204 for (size_t i = 1; i < kMaxLanes; ++i) { | 207 for (size_t i = 1; i < kMaxLanes; ++i) { |
| 205 new_indices[i] = graph()->NewNode(machine()->Int32Add(), index, | 208 laneIndex = kLaneOffsets[i]; |
| 206 graph()->NewNode(common()->Int32Constant( | 209 new_indices[laneIndex] = graph()->NewNode( |
| 207 static_cast<int>(i) * kLaneWidth))); | 210 machine()->Int32Add(), index, |
| 211 graph()->NewNode( | |
| 212 common()->Int32Constant(static_cast<int>(i) * kLaneWidth))); | |
| 208 } | 213 } |
| 209 } | 214 } |
| 210 | 215 |
| 211 void SimdScalarLowering::LowerLoadOp(MachineRepresentation rep, Node* node, | 216 void SimdScalarLowering::LowerLoadOp(MachineRepresentation rep, Node* node, |
| 212 const Operator* load_op) { | 217 const Operator* load_op) { |
| 213 if (rep == MachineRepresentation::kSimd128) { | 218 if (rep == MachineRepresentation::kSimd128) { |
| 214 Node* base = node->InputAt(0); | 219 Node* base = node->InputAt(0); |
| 215 Node* index = node->InputAt(1); | 220 Node* index = node->InputAt(1); |
| 216 Node* indices[kMaxLanes]; | 221 Node* indices[kMaxLanes]; |
| 217 GetIndexNodes(index, indices); | 222 GetIndexNodes(index, indices); |
| 218 Node* rep_nodes[kMaxLanes]; | 223 Node* rep_nodes[kMaxLanes]; |
| 219 rep_nodes[0] = node; | 224 rep_nodes[0] = node; |
| 220 NodeProperties::ChangeOp(rep_nodes[0], load_op); | 225 NodeProperties::ChangeOp(rep_nodes[0], load_op); |
| 221 if (node->InputCount() > 2) { | 226 if (node->InputCount() > 2) { |
| 222 DCHECK(node->InputCount() > 3); | 227 DCHECK(node->InputCount() > 3); |
| 223 Node* effect_input = node->InputAt(2); | 228 Node* effect_input = node->InputAt(2); |
| 224 Node* control_input = node->InputAt(3); | 229 Node* control_input = node->InputAt(3); |
| 225 rep_nodes[3] = graph()->NewNode(load_op, base, indices[3], effect_input, | 230 rep_nodes[3] = graph()->NewNode(load_op, base, indices[3], effect_input, |
| 226 control_input); | 231 control_input); |
| 227 rep_nodes[2] = graph()->NewNode(load_op, base, indices[2], rep_nodes[3], | 232 rep_nodes[2] = graph()->NewNode(load_op, base, indices[2], rep_nodes[3], |
| 228 control_input); | 233 control_input); |
| 229 rep_nodes[1] = graph()->NewNode(load_op, base, indices[1], rep_nodes[2], | 234 rep_nodes[1] = graph()->NewNode(load_op, base, indices[1], rep_nodes[2], |
| 230 control_input); | 235 control_input); |
| 231 rep_nodes[0]->ReplaceInput(2, rep_nodes[1]); | 236 rep_nodes[0]->ReplaceInput(2, rep_nodes[1]); |
| 237 rep_nodes[0]->ReplaceInput(1, indices[0]); | |
|
aseemgarg
2017/05/02 21:20:21
This is not correct. The else case (without contro
john.yan
2017/05/03 19:39:40
Hello, do you mean the else case below? I don't un
aseemgarg
2017/05/03 22:04:13
yes the else case below. Since the indices have po
| |
| 232 } else { | 238 } else { |
| 233 for (size_t i = 1; i < kMaxLanes; ++i) { | 239 for (size_t i = 1; i < kMaxLanes; ++i) { |
| 234 rep_nodes[i] = graph()->NewNode(load_op, base, indices[i]); | 240 rep_nodes[i] = graph()->NewNode(load_op, base, indices[i]); |
| 235 } | 241 } |
| 236 } | 242 } |
| 237 ReplaceNode(node, rep_nodes); | 243 ReplaceNode(node, rep_nodes); |
| 238 } else { | 244 } else { |
| 239 DefaultLowering(node); | 245 DefaultLowering(node); |
| 240 } | 246 } |
| 241 } | 247 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 260 DCHECK(node->InputCount() > 4); | 266 DCHECK(node->InputCount() > 4); |
| 261 Node* effect_input = node->InputAt(3); | 267 Node* effect_input = node->InputAt(3); |
| 262 Node* control_input = node->InputAt(4); | 268 Node* control_input = node->InputAt(4); |
| 263 rep_nodes[3] = graph()->NewNode(store_op, base, indices[3], rep_inputs[3], | 269 rep_nodes[3] = graph()->NewNode(store_op, base, indices[3], rep_inputs[3], |
| 264 effect_input, control_input); | 270 effect_input, control_input); |
| 265 rep_nodes[2] = graph()->NewNode(store_op, base, indices[2], rep_inputs[2], | 271 rep_nodes[2] = graph()->NewNode(store_op, base, indices[2], rep_inputs[2], |
| 266 rep_nodes[3], control_input); | 272 rep_nodes[3], control_input); |
| 267 rep_nodes[1] = graph()->NewNode(store_op, base, indices[1], rep_inputs[1], | 273 rep_nodes[1] = graph()->NewNode(store_op, base, indices[1], rep_inputs[1], |
| 268 rep_nodes[2], control_input); | 274 rep_nodes[2], control_input); |
| 269 rep_nodes[0]->ReplaceInput(3, rep_nodes[1]); | 275 rep_nodes[0]->ReplaceInput(3, rep_nodes[1]); |
| 276 rep_nodes[0]->ReplaceInput(1, indices[0]); | |
| 270 | 277 |
| 271 } else { | 278 } else { |
| 272 for (size_t i = 1; i < kMaxLanes; ++i) { | 279 for (size_t i = 1; i < kMaxLanes; ++i) { |
| 273 rep_nodes[i] = | 280 rep_nodes[i] = |
| 274 graph()->NewNode(store_op, base, indices[i], rep_inputs[i]); | 281 graph()->NewNode(store_op, base, indices[i], rep_inputs[i]); |
| 275 } | 282 } |
| 276 } | 283 } |
| 277 | 284 |
| 278 ReplaceNode(node, rep_nodes); | 285 ReplaceNode(node, rep_nodes); |
| 279 } else { | 286 } else { |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 862 } else { | 869 } else { |
| 863 UNREACHABLE(); | 870 UNREACHABLE(); |
| 864 } | 871 } |
| 865 } | 872 } |
| 866 ReplaceNode(phi, rep_nodes); | 873 ReplaceNode(phi, rep_nodes); |
| 867 } | 874 } |
| 868 } | 875 } |
| 869 } // namespace compiler | 876 } // namespace compiler |
| 870 } // namespace internal | 877 } // namespace internal |
| 871 } // namespace v8 | 878 } // namespace v8 |
| OLD | NEW |