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

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

Issue 11624022: Handle non-constant divisor in MathFloorOfDiv, on ia32/x64 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 11 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/ia32/lithium-ia32.h ('k') | src/x64/lithium-codegen-x64.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 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 } 1298 }
1299 1299
1300 1300
1301 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { 1301 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
1302 if (divisor->IsConstant() && 1302 if (divisor->IsConstant() &&
1303 HConstant::cast(divisor)->HasInteger32Value()) { 1303 HConstant::cast(divisor)->HasInteger32Value()) {
1304 HConstant* constant_val = HConstant::cast(divisor); 1304 HConstant* constant_val = HConstant::cast(divisor);
1305 return constant_val->CopyToRepresentation(Representation::Integer32(), 1305 return constant_val->CopyToRepresentation(Representation::Integer32(),
1306 divisor->block()->zone()); 1306 divisor->block()->zone());
1307 } 1307 }
1308 // A value with an integer representation does not need to be transformed.
1309 if (divisor->representation().IsInteger32()) {
1310 return divisor;
1311 // A change from an integer32 can be replaced by the integer32 value.
1312 } else if (divisor->IsChange() &&
1313 HChange::cast(divisor)->from().IsInteger32()) {
1314 return HChange::cast(divisor)->value();
1315 }
1308 return NULL; 1316 return NULL;
1309 } 1317 }
1310 1318
1311 1319
1312 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1320 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1313 HValue* right = instr->right(); 1321 HValue* right = instr->right();
1322 if (!right->IsConstant()) {
1323 ASSERT(right->representation().IsInteger32());
1324 // The temporary operand is necessary to ensure that right is not allocated
1325 // into edx.
1326 LOperand* temp = FixedTemp(edx);
1327 LOperand* dividend = UseFixed(instr->left(), eax);
1328 LOperand* divisor = UseRegister(instr->right());
1329 LDivI* flooring_div = new(zone()) LDivI(dividend, divisor, temp);
1330 return AssignEnvironment(DefineFixed(flooring_div, eax));
1331 }
1332
1314 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value()); 1333 ASSERT(right->IsConstant() && HConstant::cast(right)->HasInteger32Value());
1315 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right)); 1334 LOperand* divisor = chunk_->DefineConstantOperand(HConstant::cast(right));
1316 int32_t divisor_si = HConstant::cast(right)->Integer32Value(); 1335 int32_t divisor_si = HConstant::cast(right)->Integer32Value();
1317 if (divisor_si == 0) { 1336 if (divisor_si == 0) {
1318 LOperand* dividend = UseRegister(instr->left()); 1337 LOperand* dividend = UseRegister(instr->left());
1319 return AssignEnvironment(DefineAsRegister( 1338 return AssignEnvironment(DefineAsRegister(
1320 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL))); 1339 new(zone()) LMathFloorOfDiv(dividend, divisor, NULL)));
1321 } else if (IsPowerOf2(abs(divisor_si))) { 1340 } else if (IsPowerOf2(abs(divisor_si))) {
1322 // use dividend as temp if divisor < 0 && divisor != -1 1341 // use dividend as temp if divisor < 0 && divisor != -1
1323 LOperand* dividend = divisor_si < -1 ? UseTempRegister(instr->left()) : 1342 LOperand* dividend = divisor_si < -1 ? UseTempRegister(instr->left()) :
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2497 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2479 LOperand* object = UseRegister(instr->object()); 2498 LOperand* object = UseRegister(instr->object());
2480 LOperand* index = UseTempRegister(instr->index()); 2499 LOperand* index = UseTempRegister(instr->index());
2481 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2500 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2482 } 2501 }
2483 2502
2484 2503
2485 } } // namespace v8::internal 2504 } } // namespace v8::internal
2486 2505
2487 #endif // V8_TARGET_ARCH_IA32 2506 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698