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

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

Issue 141653015: Simplify HUnaryMathOperation::Canonicalize. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback Created 6 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/mips/lithium-mips.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 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 int32_t power_of_2_factor = 1288 int32_t power_of_2_factor =
1289 CompilerIntrinsics::CountTrailingZeros(divisor_abs); 1289 CompilerIntrinsics::CountTrailingZeros(divisor_abs);
1290 DivMagicNumbers magic_numbers = 1290 DivMagicNumbers magic_numbers =
1291 DivMagicNumberFor(divisor_abs >> power_of_2_factor); 1291 DivMagicNumberFor(divisor_abs >> power_of_2_factor);
1292 if (magic_numbers.M != InvalidDivMagicNumber.M) return true; 1292 if (magic_numbers.M != InvalidDivMagicNumber.M) return true;
1293 1293
1294 return false; 1294 return false;
1295 } 1295 }
1296 1296
1297 1297
1298 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
1299 // Only optimize when we have magic numbers for the divisor.
1300 // The standard integer division routine is usually slower than transitionning
1301 // to FPU.
1302 if (divisor->IsConstant() &&
1303 HConstant::cast(divisor)->HasInteger32Value()) {
1304 HConstant* constant_val = HConstant::cast(divisor);
1305 return constant_val->CopyToRepresentation(Representation::Integer32(),
1306 divisor->block()->zone());
1307 }
1308 return NULL;
1309 }
1310
1311
1312 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1298 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1313 HValue* right = instr->right(); 1299 HValue* right = instr->right();
1314 LOperand* dividend = UseRegister(instr->left()); 1300 LOperand* dividend = UseRegister(instr->left());
1315 LOperand* divisor = UseRegisterOrConstant(right); 1301 LOperand* divisor = UseRegisterOrConstant(right);
1316 LOperand* remainder = TempRegister(); 1302 LOperand* remainder = TempRegister();
1317 return AssignEnvironment(DefineAsRegister( 1303 return AssignEnvironment(DefineAsRegister(
1318 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder))); 1304 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder)));
1319 } 1305 }
1320 1306
1321 1307
1322 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1308 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1323 HValue* left = instr->left(); 1309 HValue* left = instr->left();
1324 HValue* right = instr->right(); 1310 HValue* right = instr->right();
1325 if (instr->representation().IsSmiOrInteger32()) { 1311 if (instr->representation().IsSmiOrInteger32()) {
1326 ASSERT(instr->left()->representation().Equals(instr->representation())); 1312 ASSERT(instr->left()->representation().Equals(instr->representation()));
1327 ASSERT(instr->right()->representation().Equals(instr->representation())); 1313 ASSERT(instr->right()->representation().Equals(instr->representation()));
1328 if (instr->HasPowerOf2Divisor()) { 1314 if (instr->RightIsPowerOf2()) {
1329 ASSERT(!right->CanBeZero()); 1315 ASSERT(!right->CanBeZero());
1330 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), 1316 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left),
1331 UseConstant(right)); 1317 UseConstant(right));
1332 LInstruction* result = DefineAsRegister(mod); 1318 LInstruction* result = DefineAsRegister(mod);
1333 return (left->CanBeNegative() && 1319 return (left->CanBeNegative() &&
1334 instr->CheckFlag(HValue::kBailoutOnMinusZero)) 1320 instr->CheckFlag(HValue::kBailoutOnMinusZero))
1335 ? AssignEnvironment(result) 1321 ? AssignEnvironment(result)
1336 : result; 1322 : result;
1337 } else { 1323 } else {
1338 LModI* mod = new(zone()) LModI(UseRegister(left), 1324 LModI* mod = new(zone()) LModI(UseRegister(left),
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 2441
2456 2442
2457 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2443 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2458 LOperand* object = UseRegister(instr->object()); 2444 LOperand* object = UseRegister(instr->object());
2459 LOperand* index = UseRegister(instr->index()); 2445 LOperand* index = UseRegister(instr->index());
2460 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); 2446 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
2461 } 2447 }
2462 2448
2463 2449
2464 } } // namespace v8::internal 2450 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-mips.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698