Chromium Code Reviews| Index: src/compiler/simd-scalar-lowering.cc |
| diff --git a/src/compiler/simd-scalar-lowering.cc b/src/compiler/simd-scalar-lowering.cc |
| index 87a5e07281f4462d8406edd181bc218dd15e1ff7..3a1970318e02377757f98805f4f72c701e082cc2 100644 |
| --- a/src/compiler/simd-scalar-lowering.cc |
| +++ b/src/compiler/simd-scalar-lowering.cc |
| @@ -75,6 +75,8 @@ void SimdScalarLowering::LowerGraph() { |
| V(Int32x4Splat) \ |
| V(Int32x4ExtractLane) \ |
| V(Int32x4ReplaceLane) \ |
| + V(Int32x4Neg) \ |
| + V(Simd128Not) \ |
| V(Int32x4Add) \ |
| V(Int32x4Sub) \ |
| V(Int32x4Mul) \ |
| @@ -86,12 +88,16 @@ void SimdScalarLowering::LowerGraph() { |
| V(Float32x4Splat) \ |
| V(Float32x4ExtractLane) \ |
| V(Float32x4ReplaceLane) \ |
| + V(Float32x4Abs) \ |
| + V(Float32x4Neg) \ |
| V(Float32x4Add) \ |
| V(Float32x4Sub) \ |
| V(Float32x4Mul) \ |
| V(Float32x4Div) \ |
| V(Float32x4Min) \ |
| - V(Float32x4Max) |
| + V(Float32x4Max) \ |
| + V(Float32x4FromInt32x4) \ |
| + V(Float32x4FromUint32x4) |
| void SimdScalarLowering::SetLoweredType(Node* node, Node* output) { |
| switch (node->opcode()) { |
| @@ -108,8 +114,14 @@ void SimdScalarLowering::SetLoweredType(Node* node, Node* output) { |
| break; |
| } |
| #undef CASE_STMT |
| - default: |
| - replacements_[node->id()].type = replacements_[output->id()].type; |
| + default: { |
| + if (output->opcode() == IrOpcode::kFloat32x4FromInt32x4 || |
| + output->opcode() == IrOpcode::kFloat32x4FromUint32x4) { |
| + replacements_[node->id()].type = SimdType::kInt32; |
| + } else { |
| + replacements_[node->id()].type = replacements_[output->id()].type; |
| + } |
| + } |
| } |
| } |
| @@ -229,11 +241,11 @@ void SimdScalarLowering::LowerStoreOp(MachineRepresentation rep, Node* node, |
| } |
| } |
| -void SimdScalarLowering::LowerBinaryOp(Node* node, SimdType rep_type, |
| +void SimdScalarLowering::LowerBinaryOp(Node* node, SimdType input_rep_type, |
| const Operator* op) { |
| DCHECK(node->InputCount() == 2); |
| - Node** rep_left = GetReplacementsWithType(node->InputAt(0), rep_type); |
| - Node** rep_right = GetReplacementsWithType(node->InputAt(1), rep_type); |
| + Node** rep_left = GetReplacementsWithType(node->InputAt(0), input_rep_type); |
| + Node** rep_right = GetReplacementsWithType(node->InputAt(1), input_rep_type); |
| Node* rep_node[kMaxLanes]; |
| for (int i = 0; i < kMaxLanes; ++i) { |
| rep_node[i] = graph()->NewNode(op, rep_left[i], rep_right[i]); |
| @@ -241,6 +253,17 @@ void SimdScalarLowering::LowerBinaryOp(Node* node, SimdType rep_type, |
| ReplaceNode(node, rep_node); |
| } |
| +void SimdScalarLowering::LowerUnaryOp(Node* node, SimdType input_rep_type, |
| + const Operator* op) { |
| + DCHECK(node->InputCount() == 1); |
| + Node** rep = GetReplacementsWithType(node->InputAt(0), input_rep_type); |
| + Node* rep_node[kMaxLanes]; |
| + for (int i = 0; i < kMaxLanes; ++i) { |
| + rep_node[i] = graph()->NewNode(op, rep[i]); |
| + } |
| + ReplaceNode(node, rep_node); |
| +} |
| + |
| void SimdScalarLowering::LowerNode(Node* node) { |
| SimdType rep_type = ReplacementType(node); |
| switch (node->opcode()) { |
| @@ -399,6 +422,30 @@ void SimdScalarLowering::LowerNode(Node* node) { |
| I32X4_BINOP_CASE(kSimd128Or, Word32Or) |
| I32X4_BINOP_CASE(kSimd128Xor, Word32Xor) |
| #undef I32X4_BINOP_CASE |
| + case IrOpcode::kInt32x4Neg: { |
| + DCHECK(node->InputCount() == 1); |
| + Node** rep = GetReplacementsWithType(node->InputAt(0), rep_type); |
| + Node* rep_node[kMaxLanes]; |
| + for (int i = 0; i < kMaxLanes; ++i) { |
| + rep_node[i] = graph()->NewNode( |
| + machine()->Int32Sub(), graph()->NewNode(common()->Int32Constant(0)), |
|
titzer
2017/03/01 09:57:58
Can you pull the common()->Int32Constant() out of
aseemgarg
2017/03/01 10:35:46
pulled the whole node out.
titzer
2017/03/01 10:58:07
Oh darn, realized too late. If you had access to t
aseemgarg
2017/03/01 11:03:09
Will take care of it in the next patch.
|
| + rep[i]); |
| + } |
| + ReplaceNode(node, rep_node); |
| + break; |
| + } |
| + case IrOpcode::kSimd128Not: { |
| + DCHECK(node->InputCount() == 1); |
| + Node** rep = GetReplacementsWithType(node->InputAt(0), rep_type); |
| + Node* rep_node[kMaxLanes]; |
| + for (int i = 0; i < kMaxLanes; ++i) { |
| + rep_node[i] = graph()->NewNode( |
| + machine()->Word32Xor(), rep[i], |
| + graph()->NewNode(common()->Int32Constant(0xffffffff))); |
|
titzer
2017/03/01 09:57:58
Same here.
aseemgarg
2017/03/01 10:35:46
Done.
|
| + } |
| + ReplaceNode(node, rep_node); |
| + break; |
| + } |
| #define F32X4_BINOP_CASE(name) \ |
| case IrOpcode::kFloat32x4##name: { \ |
| LowerBinaryOp(node, rep_type, machine()->Float32##name()); \ |
| @@ -411,6 +458,23 @@ void SimdScalarLowering::LowerNode(Node* node) { |
| F32X4_BINOP_CASE(Min) |
| F32X4_BINOP_CASE(Max) |
| #undef F32X4_BINOP_CASE |
| +#define F32X4_UNOP_CASE(name) \ |
| + case IrOpcode::kFloat32x4##name: { \ |
| + LowerUnaryOp(node, rep_type, machine()->Float32##name()); \ |
| + break; \ |
| + } |
| + F32X4_UNOP_CASE(Abs) |
| + F32X4_UNOP_CASE(Neg) |
| + F32X4_UNOP_CASE(Sqrt) |
| +#undef F32x4_UNOP_CASE |
| + case IrOpcode::kFloat32x4FromInt32x4: { |
| + LowerUnaryOp(node, SimdType::kInt32, machine()->RoundInt32ToFloat32()); |
| + break; |
| + } |
| + case IrOpcode::kFloat32x4FromUint32x4: { |
| + LowerUnaryOp(node, SimdType::kInt32, machine()->RoundUint32ToFloat32()); |
| + break; |
| + } |
| case IrOpcode::kInt32x4Splat: |
| case IrOpcode::kFloat32x4Splat: { |
| Node* rep_node[kMaxLanes]; |