Bug 1627618 - Part 1: Add MAdd with truncate parameter. r=jandem

Later patches will require a constructor with the signature
`MAdd(MDefinition, MDefinition, MIRType)`, which neither sets the truncation
mode nor sets the "commutative" flag. Both things happen with the existing
constructor which has a compatible signature and which is currently called
for the use sites modified in this patch. (The existing constructor is the
one directly appearing before the newly added one.)

The existing constructor defaults to `MDefinition::Truncate` and all callers to
that constructor use the `MIRType::Int32` specialisation. Because all callers
use `MIRType::Int32`, we can omit the type parameter for the new constructor.

The existing constructor is also called from WasmIonCompile, the next part will
handle that caller.

Differential Revision: https://phabricator.services.mozilla.com/D69778

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2020-04-07 08:35:25 +00:00
parent 8346f51250
commit 37d0520732
5 changed files with 11 additions and 5 deletions

View File

@ -69,7 +69,7 @@ static void AnalyzeAsmHeapAddress(MDefinition* ptr, MIRGraph& graph) {
// The pattern was matched! Produce the replacement expression.
MInstruction* and_ = MBitAnd::New(graph.alloc(), op0, rhs, MIRType::Int32);
ptr->block()->insertBefore(ptr->toBitAnd(), and_);
MInstruction* add = MAdd::New(graph.alloc(), and_, op1, MIRType::Int32);
auto* add = MAdd::New(graph.alloc(), and_, op1, MDefinition::Truncate);
ptr->block()->insertBefore(ptr->toBitAnd(), add);
ptr->replaceAllUsesWith(add);
ptr->block()->discard(ptr->toBitAnd());

View File

@ -69,8 +69,7 @@ static void AnalyzeAdd(TempAllocator& alloc, MAdd* add) {
MInstruction* rhs = MConstant::New(alloc, Int32Value(sum.constant));
add->block()->insertBefore(add, rhs);
MAdd* addNew =
MAdd::New(alloc, sum.term, rhs, MIRType::Int32, add->truncateKind());
MAdd* addNew = MAdd::New(alloc, sum.term, rhs, add->truncateKind());
add->replaceAllLiveUsesWith(addNew);
add->block()->insertBefore(add, addNew);

View File

@ -6981,7 +6981,7 @@ AbortReasonOr<Ok> IonBuilder::jsop_initelem_inc() {
MDefinition* id = current->pop();
MDefinition* obj = current->peek(-1);
MAdd* nextId = MAdd::New(alloc(), id, constantInt(1), MIRType::Int32);
MAdd* nextId = MAdd::New(alloc(), id, constantInt(1), MDefinition::Truncate);
current->add(nextId);
current->push(nextId);

View File

@ -5365,6 +5365,13 @@ class MAdd : public MBinaryArithInstruction {
setTruncateKind(truncateKind);
setCommutative();
}
MAdd(MDefinition* left, MDefinition* right, TruncateKind truncateKind)
: MAdd(left, right) {
specialization_ = MIRType::Int32;
setResultType(MIRType::Int32);
setTruncateKind(truncateKind);
setCommutative();
}
public:

View File

@ -2474,7 +2474,7 @@ bool WarpBuilder::build_InitElemInc(BytecodeLocation loc) {
// Push index + 1.
MConstant* constOne = constant(Int32Value(1));
MAdd* nextIndex = MAdd::New(alloc(), index, constOne, MIRType::Int32);
MAdd* nextIndex = MAdd::New(alloc(), index, constOne, MDefinition::Truncate);
current->add(nextIndex);
current->push(nextIndex);