Commit da477bc7 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

[X87] [Crankshaft] Fix DoMathFloor and DoMathRound code generation bug.

  The CL #35067 (https://codereview.chromium.org/1830703003) exposed one hidden bug in x87 crankshaft code generation for DoMathFloor and DoMathRound.

  The current DoMathFloor will change the default round mode of x87 FPU and then deoptimized into FC code before the default x87 FPU's round mode was restored.
  This behavior caused several test cases fail as the FC code expected to run under the default x87 FPU's round mode.

  This CL fixed this bug.

BUG=

Review URL: https://codereview.chromium.org/1856303002

Cr-Commit-Position: refs/heads/master@{#35250}
parent e5724d95
......@@ -3480,6 +3480,7 @@ void LCodeGen::DoMathFloor(LMathFloor* instr) {
__ sub(esp, Immediate(kPointerSize));
__ fist_s(Operand(esp, 0));
__ pop(output_reg);
__ X87SetRC(0x0000);
__ X87CheckIA();
DeoptimizeIf(equal, instr, Deoptimizer::kOverflow);
__ fnclex();
......@@ -3512,6 +3513,8 @@ void LCodeGen::DoMathRound(LMathRound* instr) {
// Clear exception bits.
__ fnclex();
__ fistp_s(MemOperand(esp, 0));
// Restore round mode.
__ X87SetRC(0x0000);
// Check overflow.
__ X87CheckIA();
__ pop(result);
......@@ -3546,6 +3549,8 @@ void LCodeGen::DoMathRound(LMathRound* instr) {
// Clear exception bits.
__ fnclex();
__ fistp_s(MemOperand(esp, 0));
// Restore round mode.
__ X87SetRC(0x0000);
// Check overflow.
__ X87CheckIA();
__ pop(result);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment