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

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

Issue 200423004: MIPS: Fix Lithium div, mod and floor. (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-mips.h ('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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 1248
1249 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 1249 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1250 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); 1250 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1251 return DefineAsRegister(new(zone()) LBitI(left, right)); 1251 return DefineAsRegister(new(zone()) LBitI(left, right));
1252 } else { 1252 } else {
1253 return DoArithmeticT(instr->op(), instr); 1253 return DoArithmeticT(instr->op(), instr);
1254 } 1254 }
1255 } 1255 }
1256 1256
1257 1257
1258 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) {
1259 ASSERT(instr->representation().IsSmiOrInteger32());
1260 ASSERT(instr->left()->representation().Equals(instr->representation()));
1261 ASSERT(instr->right()->representation().Equals(instr->representation()));
1262 LOperand* dividend = UseRegister(instr->left());
1263 int32_t divisor = instr->right()->GetInteger32Constant();
1264 LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I(
1265 dividend, divisor));
1266 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1267 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
1268 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
1269 divisor != 1 && divisor != -1)) {
1270 result = AssignEnvironment(result);
1271 }
1272 return result;
1273 }
1274
1275
1276 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) {
1277 ASSERT(instr->representation().IsInteger32());
1278 ASSERT(instr->left()->representation().Equals(instr->representation()));
1279 ASSERT(instr->right()->representation().Equals(instr->representation()));
1280 LOperand* dividend = UseRegister(instr->left());
1281 int32_t divisor = instr->right()->GetInteger32Constant();
1282 LInstruction* result = DefineAsRegister(new(zone()) LDivByConstI(
1283 dividend, divisor));
1284 if (divisor == 0 ||
1285 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1286 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1287 result = AssignEnvironment(result);
1288 }
1289 return result;
1290 }
1291
1292
1258 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) { 1293 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) {
1259 ASSERT(instr->representation().IsSmiOrInteger32()); 1294 ASSERT(instr->representation().IsSmiOrInteger32());
1260 ASSERT(instr->left()->representation().Equals(instr->representation())); 1295 ASSERT(instr->left()->representation().Equals(instr->representation()));
1261 ASSERT(instr->right()->representation().Equals(instr->representation())); 1296 ASSERT(instr->right()->representation().Equals(instr->representation()));
1262 LOperand* dividend = UseRegister(instr->left()); 1297 LOperand* dividend = UseRegister(instr->left());
1263 LOperand* divisor = UseRegister(instr->right()); 1298 LOperand* divisor = UseRegister(instr->right());
1264 LDivI* div = new(zone()) LDivI(dividend, divisor); 1299 LDivI* div = new(zone()) LDivI(dividend, divisor);
1265 return AssignEnvironment(DefineAsRegister(div)); 1300 return AssignEnvironment(DefineAsRegister(div));
1266 } 1301 }
1267 1302
1268 1303
1269 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { 1304 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1270 if (instr->representation().IsSmiOrInteger32()) { 1305 if (instr->representation().IsSmiOrInteger32()) {
1271 return DoDivI(instr); 1306 if (instr->RightIsPowerOf2()) {
1307 return DoDivByPowerOf2I(instr);
1308 } else if (instr->right()->IsConstant()) {
1309 return DoDivByConstI(instr);
1310 } else {
1311 return DoDivI(instr);
1312 }
1272 } else if (instr->representation().IsDouble()) { 1313 } else if (instr->representation().IsDouble()) {
1273 return DoArithmeticD(Token::DIV, instr); 1314 return DoArithmeticD(Token::DIV, instr);
1274 } else { 1315 } else {
1275 return DoArithmeticT(Token::DIV, instr); 1316 return DoArithmeticT(Token::DIV, instr);
1276 } 1317 }
1277 } 1318 }
1278 1319
1279 1320
1280 LInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) { 1321 LInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) {
1281 LOperand* dividend = UseRegisterAtStart(instr->left()); 1322 LOperand* dividend = UseRegisterAtStart(instr->left());
(...skipping 19 matching lines...) Expand all
1301 bool can_deopt = 1342 bool can_deopt =
1302 divisor == 0 || 1343 divisor == 0 ||
1303 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0); 1344 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0);
1304 return can_deopt ? AssignEnvironment(result) : result; 1345 return can_deopt ? AssignEnvironment(result) : result;
1305 } 1346 }
1306 1347
1307 1348
1308 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1349 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1309 if (instr->RightIsPowerOf2()) { 1350 if (instr->RightIsPowerOf2()) {
1310 return DoFlooringDivByPowerOf2I(instr); 1351 return DoFlooringDivByPowerOf2I(instr);
1311 } else if (instr->right()->IsConstant()) { 1352 } else if (false && instr->right()->IsConstant()) {
1312 return DoFlooringDivByConstI(instr); 1353 return DoFlooringDivByConstI(instr); // TODO(svenpanne) Fix and re-enable.
1313 } else { 1354 } else {
1314 HValue* right = instr->right(); 1355 return DoDivI(instr);
1315 LOperand* dividend = UseRegister(instr->left());
1316 LOperand* divisor = UseRegisterOrConstant(right);
1317 LOperand* remainder = TempRegister();
1318 return AssignEnvironment(DefineAsRegister(
1319 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder)));
1320 } 1356 }
1321 } 1357 }
1322 1358
1323 1359
1324 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { 1360 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1325 ASSERT(instr->representation().IsSmiOrInteger32()); 1361 ASSERT(instr->representation().IsSmiOrInteger32());
1326 ASSERT(instr->left()->representation().Equals(instr->representation())); 1362 ASSERT(instr->left()->representation().Equals(instr->representation()));
1327 ASSERT(instr->right()->representation().Equals(instr->representation())); 1363 ASSERT(instr->right()->representation().Equals(instr->representation()));
1328 LOperand* dividend = UseRegisterAtStart(instr->left()); 1364 LOperand* dividend = UseRegisterAtStart(instr->left());
1329 int32_t divisor = instr->right()->GetInteger32Constant(); 1365 int32_t divisor = instr->right()->GetInteger32Constant();
1330 LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I( 1366 LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I(
1331 dividend, divisor)); 1367 dividend, divisor));
1332 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1368 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1333 result = AssignEnvironment(result); 1369 result = AssignEnvironment(result);
1334 } 1370 }
1335 return result; 1371 return result;
1336 } 1372 }
1337 1373
1338 1374
1375 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) {
1376 ASSERT(instr->representation().IsSmiOrInteger32());
1377 ASSERT(instr->left()->representation().Equals(instr->representation()));
1378 ASSERT(instr->right()->representation().Equals(instr->representation()));
1379 LOperand* dividend = UseRegister(instr->left());
1380 int32_t divisor = instr->right()->GetInteger32Constant();
1381 LInstruction* result = DefineAsRegister(new(zone()) LModByConstI(
1382 dividend, divisor));
1383 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1384 result = AssignEnvironment(result);
1385 }
1386 return result;
1387 }
1388
1389
1339 LInstruction* LChunkBuilder::DoModI(HMod* instr) { 1390 LInstruction* LChunkBuilder::DoModI(HMod* instr) {
1340 ASSERT(instr->representation().IsSmiOrInteger32()); 1391 ASSERT(instr->representation().IsSmiOrInteger32());
1341 ASSERT(instr->left()->representation().Equals(instr->representation())); 1392 ASSERT(instr->left()->representation().Equals(instr->representation()));
1342 ASSERT(instr->right()->representation().Equals(instr->representation())); 1393 ASSERT(instr->right()->representation().Equals(instr->representation()));
1343 LOperand* dividend = UseRegister(instr->left()); 1394 LOperand* dividend = UseRegister(instr->left());
1344 LOperand* divisor = UseRegister(instr->right()); 1395 LOperand* divisor = UseRegister(instr->right());
1345 LInstruction* result = DefineAsRegister(new(zone()) LModI( 1396 LInstruction* result = DefineAsRegister(new(zone()) LModI(
1346 dividend, divisor)); 1397 dividend, divisor));
1347 if (instr->CheckFlag(HValue::kCanBeDivByZero) || 1398 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1348 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { 1399 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 2484
2434 2485
2435 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2486 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2436 LOperand* object = UseRegister(instr->object()); 2487 LOperand* object = UseRegister(instr->object());
2437 LOperand* index = UseRegister(instr->index()); 2488 LOperand* index = UseRegister(instr->index());
2438 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); 2489 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
2439 } 2490 }
2440 2491
2441 2492
2442 } } // namespace v8::internal 2493 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-mips.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698