From d773d05ba6e4327799ed4b2e48f3e7c589ccfb8d Mon Sep 17 00:00:00 2001 From: "plind44@gmail.com" Date: Thu, 12 Jun 2014 20:25:47 +0000 Subject: [PATCH] =?utf8?q?MIPS:=20Fix=20r21780=20-=20=E2=80=9CFixed=20floo?= =?utf8?q?ring=20division=20by=20a=20power=20of=202,=20once=20again...?= =?utf8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Initialize scratch register for all possible code paths. TEST=mjsunit/compiler/division-by-constant.js BUG= R=plind44@gmail.com Review URL: https://codereview.chromium.org/333713002 Patch from Balazs Kilvady . git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21822 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/lithium-codegen-mips.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 1b2dec0..f1c7b9a 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -1327,18 +1327,18 @@ void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) { } // If the divisor is negative, we have to negate and handle edge cases. - if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { - // divident can be the same register as result so save the value of it - // for checking overflow. - __ Move(scratch, dividend); - } + + // dividend can be the same register as result so save the value of it + // for checking overflow. + __ Move(scratch, dividend); + __ Subu(result, zero_reg, dividend); if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { DeoptimizeIf(eq, instr->environment(), result, Operand(zero_reg)); } // Dividing by -1 is basically negation, unless we overflow. - __ Xor(at, scratch, result); + __ Xor(scratch, scratch, result); if (divisor == -1) { if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { DeoptimizeIf(ge, instr->environment(), at, Operand(zero_reg)); @@ -1353,7 +1353,7 @@ void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) { } Label no_overflow, done; - __ Branch(&no_overflow, lt, at, Operand(zero_reg)); + __ Branch(&no_overflow, lt, scratch, Operand(zero_reg)); __ li(result, Operand(kMinInt / divisor)); __ Branch(&done); __ bind(&no_overflow); -- 2.7.4