Remove uses of CanBeNegative() in HMod.

BUG=v8:3204
LOG=y
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/195793016

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19878 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
bmeurer@chromium.org 2014-03-13 08:17:44 +00:00
parent 929313bd6b
commit 4da15df008
6 changed files with 10 additions and 5 deletions

View File

@ -4134,7 +4134,7 @@ void LCodeGen::DoModByPowerOf2I(LModByPowerOf2I* instr) {
HMod* hmod = instr->hydrogen(); HMod* hmod = instr->hydrogen();
int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1); int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1);
Label dividend_is_not_negative, done; Label dividend_is_not_negative, done;
if (hmod->left()->CanBeNegative()) { if (hmod->CheckFlag(HValue::kLeftCanBeNegative)) {
__ Cmp(dividend, 0); __ Cmp(dividend, 0);
__ B(pl, &dividend_is_not_negative); __ B(pl, &dividend_is_not_negative);
// Note that this is correct even for kMinInt operands. // Note that this is correct even for kMinInt operands.

View File

@ -1131,7 +1131,7 @@ void LCodeGen::DoModByPowerOf2I(LModByPowerOf2I* instr) {
HMod* hmod = instr->hydrogen(); HMod* hmod = instr->hydrogen();
int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1); int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1);
Label dividend_is_not_negative, done; Label dividend_is_not_negative, done;
if (hmod->left()->CanBeNegative()) { if (hmod->CheckFlag(HValue::kLeftCanBeNegative)) {
__ cmp(dividend, Operand::Zero()); __ cmp(dividend, Operand::Zero());
__ b(pl, &dividend_is_not_negative); __ b(pl, &dividend_is_not_negative);
// Note that this is correct even for kMinInt operands. // Note that this is correct even for kMinInt operands.

View File

@ -1865,6 +1865,10 @@ Range* HMod::InferRange(Zone* zone) {
result->set_can_be_minus_zero(!CheckFlag(kAllUsesTruncatingToInt32) && result->set_can_be_minus_zero(!CheckFlag(kAllUsesTruncatingToInt32) &&
left_can_be_negative); left_can_be_negative);
if (!a->CanBeNegative()) {
ClearFlag(HValue::kLeftCanBeNegative);
}
if (!a->Includes(kMinInt) || !b->Includes(-1)) { if (!a->Includes(kMinInt) || !b->Includes(-1)) {
ClearFlag(HValue::kCanOverflow); ClearFlag(HValue::kCanOverflow);
} }

View File

@ -623,6 +623,7 @@ class HValue : public ZoneObject {
kBailoutOnMinusZero, kBailoutOnMinusZero,
kCanBeDivByZero, kCanBeDivByZero,
kLeftCanBeMinInt, kLeftCanBeMinInt,
kLeftCanBeNegative,
kAllowUndefinedAsNaN, kAllowUndefinedAsNaN,
kIsArguments, kIsArguments,
kTruncatingToInt32, kTruncatingToInt32,
@ -855,7 +856,6 @@ class HValue : public ZoneObject {
Range* range() const { return range_; } Range* range() const { return range_; }
// TODO(svenpanne) We should really use the null object pattern here. // TODO(svenpanne) We should really use the null object pattern here.
bool HasRange() const { return range_ != NULL; } bool HasRange() const { return range_ != NULL; }
bool CanBeNegative() const { return !HasRange() || range()->CanBeNegative(); }
void AddNewRange(Range* r, Zone* zone); void AddNewRange(Range* r, Zone* zone);
void RemoveLastAddedRange(); void RemoveLastAddedRange();
void ComputeInitialRange(Zone* zone); void ComputeInitialRange(Zone* zone);
@ -4860,6 +4860,7 @@ class HMod V8_FINAL : public HArithmeticBinaryOperation {
HValue* right) : HArithmeticBinaryOperation(context, left, right) { HValue* right) : HArithmeticBinaryOperation(context, left, right) {
SetFlag(kCanBeDivByZero); SetFlag(kCanBeDivByZero);
SetFlag(kCanOverflow); SetFlag(kCanOverflow);
SetFlag(kLeftCanBeNegative);
} }
}; };

View File

@ -1385,7 +1385,7 @@ void LCodeGen::DoModByPowerOf2I(LModByPowerOf2I* instr) {
HMod* hmod = instr->hydrogen(); HMod* hmod = instr->hydrogen();
int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1); int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1);
Label dividend_is_not_negative, done; Label dividend_is_not_negative, done;
if (hmod->left()->CanBeNegative()) { if (hmod->CheckFlag(HValue::kLeftCanBeNegative)) {
__ test(dividend, dividend); __ test(dividend, dividend);
__ j(not_sign, &dividend_is_not_negative, Label::kNear); __ j(not_sign, &dividend_is_not_negative, Label::kNear);
// Note that this is correct even for kMinInt operands. // Note that this is correct even for kMinInt operands.

View File

@ -1004,7 +1004,7 @@ void LCodeGen::DoModByPowerOf2I(LModByPowerOf2I* instr) {
HMod* hmod = instr->hydrogen(); HMod* hmod = instr->hydrogen();
int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1); int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1);
Label dividend_is_not_negative, done; Label dividend_is_not_negative, done;
if (hmod->left()->CanBeNegative()) { if (hmod->CheckFlag(HValue::kLeftCanBeNegative)) {
__ testl(dividend, dividend); __ testl(dividend, dividend);
__ j(not_sign, &dividend_is_not_negative, Label::kNear); __ j(not_sign, &dividend_is_not_negative, Label::kNear);
// Note that this is correct even for kMinInt operands. // Note that this is correct even for kMinInt operands.