diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -3086,6 +3086,7 @@ // Skip cold loops, as unswitching them brings little benefit // but increases the code size if (PSI && PSI->hasProfileSummary() && BFI && + PSI->isFunctionColdInCallGraph(L.getHeader()->getParent(), *BFI) && PSI->isColdBlock(L.getHeader(), BFI)) { LLVM_DEBUG(dbgs() << " Skip cold loop: " << L << "\n"); return false;