| OLD | NEW |
| 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 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1355 left = UseRegisterAtStart(instr->LeastConstantOperand()); |
| 1356 } | 1356 } |
| 1357 LMulI* mul = new(zone()) LMulI(left, right, temp); | 1357 LMulI* mul = new(zone()) LMulI(left, right, temp); |
| 1358 if (instr->CheckFlag(HValue::kCanOverflow) || | 1358 if (instr->CheckFlag(HValue::kCanOverflow) || |
| 1359 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1359 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1360 AssignEnvironment(mul); | 1360 AssignEnvironment(mul); |
| 1361 } | 1361 } |
| 1362 return DefineAsRegister(mul); | 1362 return DefineAsRegister(mul); |
| 1363 | 1363 |
| 1364 } else if (instr->representation().IsDouble()) { | 1364 } else if (instr->representation().IsDouble()) { |
| 1365 if (instr->UseCount() == 1 && instr->uses().value()->IsAdd()) { | 1365 if (instr->UseCount() == 1 && (instr->uses().value()->IsAdd() || |
| 1366 HAdd* add = HAdd::cast(instr->uses().value()); | 1366 instr->uses().value()->IsSub())) { |
| 1367 if (instr == add->left()) { | 1367 HBinaryOperation* use = HBinaryOperation::cast(instr->uses().value()); |
| 1368 // This mul is the lhs of an add. The add and mul will be folded | 1368 |
| 1369 // into a multiply-add. | 1369 if (use->IsAdd() && instr == use->left()) { |
| 1370 // This mul is the lhs of an add. The add and mul will be folded into a |
| 1371 // multiply-add in DoAdd. |
| 1370 return NULL; | 1372 return NULL; |
| 1371 } | 1373 } |
| 1372 if (instr == add->right() && !add->left()->IsMul()) { | 1374 if (instr == use->right() && use->IsAdd() && !use->left()->IsMul()) { |
| 1373 // This mul is the rhs of an add, where the lhs is not another mul. | 1375 // This mul is the rhs of an add, where the lhs is not another mul. |
| 1374 // The add and mul will be folded into a multiply-add. | 1376 // The add and mul will be folded into a multiply-add in DoAdd. |
| 1377 return NULL; |
| 1378 } |
| 1379 if (instr == use->right() && use->IsSub()) { |
| 1380 // This mul is the rhs of a sub. The sub and mul will be folded into a |
| 1381 // multiply-sub in DoSub. |
| 1375 return NULL; | 1382 return NULL; |
| 1376 } | 1383 } |
| 1377 } | 1384 } |
| 1378 | 1385 |
| 1379 return DoArithmeticD(Token::MUL, instr); | 1386 return DoArithmeticD(Token::MUL, instr); |
| 1380 } else { | 1387 } else { |
| 1381 return DoArithmeticT(Token::MUL, instr); | 1388 return DoArithmeticT(Token::MUL, instr); |
| 1382 } | 1389 } |
| 1383 } | 1390 } |
| 1384 | 1391 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1395 | 1402 |
| 1396 LOperand* left = UseRegisterAtStart(instr->left()); | 1403 LOperand* left = UseRegisterAtStart(instr->left()); |
| 1397 LOperand* right = UseOrConstantAtStart(instr->right()); | 1404 LOperand* right = UseOrConstantAtStart(instr->right()); |
| 1398 LSubI* sub = new(zone()) LSubI(left, right); | 1405 LSubI* sub = new(zone()) LSubI(left, right); |
| 1399 LInstruction* result = DefineAsRegister(sub); | 1406 LInstruction* result = DefineAsRegister(sub); |
| 1400 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1407 if (instr->CheckFlag(HValue::kCanOverflow)) { |
| 1401 result = AssignEnvironment(result); | 1408 result = AssignEnvironment(result); |
| 1402 } | 1409 } |
| 1403 return result; | 1410 return result; |
| 1404 } else if (instr->representation().IsDouble()) { | 1411 } else if (instr->representation().IsDouble()) { |
| 1412 if (instr->right()->IsMul()) |
| 1413 return DoMultiplySub(instr->left(), HMul::cast(instr->right())); |
| 1414 |
| 1405 return DoArithmeticD(Token::SUB, instr); | 1415 return DoArithmeticD(Token::SUB, instr); |
| 1406 } else { | 1416 } else { |
| 1407 return DoArithmeticT(Token::SUB, instr); | 1417 return DoArithmeticT(Token::SUB, instr); |
| 1408 } | 1418 } |
| 1409 } | 1419 } |
| 1410 | 1420 |
| 1411 | 1421 |
| 1412 LInstruction* LChunkBuilder::DoRSub(HSub* instr) { | 1422 LInstruction* LChunkBuilder::DoRSub(HSub* instr) { |
| 1413 ASSERT(instr->representation().IsInteger32()); | 1423 ASSERT(instr->representation().IsInteger32()); |
| 1414 ASSERT(instr->left()->representation().IsInteger32()); | 1424 ASSERT(instr->left()->representation().IsInteger32()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1428 | 1438 |
| 1429 | 1439 |
| 1430 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { | 1440 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { |
| 1431 LOperand* multiplier_op = UseRegisterAtStart(mul->left()); | 1441 LOperand* multiplier_op = UseRegisterAtStart(mul->left()); |
| 1432 LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); | 1442 LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); |
| 1433 LOperand* addend_op = UseRegisterAtStart(addend); | 1443 LOperand* addend_op = UseRegisterAtStart(addend); |
| 1434 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op, | 1444 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op, |
| 1435 multiplicand_op)); | 1445 multiplicand_op)); |
| 1436 } | 1446 } |
| 1437 | 1447 |
| 1448 |
| 1449 LInstruction* LChunkBuilder::DoMultiplySub(HValue* minuend, HMul* mul) { |
| 1450 LOperand* minuend_op = UseRegisterAtStart(minuend); |
| 1451 LOperand* multiplier_op = UseRegisterAtStart(mul->left()); |
| 1452 LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); |
| 1453 |
| 1454 return DefineSameAsFirst(new(zone()) LMultiplySubD(minuend_op, |
| 1455 multiplier_op, |
| 1456 multiplicand_op)); |
| 1457 } |
| 1458 |
| 1459 |
| 1438 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | 1460 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
| 1439 if (instr->representation().IsInteger32()) { | 1461 if (instr->representation().IsInteger32()) { |
| 1440 ASSERT(instr->left()->representation().IsInteger32()); | 1462 ASSERT(instr->left()->representation().IsInteger32()); |
| 1441 ASSERT(instr->right()->representation().IsInteger32()); | 1463 ASSERT(instr->right()->representation().IsInteger32()); |
| 1442 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1464 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); |
| 1443 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1465 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); |
| 1444 LAddI* add = new(zone()) LAddI(left, right); | 1466 LAddI* add = new(zone()) LAddI(left, right); |
| 1445 LInstruction* result = DefineAsRegister(add); | 1467 LInstruction* result = DefineAsRegister(add); |
| 1446 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1468 if (instr->CheckFlag(HValue::kCanOverflow)) { |
| 1447 result = AssignEnvironment(result); | 1469 result = AssignEnvironment(result); |
| (...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 | 2477 |
| 2456 | 2478 |
| 2457 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2479 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2458 LOperand* object = UseRegister(instr->object()); | 2480 LOperand* object = UseRegister(instr->object()); |
| 2459 LOperand* index = UseRegister(instr->index()); | 2481 LOperand* index = UseRegister(instr->index()); |
| 2460 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2482 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2461 } | 2483 } |
| 2462 | 2484 |
| 2463 | 2485 |
| 2464 } } // namespace v8::internal | 2486 } } // namespace v8::internal |
| OLD | NEW |