Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: src/mips/lithium-codegen-mips.cc

Issue 322403006: MIPS: Fixed flooring division by a power of 2, once again... (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips/lithium-codegen-mips.cc
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc
index 65fe1aa910f1243650e64e761524d9a8b7ede4da..1b2dec04416480659edd618642d88277ccfef9a6 100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -1309,8 +1309,8 @@ void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) {
Register dividend = ToRegister(instr->dividend());
Register result = ToRegister(instr->result());
int32_t divisor = instr->divisor();
- Register scratch = scratch0();
- ASSERT(!scratch.is(dividend));
+ Register scratch = result.is(dividend) ? scratch0() : dividend;
+ ASSERT(!result.is(dividend) || !scratch.is(dividend));
// If the divisor is 1, return the dividend.
if (divisor == 1) {
@@ -1328,6 +1328,8 @@ 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);
}
__ Subu(result, zero_reg, dividend);
@@ -1335,16 +1337,18 @@ void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) {
DeoptimizeIf(eq, instr->environment(), result, Operand(zero_reg));
}
- // If the negation could not overflow, simply shifting is OK.
- if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
- __ sra(result, dividend, shift);
- return;
- }
-
// Dividing by -1 is basically negation, unless we overflow.
__ Xor(at, scratch, result);
if (divisor == -1) {
- DeoptimizeIf(ge, instr->environment(), at, Operand(zero_reg));
+ if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
+ DeoptimizeIf(ge, instr->environment(), at, Operand(zero_reg));
+ }
+ return;
+ }
+
+ // If the negation could not overflow, simply shifting is OK.
+ if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
+ __ sra(result, result, shift);
return;
}
@@ -1353,7 +1357,7 @@ void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) {
__ li(result, Operand(kMinInt / divisor));
__ Branch(&done);
__ bind(&no_overflow);
- __ sra(result, dividend, shift);
+ __ sra(result, result, shift);
__ bind(&done);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698