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

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

Issue 141653015: Simplify HUnaryMathOperation::Canonicalize. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Moved forward declaration 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
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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 int32_t power_of_2_factor = 1289 int32_t power_of_2_factor =
1290 CompilerIntrinsics::CountTrailingZeros(divisor_abs); 1290 CompilerIntrinsics::CountTrailingZeros(divisor_abs);
1291 DivMagicNumbers magic_numbers = 1291 DivMagicNumbers magic_numbers =
1292 DivMagicNumberFor(divisor_abs >> power_of_2_factor); 1292 DivMagicNumberFor(divisor_abs >> power_of_2_factor);
1293 if (magic_numbers.M != InvalidDivMagicNumber.M) return true; 1293 if (magic_numbers.M != InvalidDivMagicNumber.M) return true;
1294 1294
1295 return false; 1295 return false;
1296 } 1296 }
1297 1297
1298 1298
1299 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
1300 if (CpuFeatures::IsSupported(SUDIV)) {
1301 // A value with an integer representation does not need to be transformed.
1302 if (divisor->representation().IsInteger32()) {
1303 return divisor;
1304 // A change from an integer32 can be replaced by the integer32 value.
1305 } else if (divisor->IsChange() &&
1306 HChange::cast(divisor)->from().IsInteger32()) {
1307 return HChange::cast(divisor)->value();
1308 }
1309 }
1310
1311 if (divisor->IsConstant() && HConstant::cast(divisor)->HasInteger32Value()) {
1312 HConstant* constant_val = HConstant::cast(divisor);
1313 int32_t int32_val = constant_val->Integer32Value();
1314 if (LChunkBuilder::HasMagicNumberForDivisor(int32_val) ||
1315 CpuFeatures::IsSupported(SUDIV)) {
1316 return constant_val->CopyToRepresentation(Representation::Integer32(),
1317 divisor->block()->zone());
1318 }
1319 }
1320
1321 return NULL;
1322 }
1323
1324
1325 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { 1299 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1300 // LMathFloorOfDiv can only handle a subset of divisors, so fall
1301 // back to a flooring division in all other cases.
1326 HValue* right = instr->right(); 1302 HValue* right = instr->right();
1303 if (!right->IsInteger32Constant() ||
1304 (right->IsInteger32Constant() &&
Benedikt Meurer 2014/01/24 12:33:21 right->IsInteger32Constant() is always true here.
Sven Panne 2014/01/24 14:02:05 Embarrassing... :-} This is what you get after edi
1305 !CpuFeatures::IsSupported(SUDIV) &&
1306 !HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value()))
1307 ) {
1308 LOperand* dividend = UseRegister(instr->left());
1309 LOperand* divisor = UseRegister(right);
1310 LOperand* temp = CpuFeatures::IsSupported(SUDIV) ? NULL : FixedTemp(d4);
1311 LDivI* div = new(zone()) LDivI(dividend, divisor, temp);
1312 return AssignEnvironment(DefineAsRegister(div));
1313 }
1314
1327 LOperand* dividend = UseRegister(instr->left()); 1315 LOperand* dividend = UseRegister(instr->left());
1328 LOperand* divisor = CpuFeatures::IsSupported(SUDIV) 1316 LOperand* divisor = CpuFeatures::IsSupported(SUDIV)
1329 ? UseRegister(right) 1317 ? UseRegister(right)
1330 : UseOrConstant(right); 1318 : UseOrConstant(right);
1331 LOperand* remainder = TempRegister(); 1319 LOperand* remainder = TempRegister();
1332 ASSERT(CpuFeatures::IsSupported(SUDIV) ||
1333 (right->IsConstant() &&
1334 HConstant::cast(right)->HasInteger32Value() &&
1335 HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value())));
1336 return AssignEnvironment(DefineAsRegister( 1320 return AssignEnvironment(DefineAsRegister(
1337 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder))); 1321 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder)));
1338 } 1322 }
1339 1323
1340 1324
1341 LInstruction* LChunkBuilder::DoMod(HMod* instr) { 1325 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1342 HValue* left = instr->left(); 1326 HValue* left = instr->left();
1343 HValue* right = instr->right(); 1327 HValue* right = instr->right();
1344 if (instr->representation().IsSmiOrInteger32()) { 1328 if (instr->representation().IsSmiOrInteger32()) {
1345 ASSERT(instr->left()->representation().Equals(instr->representation())); 1329 ASSERT(instr->left()->representation().Equals(instr->representation()));
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 } 2513 }
2530 2514
2531 2515
2532 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2516 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2533 LOperand* object = UseRegister(instr->object()); 2517 LOperand* object = UseRegister(instr->object());
2534 LOperand* index = UseRegister(instr->index()); 2518 LOperand* index = UseRegister(instr->index());
2535 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); 2519 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
2536 } 2520 }
2537 2521
2538 } } // namespace v8::internal 2522 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698