diff --git a/src/coreclr/jit/codegenwasm.cpp b/src/coreclr/jit/codegenwasm.cpp index 67013555439446..81466d7053362f 100644 --- a/src/coreclr/jit/codegenwasm.cpp +++ b/src/coreclr/jit/codegenwasm.cpp @@ -435,7 +435,7 @@ void CodeGen::WasmProduceReg(GenTree* node) // // If the operand is a candidate, we use that candidate's current register. // Otherwise it must have been allocated into a temporary register initialized -// in 'WasmProduceReg'. To do this, call treeNode->SetMultiplyUsed() during +// in 'WasmProduceReg'. To do this, call SetMultiplyUsed(treeNode) during // lowering and ensure that regalloc is updated to call 'ConsumeTemporaryRegForOperand' // on the node(s) that need to be used multiple times. // diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 0fc0b571111761..b5b235e3b2b66b 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -1228,11 +1228,6 @@ struct GenTree // LIR flags // These helper methods, along with the flag values they manipulate, are defined in lir.h // -#ifdef TARGET_WASM - // Asks the register allocator to allocate a dedicated register for this node so we can use its value multiple - // times. - inline void SetMultiplyUsed(); -#endif // UnusedValue indicates that, although this node produces a value, it is unused. inline void SetUnusedValue(); inline void ClearUnusedValue(); diff --git a/src/coreclr/jit/lir.h b/src/coreclr/jit/lir.h index ba44edf09937c2..b212ee69974fbd 100644 --- a/src/coreclr/jit/lir.h +++ b/src/coreclr/jit/lir.h @@ -339,14 +339,6 @@ class LIR final static GenTree* FirstNode(GenTree* node1, GenTree* node2); }; -#ifdef TARGET_WASM -inline void GenTree::SetMultiplyUsed() -{ - assert(gtType != TYP_STRUCT); - gtLIRFlags |= LIR::Flags::MultiplyUsed; -} -#endif - inline void GenTree::SetUnusedValue() { gtLIRFlags |= LIR::Flags::UnusedValue; diff --git a/src/coreclr/jit/lower.h b/src/coreclr/jit/lower.h index 579e2dd283cccf..505243b0e736d3 100644 --- a/src/coreclr/jit/lower.h +++ b/src/coreclr/jit/lower.h @@ -636,6 +636,12 @@ class Lowering final : public Phase #ifdef TARGET_WASM ArrayStack m_stackificationStack; + + static void SetMultiplyUsed(GenTree* node) + { + assert(node->gtType != TYP_STRUCT); + node->gtLIRFlags |= LIR::Flags::MultiplyUsed; + } #endif }; diff --git a/src/coreclr/jit/lowerwasm.cpp b/src/coreclr/jit/lowerwasm.cpp index 7d66828774d866..752a7c52c590a3 100644 --- a/src/coreclr/jit/lowerwasm.cpp +++ b/src/coreclr/jit/lowerwasm.cpp @@ -169,8 +169,8 @@ GenTree* Lowering::LowerBinaryArithmetic(GenTreeOp* binOp) if (binOp->gtOverflow()) { - binOp->gtGetOp1()->SetMultiplyUsed(); - binOp->gtGetOp2()->SetMultiplyUsed(); + SetMultiplyUsed(binOp->gtGetOp1()); + SetMultiplyUsed(binOp->gtGetOp2()); } return binOp->gtNext; @@ -189,12 +189,12 @@ void Lowering::LowerDivOrMod(GenTreeOp* divMod) ExceptionSetFlags exSetFlags = divMod->OperExceptions(m_compiler); if ((exSetFlags & ExceptionSetFlags::ArithmeticException) != ExceptionSetFlags::None) { - divMod->gtGetOp1()->SetMultiplyUsed(); - divMod->gtGetOp2()->SetMultiplyUsed(); + SetMultiplyUsed(divMod->gtGetOp1()); + SetMultiplyUsed(divMod->gtGetOp2()); } else if ((exSetFlags & ExceptionSetFlags::DivideByZeroException) != ExceptionSetFlags::None) { - divMod->gtGetOp2()->SetMultiplyUsed(); + SetMultiplyUsed(divMod->gtGetOp2()); } ContainCheckDivOrMod(divMod); @@ -248,7 +248,9 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode) // If copying to the stack instead of the heap, we should treat it as a raw memcpy for // smaller generated code and potentially better performance. if (blkNode->IsAddressNotOnHeap(m_compiler)) + { doCpObj = false; + } // CopyObj or CopyBlk if (doCpObj) @@ -260,9 +262,11 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode) } blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindCpObjUnroll; - dstAddr->SetMultiplyUsed(); + SetMultiplyUsed(dstAddr); if (src->OperIs(GT_IND)) - src->gtGetOp1()->SetMultiplyUsed(); + { + SetMultiplyUsed(src->gtGetOp1()); + } } else { @@ -299,7 +303,7 @@ void Lowering::LowerCast(GenTree* tree) if (tree->gtOverflow()) { - tree->gtGetOp1()->SetMultiplyUsed(); + SetMultiplyUsed(tree->gtGetOp1()); } ContainCheckCast(tree->AsCast()); } @@ -585,6 +589,6 @@ void Lowering::AfterLowerArgsForCall(GenTreeCall* call) { // Prepare for explicit null check CallArg* thisArg = call->gtArgs.GetThisArg(); - thisArg->GetNode()->SetMultiplyUsed(); + SetMultiplyUsed(thisArg->GetNode()); } } diff --git a/src/coreclr/jit/regallocwasm.cpp b/src/coreclr/jit/regallocwasm.cpp index 361bf574bb15b9..a69bf2917b861d 100644 --- a/src/coreclr/jit/regallocwasm.cpp +++ b/src/coreclr/jit/regallocwasm.cpp @@ -460,7 +460,9 @@ void WasmRegAlloc::CollectReferencesForBlockStore(GenTreeBlk* node) { GenTree* src = node->Data(); if (src->OperIs(GT_IND)) + { src = src->gtGetOp1(); + } ConsumeTemporaryRegForOperand(src DEBUGARG("block store source")); ConsumeTemporaryRegForOperand(node->Addr() DEBUGARG("block store destination"));