@@ -2279,18 +2279,13 @@ bool Compiler::fgLateCastExpansionForCall(BasicBlock** pBlock, Statement* stmt,
22792279 }
22802280 else
22812281 {
2282- GenTreeCall* helperCall = call;
22832282 if (typeCheckFailedAction == TypeCheckFailedAction::CallHelper_Specialized)
22842283 {
2285- // Re-create the call with a specialized helper
2286- // For JIT we probably can just change the gtCallMethHnd in the existing call, but let's unify with AOT
2287- helperCall = gtNewHelperCallNode (CORINFO_HELP_CHKCASTCLASS_SPECIAL, call->TypeGet (),
2288- helperCall->gtArgs .GetUserArgByIndex (0 )->GetNode (),
2289- helperCall->gtArgs .GetUserArgByIndex (1 )->GetNode ());
2290- fgMorphCall (helperCall);
2291- gtSetEvalOrder (helperCall);
2284+ // A slightly faster fallback which assumes that we've already checked
2285+ // for null and for castToCls itself.
2286+ call->gtCallMethHnd = eeFindHelper (CORINFO_HELP_CHKCASTCLASS_SPECIAL);
22922287 }
2293- GenTree* fallbackTree = gtNewTempStore (tmpNum, helperCall );
2288+ GenTree* fallbackTree = gtNewTempStore (tmpNum, call );
22942289 fallbackBb = fgNewBBFromTreeAfter (BBJ_ALWAYS, typeCheckBb, fallbackTree, debugInfo, lastBb, true );
22952290 }
22962291
@@ -2337,10 +2332,7 @@ bool Compiler::fgLateCastExpansionForCall(BasicBlock** pBlock, Statement* stmt,
23372332 //
23382333 nullcheckBb->inheritWeight (firstBb);
23392334 typeCheckBb->inheritWeightPercentage (nullcheckBb, 50 );
2340- fallbackBb->inheritWeightPercentage (typeCheckBb,
2341- (typeCheckFailedAction == TypeCheckFailedAction::CallHelper_AlwaysThrows)
2342- ? 0
2343- : 100 - likelihood);
2335+ fallbackBb->inheritWeightPercentage (typeCheckBb, fallbackBb->KindIs (BBJ_THROW) ? 0 : 100 - likelihood);
23442336 typeCheckSucceedBb->inheritWeightPercentage (typeCheckBb, likelihood);
23452337 lastBb->inheritWeight (firstBb);
23462338
0 commit comments