Bug 1307523 - Backed out changeset 6e75141df030, rs=jandem over IRC

MozReview-Commit-ID: JWBmRQwLZql
This commit is contained in:
Gary Kwong 2016-10-04 10:44:36 -07:00
Родитель bfeb950383
Коммит 198aff4985
3 изменённых файлов: 2 добавлений и 71 удалений

Просмотреть файл

@ -2736,20 +2736,6 @@ MBinaryBitwiseInstruction::foldsTo(TempAllocator& alloc)
MDefinition*
MBinaryBitwiseInstruction::foldUnnecessaryBitop()
{
// Fold unsigned shift right operator when the second operand is zero and
// the only use is an unsigned modulo. Thus, the expression
// |(x >>> 0) % y| becomes |x % y|.
if (isUrsh() && hasOneDefUse() && getOperand(1)->isConstant()) {
MConstant* constant = getOperand(1)->toConstant();
if (constant->type() == MIRType::Int32 && constant->toInt32() == 0) {
for (MUseDefIterator use(this); use; use++) {
if (use.def()->isMod() && use.def()->toMod()->isUnsigned())
return getOperand(0);
break;
}
}
}
if (specialization_ != MIRType::Int32)
return this;

Просмотреть файл

@ -7139,51 +7139,23 @@ class MDiv : public MBinaryArithInstruction
class MMod : public MBinaryArithInstruction
{
public:
enum class PossiblyUnsigned {
NotPossible,
LHSPossible,
RHSPossible,
BothPossible,
};
protected:
bool unsigned_;
bool canBeNegativeDividend_;
bool canBePowerOfTwoDivisor_;
bool canBeDivideByZero_;
bool trapOnError_;
PossiblyUnsigned possiblyUnsigned_;
MMod(MDefinition* left, MDefinition* right, MIRType type)
: MBinaryArithInstruction(left, right),
unsigned_(false),
canBeNegativeDividend_(true),
canBePowerOfTwoDivisor_(true),
canBeDivideByZero_(true),
trapOnError_(false),
possiblyUnsigned_(PossiblyUnsigned::NotPossible)
trapOnError_(false)
{
if (type != MIRType::Value)
specialization_ = type;
setResultType(type);
if (left->isUrsh() && left->getOperand(1)->isConstant()) {
MConstant* constant = left->getOperand(1)->toConstant();
if (constant->type() == MIRType::Int32 && constant->toInt32() == 0)
possiblyUnsigned_ = PossiblyUnsigned::LHSPossible;
}
if (right->isUrsh() && right->getOperand(1)->isConstant()) {
MConstant* constant = right->getOperand(1)->toConstant();
if (constant->type() == MIRType::Int32 && constant->toInt32() == 0) {
if (possiblyUnsigned_ == PossiblyUnsigned::NotPossible)
possiblyUnsigned_ = PossiblyUnsigned::RHSPossible;
else
possiblyUnsigned_ = PossiblyUnsigned::BothPossible;
}
}
}
public:

Просмотреть файл

@ -1561,40 +1561,13 @@ MMod::computeRange(TempAllocator& alloc)
// If either operand is a NaN, the result is NaN. This also conservatively
// handles Infinity cases.
if ((possiblyUnsigned_ == PossiblyUnsigned::NotPossible &&
!lhs.hasInt32Bounds()) || !rhs.hasInt32Bounds())
{
if (!lhs.hasInt32Bounds() || !rhs.hasInt32Bounds())
return;
}
// If RHS can be zero, the result can be NaN.
if (rhs.lower() <= 0 && rhs.upper() >= 0)
return;
// (x >>> 0) % y is an unsigned modulo operation but the lhs' range is not
// always >= 0. The lhs range assumes a signed integer 32 bit while the
// value is unsigned 32 bit. That breaks the assumption that range >= 0.
if (specialization() == MIRType::Int32) {
switch (possiblyUnsigned_) {
case PossiblyUnsigned::NotPossible:
break;
case PossiblyUnsigned::LHSPossible:
if (rhs.lower() > 0 && !rhs.canHaveFractionalPart())
unsigned_ = true;
break;
case PossiblyUnsigned::RHSPossible:
if (lhs.lower() >= 0 && !lhs.canHaveFractionalPart())
unsigned_ = true;
break;
case PossiblyUnsigned::BothPossible:
if (lhs.lower() >= 0 && !lhs.canHaveFractionalPart())
unsigned_ = true;
else if (rhs.lower() > 0 && !rhs.canHaveFractionalPart())
unsigned_ = true;
break;
}
}
// If both operands are non-negative integers, we can optimize this to an
// unsigned mod.
if (specialization() == MIRType::Int32 && lhs.lower() >= 0 && rhs.lower() > 0 &&