From c3f4e20619443de3d9e1486b45edbdc93f6256d4 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sun, 10 May 2026 11:57:18 -0700 Subject: [PATCH] Ensure we don't do duplicate checks for various multi-reg paths --- src/coreclr/jit/compiler.h | 2 -- src/coreclr/jit/gentree.cpp | 48 ++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 27 deletions(-) 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 aeaf0182c43130..9fa3d6534c50c8 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -857,44 +857,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 +929,7 @@ bool GenTree::IsMultiRegNode() const #endif #endif // FEATURE_MULTIREG_RET - if (OperIs(GT_COPY, GT_RELOAD)) + if (IsCopyOrReload()) { return true; } @@ -13004,7 +13006,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 // @@ -13050,7 +13051,6 @@ unsigned Compiler::gtDispMultiRegCount(GenTree* tree) return tree->GetMultiRegCount(this); } } -#endif // FEATURE_MULTIREG_RET //---------------------------------------------------------------------------------- // gtDispRegVal: Print the register(s) defined by the given node @@ -13073,7 +13073,6 @@ void Compiler::gtDispRegVal(GenTree* tree) return; } -#if FEATURE_MULTIREG_RET if (tree->IsMultiRegNode()) { // 0th reg is GetRegNum(), which is already printed above. @@ -13087,7 +13086,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,