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

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

Issue 194863004: MIPS: Cleanup some of the range uses in ModI/DivI. (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: Created 6 years, 9 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 | « src/mips/lithium-codegen-mips.cc ('k') | 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. 1 // Copyright 2012 the V8 project authors. All rights reserved.
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 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) { 1282 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) {
1283 ASSERT(instr->representation().IsInteger32()); 1283 ASSERT(instr->representation().IsInteger32());
1284 ASSERT(instr->left()->representation().Equals(instr->representation())); 1284 ASSERT(instr->left()->representation().Equals(instr->representation()));
1285 ASSERT(instr->right()->representation().Equals(instr->representation())); 1285 ASSERT(instr->right()->representation().Equals(instr->representation()));
1286 LOperand* dividend = UseRegister(instr->left()); 1286 LOperand* dividend = UseRegister(instr->left());
1287 int32_t divisor = instr->right()->GetInteger32Constant(); 1287 int32_t divisor = instr->right()->GetInteger32Constant();
1288 LInstruction* result = 1288 LInstruction* result =
1289 DefineAsRegister(new(zone()) LFlooringDivByConstI(dividend, divisor)); 1289 DefineAsRegister(new(zone()) LFlooringDivByConstI(dividend, divisor));
1290 bool can_deopt = 1290 bool can_deopt =
1291 divisor == 0 || 1291 divisor == 0 ||
1292 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1292 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0);
1293 instr->left()->RangeCanInclude(0) && divisor < 0);
1294 return can_deopt ? AssignEnvironment(result) : result; 1293 return can_deopt ? AssignEnvironment(result) : result;
1295 } 1294 }
1296 1295
1297 1296
1298 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1297 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1299 if (instr->RightIsPowerOf2()) { 1298 if (instr->RightIsPowerOf2()) {
1300 return DoFlooringDivByPowerOf2I(instr); 1299 return DoFlooringDivByPowerOf2I(instr);
1301 } else if (instr->right()->IsConstant()) { 1300 } else if (instr->right()->IsConstant()) {
1302 return DoFlooringDivByConstI(instr); 1301 return DoFlooringDivByConstI(instr);
1303 } else { 1302 } else {
1304 HValue* right = instr->right(); 1303 HValue* right = instr->right();
1305 LOperand* dividend = UseRegister(instr->left()); 1304 LOperand* dividend = UseRegister(instr->left());
1306 LOperand* divisor = UseRegisterOrConstant(right); 1305 LOperand* divisor = UseRegisterOrConstant(right);
1307 LOperand* remainder = TempRegister(); 1306 LOperand* remainder = TempRegister();
1308 return AssignEnvironment(DefineAsRegister( 1307 return AssignEnvironment(DefineAsRegister(
1309 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder))); 1308 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder)));
1310 } 1309 }
1311 } 1310 }
1312 1311
1313 1312
1314 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { 1313 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1315 ASSERT(instr->representation().IsSmiOrInteger32()); 1314 ASSERT(instr->representation().IsSmiOrInteger32());
1316 ASSERT(instr->left()->representation().Equals(instr->representation())); 1315 ASSERT(instr->left()->representation().Equals(instr->representation()));
1317 ASSERT(instr->right()->representation().Equals(instr->representation())); 1316 ASSERT(instr->right()->representation().Equals(instr->representation()));
1318 LOperand* dividend = UseRegisterAtStart(instr->left()); 1317 LOperand* dividend = UseRegisterAtStart(instr->left());
1319 int32_t divisor = instr->right()->GetInteger32Constant(); 1318 int32_t divisor = instr->right()->GetInteger32Constant();
1320 LInstruction* result = 1319 LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I(
1321 DefineSameAsFirst(new(zone()) LModByPowerOf2I(dividend, divisor)); 1320 dividend, divisor));
1322 bool can_deopt = 1321 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1323 instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1322 result = AssignEnvironment(result);
1324 instr->left()->CanBeNegative(); 1323 }
1325 return can_deopt ? AssignEnvironment(result) : result; 1324 return result;
1326 } 1325 }
1327 1326
1328 1327
1329 LInstruction* LChunkBuilder::DoModI(HMod* instr) { 1328 LInstruction* LChunkBuilder::DoModI(HMod* instr) {
1330 ASSERT(instr->representation().IsSmiOrInteger32()); 1329 ASSERT(instr->representation().IsSmiOrInteger32());
1331 ASSERT(instr->left()->representation().Equals(instr->representation())); 1330 ASSERT(instr->left()->representation().Equals(instr->representation()));
1332 ASSERT(instr->right()->representation().Equals(instr->representation())); 1331 ASSERT(instr->right()->representation().Equals(instr->representation()));
1333 LOperand* dividend = UseRegister(instr->left()); 1332 LOperand* dividend = UseRegister(instr->left());
1334 LOperand* divisor = UseRegister(instr->right()); 1333 LOperand* divisor = UseRegister(instr->right());
1335 LModI* mod = new(zone()) LModI(dividend, 1334 LInstruction* result = DefineAsRegister(new(zone()) LModI(
1336 divisor); 1335 dividend, divisor));
1337 LInstruction* result = DefineAsRegister(mod); 1336 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1338 bool can_deopt = (instr->right()->CanBeZero() || 1337 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1339 (instr->left()->RangeCanInclude(kMinInt) && 1338 result = AssignEnvironment(result);
1340 instr->right()->RangeCanInclude(-1) && 1339 }
1341 instr->CheckFlag(HValue::kBailoutOnMinusZero)) || 1340 return result;
1342 (instr->left()->CanBeNegative() &&
1343 instr->CanBeZero() &&
1344 instr->CheckFlag(HValue::kBailoutOnMinusZero)));
1345 return can_deopt ? AssignEnvironment(result) : result;
1346 } 1341 }
1347 1342
1348 1343
1349 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1344 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1350 if (instr->representation().IsSmiOrInteger32()) { 1345 if (instr->representation().IsSmiOrInteger32()) {
1351 return instr->RightIsPowerOf2() ? DoModByPowerOf2I(instr) : DoModI(instr); 1346 return instr->RightIsPowerOf2() ? DoModByPowerOf2I(instr) : DoModI(instr);
1352 } else if (instr->representation().IsDouble()) { 1347 } else if (instr->representation().IsDouble()) {
1353 return DoArithmeticD(Token::MOD, instr); 1348 return DoArithmeticD(Token::MOD, instr);
1354 } else { 1349 } else {
1355 return DoArithmeticT(Token::MOD, instr); 1350 return DoArithmeticT(Token::MOD, instr);
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 2439
2445 2440
2446 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2441 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2447 LOperand* object = UseRegister(instr->object()); 2442 LOperand* object = UseRegister(instr->object());
2448 LOperand* index = UseRegister(instr->index()); 2443 LOperand* index = UseRegister(instr->index());
2449 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); 2444 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
2450 } 2445 }
2451 2446
2452 2447
2453 } } // namespace v8::internal 2448 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-codegen-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698