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

Side by Side Diff: src/mips/lithium-codegen-mips.cc

Issue 333713002: MIPS: Fix r21780 - “Fixed flooring division by a power of 2, once again...” (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: Fix register usage. 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved.7 1 // Copyright 2012 the V8 project authors. All rights reserved.7
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 1320
1321 // If the divisor is positive, things are easy: There can be no deopts and we 1321 // If the divisor is positive, things are easy: There can be no deopts and we
1322 // can simply do an arithmetic right shift. 1322 // can simply do an arithmetic right shift.
1323 uint16_t shift = WhichPowerOf2Abs(divisor); 1323 uint16_t shift = WhichPowerOf2Abs(divisor);
1324 if (divisor > 1) { 1324 if (divisor > 1) {
1325 __ sra(result, dividend, shift); 1325 __ sra(result, dividend, shift);
1326 return; 1326 return;
1327 } 1327 }
1328 1328
1329 // If the divisor is negative, we have to negate and handle edge cases. 1329 // If the divisor is negative, we have to negate and handle edge cases.
1330 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { 1330
1331 // divident can be the same register as result so save the value of it 1331 // divident can be the same register as result so save the value of it
1332 // for checking overflow. 1332 // for checking overflow.
1333 __ Move(scratch, dividend); 1333 __ Move(scratch, dividend);
1334 } 1334
1335 __ Subu(result, zero_reg, dividend); 1335 __ Subu(result, zero_reg, dividend);
1336 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 1336 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1337 DeoptimizeIf(eq, instr->environment(), result, Operand(zero_reg)); 1337 DeoptimizeIf(eq, instr->environment(), result, Operand(zero_reg));
1338 } 1338 }
1339 1339
1340 // Dividing by -1 is basically negation, unless we overflow. 1340 // Dividing by -1 is basically negation, unless we overflow.
1341 __ Xor(at, scratch, result); 1341 __ Xor(scratch, scratch, result);
1342 if (divisor == -1) { 1342 if (divisor == -1) {
1343 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { 1343 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
1344 DeoptimizeIf(ge, instr->environment(), at, Operand(zero_reg)); 1344 DeoptimizeIf(ge, instr->environment(), at, Operand(zero_reg));
1345 } 1345 }
1346 return; 1346 return;
1347 } 1347 }
1348 1348
1349 // If the negation could not overflow, simply shifting is OK. 1349 // If the negation could not overflow, simply shifting is OK.
1350 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { 1350 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
1351 __ sra(result, result, shift); 1351 __ sra(result, result, shift);
1352 return; 1352 return;
1353 } 1353 }
1354 1354
1355 Label no_overflow, done; 1355 Label no_overflow, done;
1356 __ Branch(&no_overflow, lt, at, Operand(zero_reg)); 1356 __ Branch(&no_overflow, lt, scratch, Operand(zero_reg));
1357 __ li(result, Operand(kMinInt / divisor)); 1357 __ li(result, Operand(kMinInt / divisor));
1358 __ Branch(&done); 1358 __ Branch(&done);
1359 __ bind(&no_overflow); 1359 __ bind(&no_overflow);
1360 __ sra(result, result, shift); 1360 __ sra(result, result, shift);
1361 __ bind(&done); 1361 __ bind(&done);
1362 } 1362 }
1363 1363
1364 1364
1365 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { 1365 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) {
1366 Register dividend = ToRegister(instr->dividend()); 1366 Register dividend = ToRegister(instr->dividend());
(...skipping 4524 matching lines...) Expand 10 before | Expand all | Expand 10 after
5891 __ li(at, scope_info); 5891 __ li(at, scope_info);
5892 __ Push(at, ToRegister(instr->function())); 5892 __ Push(at, ToRegister(instr->function()));
5893 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); 5893 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr);
5894 RecordSafepoint(Safepoint::kNoLazyDeopt); 5894 RecordSafepoint(Safepoint::kNoLazyDeopt);
5895 } 5895 }
5896 5896
5897 5897
5898 #undef __ 5898 #undef __
5899 5899
5900 } } // namespace v8::internal 5900 } } // namespace v8::internal
OLDNEW
« 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