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

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

Issue 196603004: Handle flooring division in LCodeGen::DoDivByConstI on ARM, too. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 years, 9 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 | « no previous file | no next file » | 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 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 __ mov(ip, Operand(divisor)); 1358 __ mov(ip, Operand(divisor));
1359 __ smull(scratch0(), ip, result, ip); 1359 __ smull(scratch0(), ip, result, ip);
1360 __ sub(scratch0(), scratch0(), dividend, SetCC); 1360 __ sub(scratch0(), scratch0(), dividend, SetCC);
1361 DeoptimizeIf(ne, instr->environment()); 1361 DeoptimizeIf(ne, instr->environment());
1362 } 1362 }
1363 } 1363 }
1364 1364
1365 1365
1366 void LCodeGen::DoDivI(LDivI* instr) { 1366 void LCodeGen::DoDivI(LDivI* instr) {
1367 HBinaryOperation* hdiv = instr->hydrogen(); 1367 HBinaryOperation* hdiv = instr->hydrogen();
1368 const Register left = ToRegister(instr->left()); 1368 Register left = ToRegister(instr->left());
1369 const Register right = ToRegister(instr->right()); 1369 Register right = ToRegister(instr->right());
1370 const Register result = ToRegister(instr->result()); 1370 Register result = ToRegister(instr->result());
1371 1371
1372 // Check for x / 0. 1372 // Check for x / 0.
1373 if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) { 1373 if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) {
1374 __ cmp(right, Operand::Zero()); 1374 __ cmp(right, Operand::Zero());
1375 DeoptimizeIf(eq, instr->environment()); 1375 DeoptimizeIf(eq, instr->environment());
1376 } 1376 }
1377 1377
1378 // Check for (0 / -x) that will produce negative zero. 1378 // Check for (0 / -x) that will produce negative zero.
1379 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) { 1379 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero)) {
1380 Label positive; 1380 Label positive;
(...skipping 14 matching lines...) Expand all
1395 // We don't need to check for overflow when truncating with sdiv 1395 // We don't need to check for overflow when truncating with sdiv
1396 // support because, on ARM, sdiv kMinInt, -1 -> kMinInt. 1396 // support because, on ARM, sdiv kMinInt, -1 -> kMinInt.
1397 __ cmp(left, Operand(kMinInt)); 1397 __ cmp(left, Operand(kMinInt));
1398 __ cmp(right, Operand(-1), eq); 1398 __ cmp(right, Operand(-1), eq);
1399 DeoptimizeIf(eq, instr->environment()); 1399 DeoptimizeIf(eq, instr->environment());
1400 } 1400 }
1401 1401
1402 if (CpuFeatures::IsSupported(SUDIV)) { 1402 if (CpuFeatures::IsSupported(SUDIV)) {
1403 CpuFeatureScope scope(masm(), SUDIV); 1403 CpuFeatureScope scope(masm(), SUDIV);
1404 __ sdiv(result, left, right); 1404 __ sdiv(result, left, right);
1405
1406 if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
1407 // Compute remainder and deopt if it's not zero.
1408 const Register remainder = scratch0();
1409 __ mls(remainder, result, right, left);
1410 __ cmp(remainder, Operand::Zero());
1411 DeoptimizeIf(ne, instr->environment());
1412 }
1413 } else { 1405 } else {
1414 const DoubleRegister vleft = ToDoubleRegister(instr->temp()); 1406 DoubleRegister vleft = ToDoubleRegister(instr->temp());
1415 const DoubleRegister vright = double_scratch0(); 1407 DoubleRegister vright = double_scratch0();
1416 __ vmov(double_scratch0().low(), left); 1408 __ vmov(double_scratch0().low(), left);
1417 __ vcvt_f64_s32(vleft, double_scratch0().low()); 1409 __ vcvt_f64_s32(vleft, double_scratch0().low());
1418 __ vmov(double_scratch0().low(), right); 1410 __ vmov(double_scratch0().low(), right);
1419 __ vcvt_f64_s32(vright, double_scratch0().low()); 1411 __ vcvt_f64_s32(vright, double_scratch0().low());
1420 __ vdiv(vleft, vleft, vright); // vleft now contains the result. 1412 __ vdiv(vleft, vleft, vright); // vleft now contains the result.
1421 __ vcvt_s32_f64(double_scratch0().low(), vleft); 1413 __ vcvt_s32_f64(double_scratch0().low(), vleft);
1422 __ vmov(result, double_scratch0().low()); 1414 __ vmov(result, double_scratch0().low());
1415 }
1423 1416
1424 if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) { 1417 if (hdiv->IsMathFloorOfDiv()) {
1425 // Deopt if exact conversion to integer was not possible. 1418 Label done;
1426 // Use vright as scratch register. 1419 Register remainder = scratch0();
1427 __ vcvt_f64_s32(double_scratch0(), double_scratch0().low()); 1420 __ mls(remainder, result, right, left);
1428 __ VFPCompareAndSetFlags(vleft, double_scratch0()); 1421 __ cmp(remainder, Operand::Zero());
1429 DeoptimizeIf(ne, instr->environment()); 1422 __ b(eq, &done);
1430 } 1423 __ eor(remainder, remainder, Operand(right));
1424 __ add(result, result, Operand(remainder, ASR, 31));
1425 __ bind(&done);
1426 } else if (!hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
1427 // Compute remainder and deopt if it's not zero.
1428 Register remainder = scratch0();
1429 __ mls(remainder, result, right, left);
1430 __ cmp(remainder, Operand::Zero());
1431 DeoptimizeIf(ne, instr->environment());
1431 } 1432 }
1432 } 1433 }
1433 1434
1434 1435
1435 void LCodeGen::DoMultiplyAddD(LMultiplyAddD* instr) { 1436 void LCodeGen::DoMultiplyAddD(LMultiplyAddD* instr) {
1436 DwVfpRegister addend = ToDoubleRegister(instr->addend()); 1437 DwVfpRegister addend = ToDoubleRegister(instr->addend());
1437 DwVfpRegister multiplier = ToDoubleRegister(instr->multiplier()); 1438 DwVfpRegister multiplier = ToDoubleRegister(instr->multiplier());
1438 DwVfpRegister multiplicand = ToDoubleRegister(instr->multiplicand()); 1439 DwVfpRegister multiplicand = ToDoubleRegister(instr->multiplicand());
1439 1440
1440 // This is computed in-place. 1441 // This is computed in-place.
(...skipping 4284 matching lines...) Expand 10 before | Expand all | Expand 10 after
5725 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); 5726 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index));
5726 __ ldr(result, FieldMemOperand(scratch, 5727 __ ldr(result, FieldMemOperand(scratch,
5727 FixedArray::kHeaderSize - kPointerSize)); 5728 FixedArray::kHeaderSize - kPointerSize));
5728 __ bind(&done); 5729 __ bind(&done);
5729 } 5730 }
5730 5731
5731 5732
5732 #undef __ 5733 #undef __
5733 5734
5734 } } // namespace v8::internal 5735 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698