diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 6d83b3ff0030e5..cc2e46f8203e8c 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -3998,9 +3998,7 @@ class Compiler void gtDispLeaf(GenTree* tree, IndentStack* indentStack); void gtDispLocal(GenTreeLclVarCommon* tree, IndentStack* indentStack); void gtDispNodeName(GenTree* tree); -#if FEATURE_MULTIREG_RET unsigned gtDispMultiRegCount(GenTree* tree); -#endif void gtDispRegVal(GenTree* tree); void gtDispVN(GenTree* tree); void gtDispCommonEndLine(GenTree* tree); diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 3697da73108cd8..539688edc33ae7 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -737,29 +737,6 @@ ClassLayout* GenTree::GetLayout(Compiler* compiler) const return compiler->typGetObjLayout(structHnd); } -//----------------------------------------------------------- -// CopyReg: Copy the _gtRegNum/gtRegTag fields. -// -// Arguments: -// from - GenTree node from which to copy -// -void GenTree::CopyReg(GenTree* from) -{ - _gtRegNum = from->_gtRegNum; - INDEBUG(gtRegTag = from->gtRegTag;) - - // Also copy multi-reg state if this is a call node - if (IsCall()) - { - assert(from->IsCall()); - this->AsCall()->CopyOtherRegs(from->AsCall()); - } - else if (IsCopyOrReload()) - { - this->AsCopyOrReload()->CopyOtherRegs(from->AsCopyOrReload()); - } -} - //------------------------------------------------------------------ // gtHasReg: Whether node been assigned a register by LSRA // @@ -857,44 +834,46 @@ bool GenTree::gtHasReg(Compiler* comp) const int GenTree::GetRegisterDstCount(Compiler* compiler) const { assert(!isContained()); - if (!IsMultiRegNode()) - { - return IsValue() ? 1 : 0; - } - else if (IsMultiRegCall()) + +#if FEATURE_MULTIREG_RET + if (IsMultiRegCall()) { return AsCall()->GetReturnTypeDesc()->GetReturnRegCount(); } - else if (IsCopyOrReload()) - { - return gtGetOp1()->GetRegisterDstCount(compiler); - } + #if !defined(TARGET_64BIT) - else if (OperIsMultiRegOp()) + if (OperIsMultiRegOp()) { assert(OperIs(GT_MUL_LONG)); return 2; } #endif -#ifdef FEATURE_HW_INTRINSICS - else if (OperIsHWIntrinsic()) +#endif // FEATURE_MULTIREG_RET + + if (IsCopyOrReload()) { - assert(TypeIs(TYP_STRUCT)); + return gtGetOp1()->GetRegisterDstCount(compiler); + } - const GenTreeHWIntrinsic* intrinsic = AsHWIntrinsic(); - const NamedIntrinsic intrinsicId = intrinsic->GetHWIntrinsicId(); - assert(HWIntrinsicInfo::IsMultiReg(intrinsicId)); +#ifdef FEATURE_HW_INTRINSICS + if (OperIsHWIntrinsic()) + { + const NamedIntrinsic intrinsicId = AsHWIntrinsic()->GetHWIntrinsicId(); - return HWIntrinsicInfo::GetMultiRegCount(intrinsicId); + if (HWIntrinsicInfo::IsMultiReg(intrinsicId)) + { + return HWIntrinsicInfo::GetMultiRegCount(intrinsicId); + } } #endif // FEATURE_HW_INTRINSICS - if (OperIsScalarLocal()) + if (IsMultiRegLclVar()) { return AsLclVar()->GetFieldCount(compiler); } - assert(!"Unexpected multi-reg node"); - return 0; + + assert(!IsMultiRegNode()); + return IsValue() ? 1 : 0; } //----------------------------------------------------------------------------------- @@ -927,7 +906,7 @@ bool GenTree::IsMultiRegNode() const #endif #endif // FEATURE_MULTIREG_RET - if (OperIs(GT_COPY, GT_RELOAD)) + if (IsCopyOrReload()) { return true; } @@ -11281,7 +11260,10 @@ GenTree* Compiler::gtCloneExpr(GenTree* tree) /* Make sure to copy back fields that may have been initialized */ copy->CopyRawCosts(tree); - copy->CopyReg(tree); + + assert(tree->GetRegNum() == REG_NA); + assert(tree->GetRegTag() == GenTree::GT_REGTAG_NONE); + return copy; } @@ -11430,8 +11412,6 @@ GenTreeCall* Compiler::gtCloneExprCallHelper(GenTreeCall* tree) copy->gtInlineContext = tree->gtInlineContext; - copy->CopyOtherRegFlags(tree); - // We keep track of the number of no return calls, so if we've cloned // one of these, update the tracking. // @@ -11473,7 +11453,8 @@ GenTreeCall* Compiler::gtCloneCandidateCall(GenTreeCall* call) result->gtDebugFlags |= (call->gtDebugFlags & ~GTF_DEBUG_NODE_MASK); #endif - result->CopyReg(call); + assert(call->GetRegNum() == REG_NA); + assert(call->GetRegTag() == GenTree::GT_REGTAG_NONE); return result; } @@ -13021,7 +13002,6 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_ } } -#if FEATURE_MULTIREG_RET //---------------------------------------------------------------------------------- // gtDispMultiRegCount: determine how many registers to print for a multi-reg node // @@ -13067,7 +13047,6 @@ unsigned Compiler::gtDispMultiRegCount(GenTree* tree) return tree->GetMultiRegCount(this); } } -#endif // FEATURE_MULTIREG_RET //---------------------------------------------------------------------------------- // gtDispRegVal: Print the register(s) defined by the given node @@ -13090,7 +13069,6 @@ void Compiler::gtDispRegVal(GenTree* tree) return; } -#if FEATURE_MULTIREG_RET if (tree->IsMultiRegNode()) { // 0th reg is GetRegNum(), which is already printed above. @@ -13104,7 +13082,6 @@ void Compiler::gtDispRegVal(GenTree* tree) printf(",%s", genIsValidReg(reg) ? compRegVarName(reg) : "NA"); } } -#endif } // We usually/commonly don't expect to print anything longer than this string, diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 1897b43014f17d..73864cdccee92c 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -1097,8 +1097,6 @@ struct GenTree INDEBUG(gtRegTag = GT_REGTAG_NONE;) } - // Copy the _gtRegNum/gtRegTag fields - void CopyReg(GenTree* from); bool gtHasReg(Compiler* comp) const; int GetRegisterDstCount(Compiler* compiler) const; @@ -4003,21 +4001,6 @@ struct GenTreeLclVar : public GenTreeLclVarCommon gtSpillFlags = 0; } - //------------------------------------------------------------------------- - // CopyOtherRegFlags: copy GTF_* flags associated with gtOtherRegs from - // the given LclVar node. - // - // Arguments: - // fromCall - GenTreeLclVar node from which to copy - // - // Return Value: - // None - // - void CopyOtherRegFlags(GenTreeLclVar* from) - { - this->gtSpillFlags = from->gtSpillFlags; - } - #ifdef DEBUG void ResetLclILoffs() { @@ -5330,8 +5313,9 @@ struct GenTreeCall final : public GenTree #if FEATURE_MULTIREG_RET for (unsigned i = 0; i < MAX_RET_REG_COUNT - 1; ++i) { - this->gtOtherRegs[i] = fromCall->gtOtherRegs[i]; + gtOtherRegs[i] = fromCall->gtOtherRegs[i]; } + gtSpillFlags = fromCall->gtSpillFlags; #endif } @@ -5374,23 +5358,6 @@ struct GenTreeCall final : public GenTree #endif } - //------------------------------------------------------------------------- - // CopyOtherRegFlags: copy GTF_* flags associated with gtOtherRegs from - // the given call node. - // - // Arguments: - // fromCall - GenTreeCall node from which to copy - // - // Return Value: - // None - // - void CopyOtherRegFlags(GenTreeCall* fromCall) - { -#if FEATURE_MULTIREG_RET - this->gtSpillFlags = fromCall->gtSpillFlags; -#endif - } - bool IsUnmanaged() const { return (gtFlags & GTF_CALL_UNMANAGED) != 0; @@ -8971,30 +8938,6 @@ struct GenTreeCopyOrReload : public GenTreeUnOp } } - //---------------------------------------------------------------------------- - // CopyOtherRegs: copy multi-reg state from the given copy/reload node to this - // node. - // - // Arguments: - // from - GenTree node from which to copy multi-reg state - // - // Return Value: - // None - // - // TODO-ARM: Implement this routine for Arm64 and Arm32 - // TODO-X86: Implement this routine for x86 - void CopyOtherRegs(GenTreeCopyOrReload* from) - { - assert(OperGet() == from->OperGet()); - -#ifdef UNIX_AMD64_ABI - for (unsigned i = 0; i < MAX_MULTIREG_COUNT - 1; ++i) - { - gtOtherRegs[i] = from->gtOtherRegs[i]; - } -#endif - } - unsigned GetRegCount() const { // We need to return the highest index for which we have a valid register. diff --git a/src/coreclr/jit/optcse.cpp b/src/coreclr/jit/optcse.cpp index 52648649a4cadf..b2baa7fc129c97 100644 --- a/src/coreclr/jit/optcse.cpp +++ b/src/coreclr/jit/optcse.cpp @@ -5234,8 +5234,8 @@ void CSE_HeuristicCommon::PerformCSE(CSE_Candidate* successfulCandidate) // void CSE_HeuristicCommon::ReplaceCSENode(Statement* stmt, GenTree* exp, GenTree* newNode) { - newNode->CopyReg(exp); // The cse inheirits any reg num property from the original exp node - exp->ClearRegNum(); // The exp node (for a CSE def) no longer has a register requirement + assert(exp->GetRegNum() == REG_NA); + assert(exp->GetRegTag() == GenTree::GT_REGTAG_NONE); // Walk the statement 'stmt' and find the pointer // in the tree is pointing to 'exp'