From 768c53abf705208b5963fe8855c14b5901714955 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Fri, 4 Feb 2022 15:24:01 +0300 Subject: [PATCH 1/4] Fix RuntimeHelpers.IsKnownConstant for ExtendedDefaultPolicy --- src/coreclr/jit/inlinepolicy.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/coreclr/jit/inlinepolicy.cpp b/src/coreclr/jit/inlinepolicy.cpp index 0ea9135b82c249..5df49eb1723986 100644 --- a/src/coreclr/jit/inlinepolicy.cpp +++ b/src/coreclr/jit/inlinepolicy.cpp @@ -1599,6 +1599,15 @@ double ExtendedDefaultPolicy::DetermineMultiplier() multiplier); } + if (m_ConstArgFeedsIsKnownConst || (m_ArgFeedsIsKnownConst && m_IsPrejitRoot)) + { + // if we use RuntimeHelpers.IsKnownConstant we most likely expect our function to be always inlined + // at least in the case of constant arguments. In IsPrejitRoot we don't have callsite info so let's + // assume we have a constant here in order to avoid "baked" noinline + multiplier += 20; + JITDUMP("\nConstant argument feeds RuntimeHelpers.IsKnownConstant. Multiplier increased to %g.", multiplier); + } + if (m_DivByCns > 0) { // E.g. callee has "x / arg0" where arg0 is a const at the call site - From 5ff4bc7b67d984095554969840e200ab5fae2f20 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Fri, 4 Feb 2022 15:26:31 +0300 Subject: [PATCH 2/4] Fix RuntimeHelpers.IsKnownConstant for ExtendedDefaultPolicy --- src/coreclr/jit/inlinepolicy.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/coreclr/jit/inlinepolicy.cpp b/src/coreclr/jit/inlinepolicy.cpp index 5df49eb1723986..af958099a20173 100644 --- a/src/coreclr/jit/inlinepolicy.cpp +++ b/src/coreclr/jit/inlinepolicy.cpp @@ -735,15 +735,6 @@ double DefaultPolicy::DetermineMultiplier() JITDUMP("\nInline candidate has arg that feeds range check. Multiplier increased to %g.", multiplier); } - if (m_ConstArgFeedsIsKnownConst || (m_ArgFeedsIsKnownConst && m_IsPrejitRoot)) - { - // if we use RuntimeHelpers.IsKnownConstant we most likely expect our function to be always inlined - // at least in the case of constant arguments. In IsPrejitRoot we don't have callsite info so let's - // assume we have a constant here in order to avoid "baked" noinline - multiplier += 20; - JITDUMP("\nConstant argument feeds RuntimeHelpers.IsKnownConstant. Multiplier increased to %g.", multiplier); - } - if (m_ConstantArgFeedsConstantTest > 0) { multiplier += 3.0; From 75bba73759c78cee8e7448ad2cfbafd55331b8ba Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Wed, 9 Feb 2022 15:37:34 +0300 Subject: [PATCH 3/4] Update inlinepolicy.cpp --- src/coreclr/jit/inlinepolicy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/inlinepolicy.cpp b/src/coreclr/jit/inlinepolicy.cpp index af958099a20173..21a3af3771a354 100644 --- a/src/coreclr/jit/inlinepolicy.cpp +++ b/src/coreclr/jit/inlinepolicy.cpp @@ -1595,7 +1595,7 @@ double ExtendedDefaultPolicy::DetermineMultiplier() // if we use RuntimeHelpers.IsKnownConstant we most likely expect our function to be always inlined // at least in the case of constant arguments. In IsPrejitRoot we don't have callsite info so let's // assume we have a constant here in order to avoid "baked" noinline - multiplier += 20; + multiplier += 3; JITDUMP("\nConstant argument feeds RuntimeHelpers.IsKnownConstant. Multiplier increased to %g.", multiplier); } From 78189d09f139bac7c6d5c0071d40f64d9c143c68 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Wed, 16 Feb 2022 03:18:06 +0300 Subject: [PATCH 4/4] Update inlinepolicy.cpp --- src/coreclr/jit/inlinepolicy.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/coreclr/jit/inlinepolicy.cpp b/src/coreclr/jit/inlinepolicy.cpp index 21a3af3771a354..dafb34f8781ed2 100644 --- a/src/coreclr/jit/inlinepolicy.cpp +++ b/src/coreclr/jit/inlinepolicy.cpp @@ -1590,15 +1590,6 @@ double ExtendedDefaultPolicy::DetermineMultiplier() multiplier); } - if (m_ConstArgFeedsIsKnownConst || (m_ArgFeedsIsKnownConst && m_IsPrejitRoot)) - { - // if we use RuntimeHelpers.IsKnownConstant we most likely expect our function to be always inlined - // at least in the case of constant arguments. In IsPrejitRoot we don't have callsite info so let's - // assume we have a constant here in order to avoid "baked" noinline - multiplier += 3; - JITDUMP("\nConstant argument feeds RuntimeHelpers.IsKnownConstant. Multiplier increased to %g.", multiplier); - } - if (m_DivByCns > 0) { // E.g. callee has "x / arg0" where arg0 is a const at the call site -