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

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

Issue 12319113: Emit VMLS for multiply-subtract on ARM. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address Ulan's commen Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-arm.h ('k') | src/arm/lithium-codegen-arm.cc » ('j') | 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 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
1415
1405 return DoArithmeticD(Token::SUB, instr); 1416 return DoArithmeticD(Token::SUB, instr);
1406 } else { 1417 } else {
1407 return DoArithmeticT(Token::SUB, instr); 1418 return DoArithmeticT(Token::SUB, instr);
1408 } 1419 }
1409 } 1420 }
1410 1421
1411 1422
1412 LInstruction* LChunkBuilder::DoRSub(HSub* instr) { 1423 LInstruction* LChunkBuilder::DoRSub(HSub* instr) {
1413 ASSERT(instr->representation().IsInteger32()); 1424 ASSERT(instr->representation().IsInteger32());
1414 ASSERT(instr->left()->representation().IsInteger32()); 1425 ASSERT(instr->left()->representation().IsInteger32());
(...skipping 13 matching lines...) Expand all
1428 1439
1429 1440
1430 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { 1441 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) {
1431 LOperand* multiplier_op = UseRegisterAtStart(mul->left()); 1442 LOperand* multiplier_op = UseRegisterAtStart(mul->left());
1432 LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); 1443 LOperand* multiplicand_op = UseRegisterAtStart(mul->right());
1433 LOperand* addend_op = UseRegisterAtStart(addend); 1444 LOperand* addend_op = UseRegisterAtStart(addend);
1434 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op, 1445 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op,
1435 multiplicand_op)); 1446 multiplicand_op));
1436 } 1447 }
1437 1448
1449
1450 LInstruction* LChunkBuilder::DoMultiplySub(HValue* minuend, HMul* mul) {
1451 LOperand* minuend_op = UseRegisterAtStart(minuend);
1452 LOperand* multiplier_op = UseRegisterAtStart(mul->left());
1453 LOperand* multiplicand_op = UseRegisterAtStart(mul->right());
1454
1455 return DefineSameAsFirst(new(zone()) LMultiplySubD(minuend_op,
1456 multiplier_op,
1457 multiplicand_op));
1458 }
1459
1460
1438 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { 1461 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
1439 if (instr->representation().IsInteger32()) { 1462 if (instr->representation().IsInteger32()) {
1440 ASSERT(instr->left()->representation().IsInteger32()); 1463 ASSERT(instr->left()->representation().IsInteger32());
1441 ASSERT(instr->right()->representation().IsInteger32()); 1464 ASSERT(instr->right()->representation().IsInteger32());
1442 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); 1465 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
1443 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); 1466 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
1444 LAddI* add = new(zone()) LAddI(left, right); 1467 LAddI* add = new(zone()) LAddI(left, right);
1445 LInstruction* result = DefineAsRegister(add); 1468 LInstruction* result = DefineAsRegister(add);
1446 if (instr->CheckFlag(HValue::kCanOverflow)) { 1469 if (instr->CheckFlag(HValue::kCanOverflow)) {
1447 result = AssignEnvironment(result); 1470 result = AssignEnvironment(result);
1448 } 1471 }
1449 return result; 1472 return result;
1450 } else if (instr->representation().IsDouble()) { 1473 } else if (instr->representation().IsDouble()) {
1451 if (instr->left()->IsMul()) 1474 if (instr->left()->IsMul()) {
1452 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right()); 1475 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right());
1476 }
1453 1477
1454 if (instr->right()->IsMul()) { 1478 if (instr->right()->IsMul()) {
1455 ASSERT(!instr->left()->IsMul()); 1479 ASSERT(!instr->left()->IsMul());
1456 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left()); 1480 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left());
1457 } 1481 }
1458 1482
1459 return DoArithmeticD(Token::ADD, instr); 1483 return DoArithmeticD(Token::ADD, instr);
1460 } else { 1484 } else {
1461 ASSERT(instr->representation().IsTagged()); 1485 ASSERT(instr->representation().IsTagged());
1462 return DoArithmeticT(Token::ADD, instr); 1486 return DoArithmeticT(Token::ADD, instr);
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 2479
2456 2480
2457 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2481 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2458 LOperand* object = UseRegister(instr->object()); 2482 LOperand* object = UseRegister(instr->object());
2459 LOperand* index = UseRegister(instr->index()); 2483 LOperand* index = UseRegister(instr->index());
2460 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); 2484 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
2461 } 2485 }
2462 2486
2463 2487
2464 } } // namespace v8::internal 2488 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.h ('k') | src/arm/lithium-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698