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

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

Issue 10382033: x86/x64 port of Math.floor(x/y) to use integer division for specific divisor (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 6 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/x64/lithium-x64.h ('k') | test/mjsunit/math-floor-of-div-minus-zero.js » ('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 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 LOperand* divisor = UseRegister(instr->right()); 1280 LOperand* divisor = UseRegister(instr->right());
1281 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); 1281 LDivI* result = new(zone()) LDivI(dividend, divisor, temp);
1282 return AssignEnvironment(DefineFixed(result, rax)); 1282 return AssignEnvironment(DefineFixed(result, rax));
1283 } else { 1283 } else {
1284 ASSERT(instr->representation().IsTagged()); 1284 ASSERT(instr->representation().IsTagged());
1285 return DoArithmeticT(Token::DIV, instr); 1285 return DoArithmeticT(Token::DIV, instr);
1286 } 1286 }
1287 } 1287 }
1288 1288
1289 1289
1290 HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue* dividend) {
1291 // A value with an integer representation does not need to be transformed.
1292 if (dividend->representation().IsInteger32()) {
1293 return dividend;
1294 // A change from an integer32 can be replaced by the integer32 value.
1295 } else if (dividend->IsChange() &&
1296 HChange::cast(dividend)->from().IsInteger32()) {
1297 return HChange::cast(dividend)->value();
1298 }
1299 return NULL;
1300 }
1301
1302
1303 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
1304 if (divisor->IsConstant() &&
1305 HConstant::cast(divisor)->HasInteger32Value()) {
1306 HConstant* constant_val = HConstant::cast(divisor);
1307 return constant_val->CopyToRepresentation(Representation::Integer32(),
1308 divisor->block()->zone());
1309 }
1310 return NULL;
1311 }
1312
1313
1290 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1314 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1291 UNIMPLEMENTED(); 1315 HValue* right = instr->right();
1292 return NULL; 1316 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value());
1317 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right));
1318 int32_t divisor_si = HConstant::cast(right)->Integer32Value();
1319 if (divisor_si == 0) {
1320 LOperand* dividend = UseRegister(instr->left());
1321 return AssignEnvironment(DefineAsRegister(
1322 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL)));
1323 } else if (IsPowerOf2(abs(divisor_si))) {
1324 LOperand* dividend = UseRegisterAtStart(instr->left());
1325 LInstruction* result = DefineAsRegister(
1326 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL));
1327 return divisor_si < 0 ? AssignEnvironment(result) : result;
1328 } else {
1329 // use two r64
1330 LOperand* dividend = UseRegisterAtStart(instr->left());
1331 LOperand* temp = TempRegister();
1332 LInstruction* result = DefineAsRegister(
1333 new(zone()) LMathFloorOfDiv(dividend, divisor, temp));
1334 return divisor_si < 0 ? AssignEnvironment(result) : result;
1335 }
1293 } 1336 }
1294 1337
1295 1338
1296 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1339 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1297 if (instr->representation().IsInteger32()) { 1340 if (instr->representation().IsInteger32()) {
1298 ASSERT(instr->left()->representation().IsInteger32()); 1341 ASSERT(instr->left()->representation().IsInteger32());
1299 ASSERT(instr->right()->representation().IsInteger32()); 1342 ASSERT(instr->right()->representation().IsInteger32());
1300 1343
1301 LInstruction* result; 1344 LInstruction* result;
1302 if (instr->HasPowerOf2Divisor()) { 1345 if (instr->HasPowerOf2Divisor()) {
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2369 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2327 LOperand* object = UseRegister(instr->object()); 2370 LOperand* object = UseRegister(instr->object());
2328 LOperand* index = UseTempRegister(instr->index()); 2371 LOperand* index = UseTempRegister(instr->index());
2329 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2372 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2330 } 2373 }
2331 2374
2332 2375
2333 } } // namespace v8::internal 2376 } } // namespace v8::internal
2334 2377
2335 #endif // V8_TARGET_ARCH_X64 2378 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.h ('k') | test/mjsunit/math-floor-of-div-minus-zero.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698