Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Jun 10, 2021
1 parent d8e2d7c commit 98afcea
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -10362,7 +10362,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
static fgWalkPreFn gsMarkPtrsAndAssignGroups; // Shadow param analysis tree-walk
static fgWalkPreFn gsReplaceShadowParams; // Shadow param replacement tree-walk

#define DEFAULT_MAX_INLINE_SIZE 200 // Methods with > DEFAULT_MAX_INLINE_SIZE IL bytes will never be inlined.
#define DEFAULT_MAX_INLINE_SIZE 500 // Methods with > DEFAULT_MAX_INLINE_SIZE IL bytes will never be inlined.
// This can be overwritten by setting complus_JITInlineSize env variable.

#define DEFAULT_MAX_INLINE_DEPTH 20 // Methods at more than this level deep will not be inlined
Expand Down
33 changes: 32 additions & 1 deletion src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,8 +1465,9 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
{
compInlineResult->Note(InlineObservation::CALLSITE_FOLDABLE_BRANCH);
}
else if (FgStack::IsArgument(op1))
else
{
// E.g. brtrue is basically "if (X == 0)"
compInlineResult->Note(InlineObservation::CALLEE_BINARY_EXRP_WITH_CNS);
}
break;
Expand All @@ -1489,6 +1490,36 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
break;
}

case CEE_LDELEMA:
case CEE_LDELEM_I1:
case CEE_LDELEM_U1:
case CEE_LDELEM_I2:
case CEE_LDELEM_U2:
case CEE_LDELEM_I4:
case CEE_LDELEM_U4:
case CEE_LDELEM_I8:
case CEE_LDELEM_I:
case CEE_LDELEM_R4:
case CEE_LDELEM_R8:
case CEE_LDELEM_REF:
case CEE_STELEM_I:
case CEE_STELEM_I1:
case CEE_STELEM_I2:
case CEE_STELEM_I4:
case CEE_STELEM_I8:
case CEE_STELEM_R4:
case CEE_STELEM_R8:
case CEE_STELEM_REF:
case CEE_LDELEM:
case CEE_STELEM:
{
if (FgStack::IsArgument(pushedStack.Top()) || FgStack::IsArgument(pushedStack.Top(1)))
{
compInlineResult->Note(InlineObservation::CALLEE_ARG_FEEDS_RANGE_CHECK);
}
break;
}

case CEE_SWITCH:
{
if (makeInlineObservations)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18983,6 +18983,7 @@ void Compiler::impMakeDiscretionaryInlineObservations(InlineInfo* pInlineInfo, I
{
inlineResult->Note(InlineObservation::CALLEE_CLASS_PROMOTABLE);
}
inlineResult->Note(InlineObservation::CALLEE_CLASS_VALUETYPE);
}

#ifdef FEATURE_SIMD
Expand Down
17 changes: 6 additions & 11 deletions src/coreclr/jit/inlinepolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,7 @@ void DefaultPolicy::DumpXml(FILE* file, unsigned indent) const
XATTR_I4(m_CallsiteDepth);
XATTR_I4(m_InstructionCount);
XATTR_I4(m_LoadStoreCount);
XATTR_I4(m_ArgFeedsTest);
XATTR_I4(m_ArgFeedsConstantTest);
XATTR_I4(m_ArgFeedsRangeCheck);
XATTR_I4(m_ConstantArgFeedsConstantTest);
XATTR_I4(m_BinaryExprWithCns);
XATTR_I4(m_ArgCasted);
XATTR_I4(m_ArgIsStructByValue);
Expand Down Expand Up @@ -849,7 +846,7 @@ double DefaultPolicy::DetermineMultiplier()

if (m_IsFromValueClass)
{
multiplier += 3;
multiplier += 5.0;
JITDUMP("\nmultiplier in methods of struct increased to %g.", multiplier);
}

Expand Down Expand Up @@ -885,7 +882,7 @@ double DefaultPolicy::DetermineMultiplier()
if (m_ReturnsStructByValue)
{
// For structs-passed-by-value we might avoid expensive copy operations if we inline
multiplier += 2.0;
multiplier += 5.0;
JITDUMP("\nInline candidate returns a struct by value. Multiplier increased to %g.", multiplier);
}

Expand All @@ -912,7 +909,7 @@ double DefaultPolicy::DetermineMultiplier()
// if (Math.Abs(arg0) > 10) { // same here
// etc.
//
multiplier += 4.0 + m_FoldableBranch;
multiplier += 4.0 + m_FoldableBranch * 1.5;
JITDUMP("\nInline candidate has %d foldable branches. Multiplier increased to %g.", m_FoldableBranch,
multiplier);
}
Expand All @@ -926,10 +923,10 @@ double DefaultPolicy::DetermineMultiplier()

if (m_FldAccessOverArgStruct > 0)
{
multiplier += m_ArgCasted;
multiplier += 2.0 + m_ArgCasted;
// Such ldfld/stfld are cheap for promotable structs
JITDUMP("\n%d ldfld or stfld over arguments which are structs. Multiplier increased to %g.",
m_ArgIsStructByValue, multiplier);
m_FldAccessOverArgStruct, multiplier);
}

if (m_FoldableBox > 0)
Expand All @@ -956,7 +953,7 @@ double DefaultPolicy::DetermineMultiplier()
// ceq
//
// so at least we can note potential constant tests
multiplier += 1.5 + m_BinaryExprWithCns;
multiplier += 2.5 + m_BinaryExprWithCns;
JITDUMP("\nInline candidate has %d binary expressions with constants. Multiplier increased to %g.",
m_BinaryExprWithCns, multiplier);
}
Expand Down Expand Up @@ -2364,10 +2361,8 @@ void DiscretionaryPolicy::DumpData(FILE* file) const
fprintf(file, ",%u", m_IsFromPromotableValueClass ? 1 : 0);
fprintf(file, ",%u", m_HasSimd ? 1 : 0);
fprintf(file, ",%u", m_LooksLikeWrapperMethod ? 1 : 0);
fprintf(file, ",%u", m_ArgFeedsConstantTest);
fprintf(file, ",%u", m_MethodIsMostlyLoadStore ? 1 : 0);
fprintf(file, ",%u", m_ArgFeedsRangeCheck);
fprintf(file, ",%u", m_ConstantArgFeedsConstantTest);
fprintf(file, ",%d", m_CalleeNativeSizeEstimate);
fprintf(file, ",%d", m_CallsiteNativeSizeEstimate);
fprintf(file, ",%d", m_ModelCodeSizeEstimate);
Expand Down

0 comments on commit 98afcea

Please sign in to comment.