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

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

Issue 191293013: Cleanup some of the range uses in ModI/DivI. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE 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 | Annotate | Revision Log
« no previous file with comments | « src/a64/lithium-a64.h ('k') | src/a64/lithium-codegen-a64.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 return AssignEnvironment(new(zone()) LDeoptimize); 1367 return AssignEnvironment(new(zone()) LDeoptimize);
1368 } 1368 }
1369 1369
1370 1370
1371 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) { 1371 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) {
1372 ASSERT(instr->representation().IsInteger32()); 1372 ASSERT(instr->representation().IsInteger32());
1373 ASSERT(instr->left()->representation().Equals(instr->representation())); 1373 ASSERT(instr->left()->representation().Equals(instr->representation()));
1374 ASSERT(instr->right()->representation().Equals(instr->representation())); 1374 ASSERT(instr->right()->representation().Equals(instr->representation()));
1375 LOperand* dividend = UseRegister(instr->left()); 1375 LOperand* dividend = UseRegister(instr->left());
1376 int32_t divisor = instr->right()->GetInteger32Constant(); 1376 int32_t divisor = instr->right()->GetInteger32Constant();
1377 LInstruction* result = 1377 LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I(
1378 DefineAsRegister(new(zone()) LDivByPowerOf2I(dividend, divisor)); 1378 dividend, divisor));
1379 bool can_deopt = 1379 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1380 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1380 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
1381 instr->left()->RangeCanInclude(0) && divisor < 0) ||
1382 (instr->CheckFlag(HValue::kCanOverflow) &&
1383 instr->left()->RangeCanInclude(kMinInt) && divisor == -1) ||
1384 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && 1381 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
1385 divisor != 1 && divisor != -1); 1382 divisor != 1 && divisor != -1)) {
1386 return can_deopt ? AssignEnvironment(result) : result; 1383 result = AssignEnvironment(result);
1384 }
1385 return result;
1387 } 1386 }
1388 1387
1389 1388
1390 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) { 1389 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) {
1391 ASSERT(instr->representation().IsInteger32()); 1390 ASSERT(instr->representation().IsInteger32());
1392 ASSERT(instr->left()->representation().Equals(instr->representation())); 1391 ASSERT(instr->left()->representation().Equals(instr->representation()));
1393 ASSERT(instr->right()->representation().Equals(instr->representation())); 1392 ASSERT(instr->right()->representation().Equals(instr->representation()));
1394 LOperand* dividend = UseRegister(instr->left()); 1393 LOperand* dividend = UseRegister(instr->left());
1395 int32_t divisor = instr->right()->GetInteger32Constant(); 1394 int32_t divisor = instr->right()->GetInteger32Constant();
1396 bool truncating = instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32); 1395 LOperand* temp = instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)
1397 LOperand* temp = truncating ? NULL : TempRegister(); 1396 ? NULL : TempRegister();
1398 LInstruction* result = 1397 LInstruction* result = DefineAsRegister(new(zone()) LDivByConstI(
1399 DefineAsRegister(new(zone()) LDivByConstI(dividend, divisor, temp)); 1398 dividend, divisor, temp));
1400 bool can_deopt = 1399 if (divisor == 0 ||
1401 divisor == 0 || 1400 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1402 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1401 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1403 instr->left()->RangeCanInclude(0) && divisor < 0) || 1402 result = AssignEnvironment(result);
1404 !truncating; 1403 }
1405 return can_deopt ? AssignEnvironment(result) : result; 1404 return result;
1406 } 1405 }
1407 1406
1408 1407
1409 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) { 1408 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* instr) {
1410 ASSERT(instr->representation().IsSmiOrInteger32()); 1409 ASSERT(instr->representation().IsSmiOrInteger32());
1411 ASSERT(instr->left()->representation().Equals(instr->representation())); 1410 ASSERT(instr->left()->representation().Equals(instr->representation()));
1412 ASSERT(instr->right()->representation().Equals(instr->representation())); 1411 ASSERT(instr->right()->representation().Equals(instr->representation()));
1413 LOperand* dividend = UseRegister(instr->left()); 1412 LOperand* dividend = UseRegister(instr->left());
1414 LOperand* divisor = UseRegister(instr->right()); 1413 LOperand* divisor = UseRegister(instr->right());
1415 LOperand* temp = instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) 1414 LOperand* temp = instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) { 1752 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) {
1754 ASSERT(instr->representation().IsInteger32()); 1753 ASSERT(instr->representation().IsInteger32());
1755 ASSERT(instr->left()->representation().Equals(instr->representation())); 1754 ASSERT(instr->left()->representation().Equals(instr->representation()));
1756 ASSERT(instr->right()->representation().Equals(instr->representation())); 1755 ASSERT(instr->right()->representation().Equals(instr->representation()));
1757 LOperand* dividend = UseRegister(instr->left()); 1756 LOperand* dividend = UseRegister(instr->left());
1758 int32_t divisor = instr->right()->GetInteger32Constant(); 1757 int32_t divisor = instr->right()->GetInteger32Constant();
1759 LInstruction* result = 1758 LInstruction* result =
1760 DefineAsRegister(new(zone()) LFlooringDivByConstI(dividend, divisor)); 1759 DefineAsRegister(new(zone()) LFlooringDivByConstI(dividend, divisor));
1761 bool can_deopt = 1760 bool can_deopt =
1762 divisor == 0 || 1761 divisor == 0 ||
1763 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1762 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0);
1764 instr->left()->RangeCanInclude(0) && divisor < 0);
1765 return can_deopt ? AssignEnvironment(result) : result; 1763 return can_deopt ? AssignEnvironment(result) : result;
1766 } 1764 }
1767 1765
1768 1766
1769 LInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) { 1767 LInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) {
1770 LOperand* dividend = UseRegister(instr->left()); 1768 LOperand* dividend = UseRegister(instr->left());
1771 LOperand* divisor = UseRegister(instr->right()); 1769 LOperand* divisor = UseRegister(instr->right());
1772 LOperand* remainder = TempRegister(); 1770 LOperand* remainder = TempRegister();
1773 LInstruction* result = 1771 LInstruction* result =
1774 DefineAsRegister(new(zone()) LFlooringDivI(dividend, divisor, remainder)); 1772 DefineAsRegister(new(zone()) LFlooringDivI(dividend, divisor, remainder));
(...skipping 30 matching lines...) Expand all
1805 return DefineAsRegister(new(zone()) LMathMinMax(left, right)); 1803 return DefineAsRegister(new(zone()) LMathMinMax(left, right));
1806 } 1804 }
1807 1805
1808 1806
1809 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { 1807 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1810 ASSERT(instr->representation().IsInteger32()); 1808 ASSERT(instr->representation().IsInteger32());
1811 ASSERT(instr->left()->representation().Equals(instr->representation())); 1809 ASSERT(instr->left()->representation().Equals(instr->representation()));
1812 ASSERT(instr->right()->representation().Equals(instr->representation())); 1810 ASSERT(instr->right()->representation().Equals(instr->representation()));
1813 LOperand* dividend = UseRegisterAtStart(instr->left()); 1811 LOperand* dividend = UseRegisterAtStart(instr->left());
1814 int32_t divisor = instr->right()->GetInteger32Constant(); 1812 int32_t divisor = instr->right()->GetInteger32Constant();
1815 LInstruction* result = 1813 LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I(
1816 DefineSameAsFirst(new(zone()) LModByPowerOf2I(dividend, divisor)); 1814 dividend, divisor));
1817 bool can_deopt = 1815 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1818 instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1816 result = AssignEnvironment(result);
1819 instr->left()->CanBeNegative(); 1817 }
1820 return can_deopt ? AssignEnvironment(result) : result; 1818 return result;
1821 } 1819 }
1822 1820
1823 1821
1824 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) { 1822 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) {
1825 ASSERT(instr->representation().IsInteger32()); 1823 ASSERT(instr->representation().IsInteger32());
1826 ASSERT(instr->left()->representation().Equals(instr->representation())); 1824 ASSERT(instr->left()->representation().Equals(instr->representation()));
1827 ASSERT(instr->right()->representation().Equals(instr->representation())); 1825 ASSERT(instr->right()->representation().Equals(instr->representation()));
1828 LOperand* dividend = UseRegister(instr->left()); 1826 LOperand* dividend = UseRegister(instr->left());
1829 int32_t divisor = instr->right()->GetInteger32Constant(); 1827 int32_t divisor = instr->right()->GetInteger32Constant();
1830 LOperand* temp = TempRegister(); 1828 LOperand* temp = TempRegister();
1831 LInstruction* result = 1829 LInstruction* result = DefineAsRegister(new(zone()) LModByConstI(
1832 DefineAsRegister(new(zone()) LModByConstI(dividend, divisor, temp)); 1830 dividend, divisor, temp));
1833 bool can_deopt = 1831 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1834 divisor == 0 || 1832 result = AssignEnvironment(result);
1835 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1833 }
1836 instr->left()->CanBeNegative()); 1834 return result;
1837 return can_deopt ? AssignEnvironment(result) : result;
1838 } 1835 }
1839 1836
1840 1837
1841 LInstruction* LChunkBuilder::DoModI(HMod* instr) { 1838 LInstruction* LChunkBuilder::DoModI(HMod* instr) {
1842 ASSERT(instr->representation().IsSmiOrInteger32()); 1839 ASSERT(instr->representation().IsSmiOrInteger32());
1843 ASSERT(instr->left()->representation().Equals(instr->representation())); 1840 ASSERT(instr->left()->representation().Equals(instr->representation()));
1844 ASSERT(instr->right()->representation().Equals(instr->representation())); 1841 ASSERT(instr->right()->representation().Equals(instr->representation()));
1845 LOperand* dividend = UseRegister(instr->left()); 1842 LOperand* dividend = UseRegister(instr->left());
1846 LOperand* divisor = UseRegister(instr->right()); 1843 LOperand* divisor = UseRegister(instr->right());
1847 LInstruction* result = 1844 LInstruction* result = DefineAsRegister(new(zone()) LModI(dividend, divisor));
1848 DefineAsRegister(new(zone()) LModI(dividend, divisor)); 1845 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1849 bool can_deopt = (instr->right()->CanBeZero() || 1846 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1850 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && 1847 result = AssignEnvironment(result);
1851 instr->left()->CanBeNegative() && instr->CanBeZero())); 1848 }
1852 return can_deopt ? AssignEnvironment(result) : result; 1849 return result;
1853 } 1850 }
1854 1851
1855 1852
1856 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1853 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1857 if (instr->representation().IsSmiOrInteger32()) { 1854 if (instr->representation().IsSmiOrInteger32()) {
1858 if (instr->RightIsPowerOf2()) { 1855 if (instr->RightIsPowerOf2()) {
1859 return DoModByPowerOf2I(instr); 1856 return DoModByPowerOf2I(instr);
1860 } else if (instr->right()->IsConstant()) { 1857 } else if (instr->right()->IsConstant()) {
1861 return DoModByConstI(instr); 1858 return DoModByConstI(instr);
1862 } else { 1859 } else {
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 2557
2561 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { 2558 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) {
2562 LOperand* receiver = UseRegister(instr->receiver()); 2559 LOperand* receiver = UseRegister(instr->receiver());
2563 LOperand* function = UseRegister(instr->function()); 2560 LOperand* function = UseRegister(instr->function());
2564 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); 2561 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function);
2565 return AssignEnvironment(DefineAsRegister(result)); 2562 return AssignEnvironment(DefineAsRegister(result));
2566 } 2563 }
2567 2564
2568 2565
2569 } } // namespace v8::internal 2566 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/a64/lithium-a64.h ('k') | src/a64/lithium-codegen-a64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698