Bug 1464366 : [MIPS] Provide implementation for CodeGenerator::visitTrunc{F}; r=jandem
authorDragan Mladjenovic <dragan.mladjenovic>
Fri, 25 May 2018 12:31:12 +0200
changeset 420152 855746edf54b32406958af8d4527097dd7d6e8b7
parent 420151 d4393b6057dcfe3d04e810bf6b4260d1c62279d0
child 420153 7b6e1437845e328b7ce1a75aaeaf7479faca8c98
push id34065
push useraciure@mozilla.com
push dateMon, 28 May 2018 21:54:18 +0000
treeherdermozilla-central@35aa0dde259f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1464366
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1464366 : [MIPS] Provide implementation for CodeGenerator::visitTrunc{F}; r=jandem
js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
--- a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
+++ b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
@@ -1450,23 +1450,53 @@ CodeGenerator::visitRoundF(LRoundF* lir)
     bailoutCmp32(Assembler::Equal, output, Imm32(INT_MIN), lir->snapshot());
 
     masm.bind(&end);
 }
 
 void
 CodeGenerator::visitTrunc(LTrunc* lir)
 {
-    MOZ_CRASH("visitTrunc");
+    FloatRegister input = ToFloatRegister(lir->input());
+    Register output = ToRegister(lir->output());
+
+    Label notZero;
+    masm.as_truncwd(ScratchFloat32Reg, input);
+    masm.as_cfc1(ScratchRegister, Assembler::FCSR);
+    masm.moveFromFloat32(ScratchFloat32Reg, output);
+    masm.ma_ext(ScratchRegister, ScratchRegister, Assembler::CauseV, 1);
+
+    masm.ma_b(output, Imm32(0), &notZero, Assembler::NotEqual, ShortJump);
+    masm.moveFromDoubleHi(input, ScratchRegister);
+    // Check if input is in ]-1; -0] range by checking the sign bit.
+    masm.as_slt(ScratchRegister, ScratchRegister, zero);
+    masm.bind(&notZero);
+
+    bailoutCmp32(Assembler::NotEqual, ScratchRegister, Imm32(0), lir->snapshot());
 }
 
 void
 CodeGenerator::visitTruncF(LTruncF* lir)
 {
-    MOZ_CRASH("visitTruncF");
+    FloatRegister input = ToFloatRegister(lir->input());
+    Register output = ToRegister(lir->output());
+
+    Label notZero;
+    masm.as_truncws(ScratchFloat32Reg, input);
+    masm.as_cfc1(ScratchRegister, Assembler::FCSR);
+    masm.moveFromFloat32(ScratchFloat32Reg, output);
+    masm.ma_ext(ScratchRegister, ScratchRegister, Assembler::CauseV, 1);
+
+    masm.ma_b(output, Imm32(0), &notZero, Assembler::NotEqual, ShortJump);
+    masm.moveFromFloat32(input, ScratchRegister);
+    // Check if input is in ]-1; -0] range by checking the sign bit.
+    masm.as_slt(ScratchRegister, ScratchRegister, zero);
+    masm.bind(&notZero);
+
+    bailoutCmp32(Assembler::NotEqual, ScratchRegister, Imm32(0), lir->snapshot());
 }
 
 void
 CodeGenerator::visitTruncateDToInt32(LTruncateDToInt32* ins)
 {
     emitTruncateDouble(ToFloatRegister(ins->input()), ToRegister(ins->output()),
                        ins->mir());
 }