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

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

Issue 191293013: Cleanup some of the range uses in ModI/DivI. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE 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 | « src/a64/lithium-a64.cc ('k') | src/arm/lithium-arm.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 2589 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 2600
2601 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { 2601 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) {
2602 Register dividend = ToRegister32(instr->dividend()); 2602 Register dividend = ToRegister32(instr->dividend());
2603 int32_t divisor = instr->divisor(); 2603 int32_t divisor = instr->divisor();
2604 Register result = ToRegister32(instr->result()); 2604 Register result = ToRegister32(instr->result());
2605 ASSERT(divisor == kMinInt || (divisor != 0 && IsPowerOf2(Abs(divisor)))); 2605 ASSERT(divisor == kMinInt || (divisor != 0 && IsPowerOf2(Abs(divisor))));
2606 ASSERT(!result.is(dividend)); 2606 ASSERT(!result.is(dividend));
2607 2607
2608 // Check for (0 / -x) that will produce negative zero. 2608 // Check for (0 / -x) that will produce negative zero.
2609 HDiv* hdiv = instr->hydrogen(); 2609 HDiv* hdiv = instr->hydrogen();
2610 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && 2610 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
2611 hdiv->left()->RangeCanInclude(0) && divisor < 0) {
2612 __ Cmp(dividend, 0); 2611 __ Cmp(dividend, 0);
2613 DeoptimizeIf(eq, instr->environment()); 2612 DeoptimizeIf(eq, instr->environment());
2614 } 2613 }
2615 // Check for (kMinInt / -1). 2614 // Check for (kMinInt / -1).
2616 if (hdiv->CheckFlag(HValue::kCanOverflow) && 2615 if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) {
2617 hdiv->left()->RangeCanInclude(kMinInt) && divisor == -1) {
2618 __ Cmp(dividend, kMinInt); 2616 __ Cmp(dividend, kMinInt);
2619 DeoptimizeIf(eq, instr->environment()); 2617 DeoptimizeIf(eq, instr->environment());
2620 } 2618 }
2621 // Deoptimize if remainder will not be 0. 2619 // Deoptimize if remainder will not be 0.
2622 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && 2620 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
2623 divisor != 1 && divisor != -1) { 2621 divisor != 1 && divisor != -1) {
2624 int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1); 2622 int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1);
2625 __ Tst(dividend, mask); 2623 __ Tst(dividend, mask);
2626 DeoptimizeIf(ne, instr->environment()); 2624 DeoptimizeIf(ne, instr->environment());
2627 } 2625 }
(...skipping 22 matching lines...) Expand all
2650 Register result = ToRegister32(instr->result()); 2648 Register result = ToRegister32(instr->result());
2651 ASSERT(!AreAliased(dividend, result)); 2649 ASSERT(!AreAliased(dividend, result));
2652 2650
2653 if (divisor == 0) { 2651 if (divisor == 0) {
2654 Deoptimize(instr->environment()); 2652 Deoptimize(instr->environment());
2655 return; 2653 return;
2656 } 2654 }
2657 2655
2658 // Check for (0 / -x) that will produce negative zero. 2656 // Check for (0 / -x) that will produce negative zero.
2659 HDiv* hdiv = instr->hydrogen(); 2657 HDiv* hdiv = instr->hydrogen();
2660 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && 2658 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
2661 hdiv->left()->RangeCanInclude(0) && divisor < 0) {
2662 DeoptimizeIfZero(dividend, instr->environment()); 2659 DeoptimizeIfZero(dividend, instr->environment());
2663 } 2660 }
2664 2661
2665 __ FlooringDiv(result, dividend, Abs(divisor)); 2662 __ FlooringDiv(result, dividend, Abs(divisor));
2666 __ Add(result, result, Operand(dividend, LSR, 31)); 2663 __ Add(result, result, Operand(dividend, LSR, 31));
2667 if (divisor < 0) __ Neg(result, result); 2664 if (divisor < 0) __ Neg(result, result);
2668 2665
2669 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { 2666 if (!hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
2670 Register temp = ToRegister32(instr->temp()); 2667 Register temp = ToRegister32(instr->temp());
2671 ASSERT(!AreAliased(dividend, result, temp)); 2668 ASSERT(!AreAliased(dividend, result, temp));
2672 __ Sxtw(dividend.X(), dividend); 2669 __ Sxtw(dividend.X(), dividend);
2673 __ Mov(temp, divisor); 2670 __ Mov(temp, divisor);
2674 __ Smsubl(temp.X(), result, temp, dividend.X()); 2671 __ Smsubl(temp.X(), result, temp, dividend.X());
2675 DeoptimizeIfNotZero(temp, instr->environment()); 2672 DeoptimizeIfNotZero(temp, instr->environment());
2676 } 2673 }
2677 } 2674 }
2678 2675
2679 2676
2680 void LCodeGen::DoDivI(LDivI* instr) { 2677 void LCodeGen::DoDivI(LDivI* instr) {
2678 HBinaryOperation* hdiv = instr->hydrogen();
2681 Register dividend = ToRegister32(instr->left()); 2679 Register dividend = ToRegister32(instr->left());
2682 Register divisor = ToRegister32(instr->right()); 2680 Register divisor = ToRegister32(instr->right());
2683 Register result = ToRegister32(instr->result()); 2681 Register result = ToRegister32(instr->result());
2684 HValue* hdiv = instr->hydrogen_value();
2685 2682
2686 // Issue the division first, and then check for any deopt cases whilst the 2683 // Issue the division first, and then check for any deopt cases whilst the
2687 // result is computed. 2684 // result is computed.
2688 __ Sdiv(result, dividend, divisor); 2685 __ Sdiv(result, dividend, divisor);
2689 2686
2690 if (hdiv->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { 2687 if (hdiv->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
2691 ASSERT_EQ(NULL, instr->temp()); 2688 ASSERT_EQ(NULL, instr->temp());
2692 return; 2689 return;
2693 } 2690 }
2694 2691
2695 Label deopt; 2692 Label deopt;
2696 // Check for x / 0. 2693 // Check for x / 0.
2697 if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) { 2694 if (hdiv->CheckFlag(HValue::kCanBeDivByZero)) {
2698 __ Cbz(divisor, &deopt); 2695 __ Cbz(divisor, &deopt);
2699 } 2696 }
2700 2697
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3888 Register result = ToRegister32(instr->result()); 3885 Register result = ToRegister32(instr->result());
3889 ASSERT(!AreAliased(dividend, result)); 3886 ASSERT(!AreAliased(dividend, result));
3890 3887
3891 if (divisor == 0) { 3888 if (divisor == 0) {
3892 Deoptimize(instr->environment()); 3889 Deoptimize(instr->environment());
3893 return; 3890 return;
3894 } 3891 }
3895 3892
3896 // Check for (0 / -x) that will produce negative zero. 3893 // Check for (0 / -x) that will produce negative zero.
3897 HMathFloorOfDiv* hdiv = instr->hydrogen(); 3894 HMathFloorOfDiv* hdiv = instr->hydrogen();
3898 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && 3895 if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) {
3899 hdiv->left()->RangeCanInclude(0) && divisor < 0) {
3900 __ Cmp(dividend, 0); 3896 __ Cmp(dividend, 0);
3901 DeoptimizeIf(eq, instr->environment()); 3897 DeoptimizeIf(eq, instr->environment());
3902 } 3898 }
3903 3899
3904 __ FlooringDiv(result, dividend, divisor); 3900 __ FlooringDiv(result, dividend, divisor);
3905 } 3901 }
3906 3902
3907 3903
3908 void LCodeGen::DoFlooringDivI(LFlooringDivI* instr) { 3904 void LCodeGen::DoFlooringDivI(LFlooringDivI* instr) {
3909 Register dividend = ToRegister32(instr->dividend()); 3905 Register dividend = ToRegister32(instr->dividend());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
4177 } 4173 }
4178 4174
4179 __ FlooringDiv(result, dividend, Abs(divisor)); 4175 __ FlooringDiv(result, dividend, Abs(divisor));
4180 __ Add(result, result, Operand(dividend, LSR, 31)); 4176 __ Add(result, result, Operand(dividend, LSR, 31));
4181 __ Sxtw(dividend.X(), dividend); 4177 __ Sxtw(dividend.X(), dividend);
4182 __ Mov(temp, Abs(divisor)); 4178 __ Mov(temp, Abs(divisor));
4183 __ Smsubl(result.X(), result, temp, dividend.X()); 4179 __ Smsubl(result.X(), result, temp, dividend.X());
4184 4180
4185 // Check for negative zero. 4181 // Check for negative zero.
4186 HMod* hmod = instr->hydrogen(); 4182 HMod* hmod = instr->hydrogen();
4187 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero) && 4183 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) {
4188 hmod->left()->CanBeNegative()) {
4189 Label remainder_not_zero; 4184 Label remainder_not_zero;
4190 __ Cbnz(result, &remainder_not_zero); 4185 __ Cbnz(result, &remainder_not_zero);
4191 DeoptimizeIfNegative(dividend, instr->environment()); 4186 DeoptimizeIfNegative(dividend, instr->environment());
4192 __ bind(&remainder_not_zero); 4187 __ bind(&remainder_not_zero);
4193 } 4188 }
4194 } 4189 }
4195 4190
4196 4191
4197 void LCodeGen::DoModI(LModI* instr) { 4192 void LCodeGen::DoModI(LModI* instr) {
4198 Register dividend = ToRegister32(instr->left()); 4193 Register dividend = ToRegister32(instr->left());
4199 Register divisor = ToRegister32(instr->right()); 4194 Register divisor = ToRegister32(instr->right());
4200 Register result = ToRegister32(instr->result()); 4195 Register result = ToRegister32(instr->result());
4201 4196
4202 Label deopt, done; 4197 Label deopt, done;
4203 // modulo = dividend - quotient * divisor 4198 // modulo = dividend - quotient * divisor
4204 __ Sdiv(result, dividend, divisor); 4199 __ Sdiv(result, dividend, divisor);
4205 if (instr->hydrogen()->right()->CanBeZero()) { 4200 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) {
4206 // Combine the deoptimization sites. 4201 // Combine the deoptimization sites.
4207 Label ok; 4202 Label ok;
4208 __ Cbnz(divisor, &ok); 4203 __ Cbnz(divisor, &ok);
4209 __ Bind(&deopt); 4204 __ Bind(&deopt);
4210 Deoptimize(instr->environment()); 4205 Deoptimize(instr->environment());
4211 __ Bind(&ok); 4206 __ Bind(&ok);
4212 } 4207 }
4213 __ Msub(result, result, divisor, dividend); 4208 __ Msub(result, result, divisor, dividend);
4214 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero) && 4209 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
4215 instr->hydrogen()->left()->CanBeNegative() &&
4216 instr->hydrogen()->CanBeZero()) {
4217 __ Cbnz(result, &done); 4210 __ Cbnz(result, &done);
4218 if (deopt.is_bound()) { // TODO(all) This is a hack, remove this... 4211 if (deopt.is_bound()) { // TODO(all) This is a hack, remove this...
4219 __ Tbnz(dividend, kWSignBit, &deopt); 4212 __ Tbnz(dividend, kWSignBit, &deopt);
4220 } else { 4213 } else {
4221 DeoptimizeIfNegative(dividend, instr->environment()); 4214 DeoptimizeIfNegative(dividend, instr->environment());
4222 } 4215 }
4223 } 4216 }
4224 __ Bind(&done); 4217 __ Bind(&done);
4225 } 4218 }
4226 4219
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after
5837 __ Bind(&out_of_object); 5830 __ Bind(&out_of_object);
5838 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); 5831 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
5839 // Index is equal to negated out of object property index plus 1. 5832 // Index is equal to negated out of object property index plus 1.
5840 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); 5833 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2));
5841 __ Ldr(result, FieldMemOperand(result, 5834 __ Ldr(result, FieldMemOperand(result,
5842 FixedArray::kHeaderSize - kPointerSize)); 5835 FixedArray::kHeaderSize - kPointerSize));
5843 __ Bind(&done); 5836 __ Bind(&done);
5844 } 5837 }
5845 5838
5846 } } // namespace v8::internal 5839 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/a64/lithium-a64.cc ('k') | src/arm/lithium-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698