From 8d699cd65dc276a3058e7f961b4af51d0d107a7c Mon Sep 17 00:00:00 2001 From: EgorBo Date: Fri, 26 Jan 2024 23:40:43 +0100 Subject: [PATCH] remove morphing --- src/coreclr/jit/helperexpansion.cpp | 18 +++++------------- src/coreclr/jit/importer.cpp | 3 +++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/coreclr/jit/helperexpansion.cpp b/src/coreclr/jit/helperexpansion.cpp index e98f37ad2c5d64..59a580a5f88eb8 100644 --- a/src/coreclr/jit/helperexpansion.cpp +++ b/src/coreclr/jit/helperexpansion.cpp @@ -2279,18 +2279,13 @@ bool Compiler::fgLateCastExpansionForCall(BasicBlock** pBlock, Statement* stmt, } else { - GenTreeCall* helperCall = call; if (typeCheckFailedAction == TypeCheckFailedAction::CallHelper_Specialized) { - // Re-create the call with a specialized helper - // For JIT we probably can just change the gtCallMethHnd in the existing call, but let's unify with AOT - helperCall = gtNewHelperCallNode(CORINFO_HELP_CHKCASTCLASS_SPECIAL, call->TypeGet(), - helperCall->gtArgs.GetUserArgByIndex(0)->GetNode(), - helperCall->gtArgs.GetUserArgByIndex(1)->GetNode()); - fgMorphCall(helperCall); - gtSetEvalOrder(helperCall); + // A slightly faster fallback which assumes that we've already checked + // for null and for castToCls itself. + call->gtCallMethHnd = eeFindHelper(CORINFO_HELP_CHKCASTCLASS_SPECIAL); } - GenTree* fallbackTree = gtNewTempStore(tmpNum, helperCall); + GenTree* fallbackTree = gtNewTempStore(tmpNum, call); fallbackBb = fgNewBBFromTreeAfter(BBJ_ALWAYS, typeCheckBb, fallbackTree, debugInfo, lastBb, true); } @@ -2337,10 +2332,7 @@ bool Compiler::fgLateCastExpansionForCall(BasicBlock** pBlock, Statement* stmt, // nullcheckBb->inheritWeight(firstBb); typeCheckBb->inheritWeightPercentage(nullcheckBb, 50); - fallbackBb->inheritWeightPercentage(typeCheckBb, - (typeCheckFailedAction == TypeCheckFailedAction::CallHelper_AlwaysThrows) - ? 0 - : 100 - likelihood); + fallbackBb->inheritWeightPercentage(typeCheckBb, fallbackBb->KindIs(BBJ_THROW) ? 0 : 100 - likelihood); typeCheckSucceedBb->inheritWeightPercentage(typeCheckBb, likelihood); lastBb->inheritWeight(firstBb); diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 205fca7a584a33..955b75af71faae 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -5460,6 +5460,9 @@ GenTree* Compiler::impCastClassOrIsInstToTree( shouldExpandInline = isCastClass && isClassExact; } + // CI test + shouldExpandInline = false; + // Pessimistically assume the jit cannot expand this as an inline test bool canExpandInline = false; bool reversedMTCheck = false;