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

Side by Side Diff: src/arm/lithium-codegen-arm.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/arm/lithium-arm.cc ('k') | src/hydrogen-instructions.h » ('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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1108
1109 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { 1109 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) {
1110 GenerateOsrPrologue(); 1110 GenerateOsrPrologue();
1111 } 1111 }
1112 1112
1113 1113
1114 void LCodeGen::DoModI(LModI* instr) { 1114 void LCodeGen::DoModI(LModI* instr) {
1115 HMod* hmod = instr->hydrogen(); 1115 HMod* hmod = instr->hydrogen();
1116 HValue* left = hmod->left(); 1116 HValue* left = hmod->left();
1117 HValue* right = hmod->right(); 1117 HValue* right = hmod->right();
1118 if (hmod->HasPowerOf2Divisor()) { 1118 if (hmod->RightIsPowerOf2()) {
1119 // TODO(svenpanne) We should really do the strength reduction on the 1119 // TODO(svenpanne) We should really do the strength reduction on the
1120 // Hydrogen level. 1120 // Hydrogen level.
1121 Register left_reg = ToRegister(instr->left()); 1121 Register left_reg = ToRegister(instr->left());
1122 Register result_reg = ToRegister(instr->result()); 1122 Register result_reg = ToRegister(instr->result());
1123 1123
1124 // Note: The code below even works when right contains kMinInt. 1124 // Note: The code below even works when right contains kMinInt.
1125 int32_t divisor = Abs(right->GetInteger32Constant()); 1125 int32_t divisor = Abs(right->GetInteger32Constant());
1126 1126
1127 Label left_is_not_negative, done; 1127 Label left_is_not_negative, done;
1128 if (left->CanBeNegative()) { 1128 if (left->CanBeNegative()) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 // This sequence could be replaced with 'mls' when 1338 // This sequence could be replaced with 'mls' when
1339 // it gets implemented. 1339 // it gets implemented.
1340 __ mul(scratch, result, ip); 1340 __ mul(scratch, result, ip);
1341 __ sub(remainder, dividend, scratch); 1341 __ sub(remainder, dividend, scratch);
1342 } 1342 }
1343 } 1343 }
1344 } 1344 }
1345 1345
1346 1346
1347 void LCodeGen::DoDivI(LDivI* instr) { 1347 void LCodeGen::DoDivI(LDivI* instr) {
1348 if (instr->hydrogen()->HasPowerOf2Divisor()) { 1348 if (!instr->is_flooring() && instr->hydrogen()->RightIsPowerOf2()) {
1349 const Register dividend = ToRegister(instr->left()); 1349 const Register dividend = ToRegister(instr->left());
1350 const Register result = ToRegister(instr->result()); 1350 const Register result = ToRegister(instr->result());
1351 int32_t divisor = instr->hydrogen()->right()->GetInteger32Constant(); 1351 int32_t divisor = instr->hydrogen()->right()->GetInteger32Constant();
1352 int32_t test_value = 0; 1352 int32_t test_value = 0;
1353 int32_t power = 0; 1353 int32_t power = 0;
1354 1354
1355 if (divisor > 0) { 1355 if (divisor > 0) {
1356 test_value = divisor - 1; 1356 test_value = divisor - 1;
1357 power = WhichPowerOf2(divisor); 1357 power = WhichPowerOf2(divisor);
1358 } else { 1358 } else {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 } 1395 }
1396 1396
1397 return; 1397 return;
1398 } 1398 }
1399 1399
1400 const Register left = ToRegister(instr->left()); 1400 const Register left = ToRegister(instr->left());
1401 const Register right = ToRegister(instr->right()); 1401 const Register right = ToRegister(instr->right());
1402 const Register result = ToRegister(instr->result()); 1402 const Register result = ToRegister(instr->result());
1403 1403
1404 // Check for x / 0. 1404 // Check for x / 0.
1405 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { 1405 if (instr->hydrogen_value()->CheckFlag(HValue::kCanBeDivByZero)) {
1406 __ cmp(right, Operand::Zero()); 1406 __ cmp(right, Operand::Zero());
1407 DeoptimizeIf(eq, instr->environment()); 1407 DeoptimizeIf(eq, instr->environment());
1408 } 1408 }
1409 1409
1410 // Check for (0 / -x) that will produce negative zero. 1410 // Check for (0 / -x) that will produce negative zero.
1411 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 1411 if (instr->hydrogen_value()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1412 Label positive; 1412 Label positive;
1413 if (!instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { 1413 if (!instr->hydrogen_value()->CheckFlag(HValue::kCanBeDivByZero)) {
1414 // Do the test only if it hadn't be done above. 1414 // Do the test only if it hadn't be done above.
1415 __ cmp(right, Operand::Zero()); 1415 __ cmp(right, Operand::Zero());
1416 } 1416 }
1417 __ b(pl, &positive); 1417 __ b(pl, &positive);
1418 __ cmp(left, Operand::Zero()); 1418 __ cmp(left, Operand::Zero());
1419 DeoptimizeIf(eq, instr->environment()); 1419 DeoptimizeIf(eq, instr->environment());
1420 __ bind(&positive); 1420 __ bind(&positive);
1421 } 1421 }
1422 1422
1423 // Check for (kMinInt / -1). 1423 // Check for (kMinInt / -1).
1424 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow) && 1424 if (instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow) &&
1425 (!CpuFeatures::IsSupported(SUDIV) || 1425 (!CpuFeatures::IsSupported(SUDIV) ||
1426 !instr->hydrogen()->CheckFlag(HValue::kAllUsesTruncatingToInt32))) { 1426 !instr->hydrogen_value()->CheckFlag(
1427 HValue::kAllUsesTruncatingToInt32))) {
1427 // We don't need to check for overflow when truncating with sdiv 1428 // We don't need to check for overflow when truncating with sdiv
1428 // support because, on ARM, sdiv kMinInt, -1 -> kMinInt. 1429 // support because, on ARM, sdiv kMinInt, -1 -> kMinInt.
1429 __ cmp(left, Operand(kMinInt)); 1430 __ cmp(left, Operand(kMinInt));
1430 __ cmp(right, Operand(-1), eq); 1431 __ cmp(right, Operand(-1), eq);
1431 DeoptimizeIf(eq, instr->environment()); 1432 DeoptimizeIf(eq, instr->environment());
1432 } 1433 }
1433 1434
1434 if (CpuFeatures::IsSupported(SUDIV)) { 1435 if (CpuFeatures::IsSupported(SUDIV)) {
1435 CpuFeatureScope scope(masm(), SUDIV); 1436 CpuFeatureScope scope(masm(), SUDIV);
1436 __ sdiv(result, left, right); 1437 __ sdiv(result, left, right);
1437 1438
1438 if (!instr->hydrogen()->CheckFlag( 1439 if (!instr->hydrogen_value()->CheckFlag(
1439 HInstruction::kAllUsesTruncatingToInt32)) { 1440 HInstruction::kAllUsesTruncatingToInt32)) {
1440 // Compute remainder and deopt if it's not zero. 1441 // Compute remainder and deopt if it's not zero.
1441 const Register remainder = scratch0(); 1442 const Register remainder = scratch0();
1442 __ mls(remainder, result, right, left); 1443 __ mls(remainder, result, right, left);
1443 __ cmp(remainder, Operand::Zero()); 1444 __ cmp(remainder, Operand::Zero());
1444 DeoptimizeIf(ne, instr->environment()); 1445 DeoptimizeIf(ne, instr->environment());
1445 } 1446 }
1446 } else { 1447 } else {
1447 const DoubleRegister vleft = ToDoubleRegister(instr->temp()); 1448 const DoubleRegister vleft = ToDoubleRegister(instr->temp());
1448 const DoubleRegister vright = double_scratch0(); 1449 const DoubleRegister vright = double_scratch0();
1449 __ vmov(double_scratch0().low(), left); 1450 __ vmov(double_scratch0().low(), left);
1450 __ vcvt_f64_s32(vleft, double_scratch0().low()); 1451 __ vcvt_f64_s32(vleft, double_scratch0().low());
1451 __ vmov(double_scratch0().low(), right); 1452 __ vmov(double_scratch0().low(), right);
1452 __ vcvt_f64_s32(vright, double_scratch0().low()); 1453 __ vcvt_f64_s32(vright, double_scratch0().low());
1453 __ vdiv(vleft, vleft, vright); // vleft now contains the result. 1454 __ vdiv(vleft, vleft, vright); // vleft now contains the result.
1454 __ vcvt_s32_f64(double_scratch0().low(), vleft); 1455 __ vcvt_s32_f64(double_scratch0().low(), vleft);
1455 __ vmov(result, double_scratch0().low()); 1456 __ vmov(result, double_scratch0().low());
1456 1457
1457 if (!instr->hydrogen()->CheckFlag( 1458 if (!instr->hydrogen_value()->CheckFlag(
1458 HInstruction::kAllUsesTruncatingToInt32)) { 1459 HInstruction::kAllUsesTruncatingToInt32)) {
1459 // Deopt if exact conversion to integer was not possible. 1460 // Deopt if exact conversion to integer was not possible.
1460 // Use vright as scratch register. 1461 // Use vright as scratch register.
1461 __ vcvt_f64_s32(double_scratch0(), double_scratch0().low()); 1462 __ vcvt_f64_s32(double_scratch0(), double_scratch0().low());
1462 __ VFPCompareAndSetFlags(vleft, double_scratch0()); 1463 __ VFPCompareAndSetFlags(vleft, double_scratch0());
1463 DeoptimizeIf(ne, instr->environment()); 1464 DeoptimizeIf(ne, instr->environment());
1464 } 1465 }
1465 } 1466 }
1466 } 1467 }
1467 1468
(...skipping 4357 matching lines...) Expand 10 before | Expand all | Expand 10 after
5825 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); 5826 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index));
5826 __ ldr(result, FieldMemOperand(scratch, 5827 __ ldr(result, FieldMemOperand(scratch,
5827 FixedArray::kHeaderSize - kPointerSize)); 5828 FixedArray::kHeaderSize - kPointerSize));
5828 __ bind(&done); 5829 __ bind(&done);
5829 } 5830 }
5830 5831
5831 5832
5832 #undef __ 5833 #undef __
5833 5834
5834 } } // namespace v8::internal 5835 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698