Bug 1920712 - Part 2: Pass result type to MBitNot. r=spidermonkey-reviewers,jandem

This matches the approach used by other arithmetic instructions.

Spotted this difference when working on part 1.

Differential Revision: https://phabricator.services.mozilla.com/D223330
This commit is contained in:
André Bargull 2024-09-30 14:48:46 +00:00
parent b3f28640fe
commit 9f0370483e
4 changed files with 13 additions and 13 deletions

View File

@ -229,7 +229,7 @@ MDefinition* MWasmBinaryBitwise::foldsTo(TempAllocator& alloc) {
case SubOpcode::Or:
return OnesOfType(alloc, type());
case SubOpcode::Xor:
return MBitNot::New(alloc, argR);
return MBitNot::New(alloc, argR, type());
default:
MOZ_CRASH();
}
@ -243,7 +243,7 @@ MDefinition* MWasmBinaryBitwise::foldsTo(TempAllocator& alloc) {
case SubOpcode::Or:
return OnesOfType(alloc, type());
case SubOpcode::Xor:
return MBitNot::New(alloc, argL);
return MBitNot::New(alloc, argL, type());
default:
MOZ_CRASH();
}

View File

@ -4007,11 +4007,10 @@ class MToString : public MUnaryInstruction, public ToStringPolicy::Data {
};
class MBitNot : public MUnaryInstruction, public BitwisePolicy::Data {
explicit MBitNot(MDefinition* input) : MUnaryInstruction(classOpcode, input) {
setResultType(MIRType::Int32);
if (input->type() == MIRType::Int64) {
setResultType(MIRType::Int64);
}
MBitNot(MDefinition* input, MIRType type)
: MUnaryInstruction(classOpcode, input) {
MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Int64);
setResultType(type);
setMovable();
}

View File

@ -3093,7 +3093,7 @@ bool WarpCacheIRTranspiler::emitDoubleNegationResult(NumberOperandId inputId) {
bool WarpCacheIRTranspiler::emitInt32NotResult(Int32OperandId inputId) {
MDefinition* input = getOperand(inputId);
auto* ins = MBitNot::New(alloc(), input);
auto* ins = MBitNot::New(alloc(), input, MIRType::Int32);
add(ins);
pushResult(ins);

View File

@ -974,11 +974,11 @@ class FunctionCompiler {
return ins;
}
MDefinition* bitnot(MDefinition* op) {
MDefinition* bitnot(MDefinition* op, MIRType type) {
if (inDeadCode()) {
return nullptr;
}
auto* ins = MBitNot::New(alloc(), op);
auto* ins = MBitNot::New(alloc(), op, type);
curBlock_->add(ins);
return ins;
}
@ -6406,13 +6406,14 @@ static bool EmitRotate(FunctionCompiler& f, ValType type, bool isLeftRotation) {
return true;
}
static bool EmitBitNot(FunctionCompiler& f, ValType operandType) {
static bool EmitBitNot(FunctionCompiler& f, ValType operandType,
MIRType mirType) {
MDefinition* input;
if (!f.iter().readUnary(operandType, &input)) {
return false;
}
f.iter().setResult(f.bitnot(input));
f.iter().setResult(f.bitnot(input, mirType));
return true;
}
@ -9997,7 +9998,7 @@ bool EmitBodyExprs(FunctionCompiler& f) {
case uint32_t(MozOp::I32Neg):
CHECK(EmitUnaryWithType<MWasmNeg>(f, ValType::I32, MIRType::Int32));
case uint32_t(MozOp::I32BitNot):
CHECK(EmitBitNot(f, ValType::I32));
CHECK(EmitBitNot(f, ValType::I32, MIRType::Int32));
case uint32_t(MozOp::I32Abs):
CHECK(EmitUnaryWithType<MAbs>(f, ValType::I32, MIRType::Int32));
case uint32_t(MozOp::F32TeeStoreF64):