Index: src/compiler/mips/instruction-selector-mips.cc |
diff --git a/src/compiler/mips/instruction-selector-mips.cc b/src/compiler/mips/instruction-selector-mips.cc |
index e3981a2bd6a6e1a3e3a62c6fe97838251e5a79c4..bdde19c37083158deb0909edad780caf4b07b03f 100644 |
--- a/src/compiler/mips/instruction-selector-mips.cc |
+++ b/src/compiler/mips/instruction-selector-mips.cc |
@@ -535,8 +535,40 @@ void InstructionSelector::VisitChangeFloat64ToInt32(Node* node) { |
g.UseRegister(value->InputAt(0))); |
return; |
default: |
- VisitRR(this, kMipsTruncWD, node); |
+ break; |
+ } |
+ if (value->opcode() == IrOpcode::kChangeFloat32ToFloat64) { |
+ Node* next = value->InputAt(0); |
+ if (CanCover(value, next)) { |
+ // Match ChangeFloat64ToInt32(ChangeFloat32ToFloat64(Float64Round##OP)) |
+ switch (next->opcode()) { |
+ case IrOpcode::kFloat32RoundDown: |
+ Emit(kMipsFloorWS, g.DefineAsRegister(node), |
+ g.UseRegister(next->InputAt(0))); |
+ return; |
+ case IrOpcode::kFloat32RoundUp: |
+ Emit(kMipsCeilWS, g.DefineAsRegister(node), |
+ g.UseRegister(next->InputAt(0))); |
+ return; |
+ case IrOpcode::kFloat32RoundTiesEven: |
+ Emit(kMipsRoundWS, g.DefineAsRegister(node), |
+ g.UseRegister(next->InputAt(0))); |
+ return; |
+ case IrOpcode::kFloat32RoundTruncate: |
+ Emit(kMipsTruncWS, g.DefineAsRegister(node), |
+ g.UseRegister(next->InputAt(0))); |
+ return; |
+ default: |
+ Emit(kMipsTruncWS, g.DefineAsRegister(node), |
+ g.UseRegister(value->InputAt(0))); |
+ return; |
+ } |
+ } else { |
+ // Match float32 -> float64 -> int32 representation change path. |
+ Emit(kMipsTruncWS, g.DefineAsRegister(node), |
+ g.UseRegister(value->InputAt(0))); |
return; |
+ } |
} |
} |
VisitRR(this, kMipsTruncWD, node); |
@@ -549,6 +581,16 @@ void InstructionSelector::VisitChangeFloat64ToUint32(Node* node) { |
void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) { |
+ MipsOperandGenerator g(this); |
+ Node* value = node->InputAt(0); |
+ // Match TruncateFloat64ToFloat32(ChangeInt32ToFloat64) to corresponding |
+ // instruction. |
+ if (CanCover(node, value) && |
+ value->opcode() == IrOpcode::kChangeInt32ToFloat64) { |
+ Emit(kMipsCvtSW, g.DefineAsRegister(node), |
+ g.UseRegister(value->InputAt(0))); |
+ return; |
+ } |
VisitRR(this, kMipsCvtSD, node); |
} |