未验证 提交 84a65ca9 编写于 作者: E Egor Bogatov 提交者: GitHub

Avoid boxing in Enum.HasFlag in Tier0 (#89348)

Co-authored-by: NMichał Petryka <35800402+MichalPetryka@users.noreply.github.com>
Co-authored-by: NJakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
上级 67b31173
......@@ -3160,7 +3160,18 @@ void Compiler::impImportAndPushBox(CORINFO_RESOLVED_TOKEN* pResolvedToken)
// and the other you get
// *(temp+4) = expr
if (opts.OptimizationDisabled())
// For minopts/debug code, try and minimize the total number
// of box temps by reusing an existing temp when possible. However,
bool shareBoxedTemps = opts.OptimizationDisabled();
// Avoid sharing in some tier 0 cases to, potentially, avoid boxing in Enum.HasFlag.
if (shareBoxedTemps && varTypeIsIntegral(exprToBox) && !lvaHaveManyLocals() &&
(info.compCompHnd->isEnum(pResolvedToken->hClass, nullptr) != TypeCompareState::Must))
{
shareBoxedTemps = false;
}
if (shareBoxedTemps)
{
// For minopts/debug code, try and minimize the total number
// of box temps by reusing an existing temp when possible.
......
......@@ -2580,6 +2580,10 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
case NI_System_RuntimeType_get_TypeHandle:
case NI_System_RuntimeTypeHandle_ToIntPtr:
// This one is not simple, but it will help us
// to avoid some unnecessary boxing
case NI_System_Enum_HasFlag:
// Most atomics are compiled to single instructions
case NI_System_Threading_Interlocked_And:
case NI_System_Threading_Interlocked_Or:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册