diff --git a/src/coreclr/jit/block.cpp b/src/coreclr/jit/block.cpp index c365b2a774a07..318e889969d54 100644 --- a/src/coreclr/jit/block.cpp +++ b/src/coreclr/jit/block.cpp @@ -297,7 +297,7 @@ bool BasicBlock::IsFirstColdBlock(Compiler* compiler) const bool BasicBlock::CanRemoveJumpToNext(Compiler* compiler) const { assert(KindIs(BBJ_ALWAYS)); - return JumpsToNext() && !hasAlign() && !compiler->fgInDifferentRegions(this, bbTarget); + return JumpsToNext() && (bbNext != compiler->fgFirstColdBlock); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/codegenlinear.cpp b/src/coreclr/jit/codegenlinear.cpp index 83712ec0cd669..3eaa6a7e7ca41 100644 --- a/src/coreclr/jit/codegenlinear.cpp +++ b/src/coreclr/jit/codegenlinear.cpp @@ -645,6 +645,7 @@ void CodeGen::genCodeForBBlist() /* Do we need to generate a jump or return? */ + bool removedJmp = false; switch (block->GetKind()) { case BBJ_RETURN: @@ -733,6 +734,7 @@ void CodeGen::genCodeForBBlist() } #endif // TARGET_AMD64 + removedJmp = true; break; } #ifdef TARGET_XARCH @@ -811,7 +813,7 @@ void CodeGen::genCodeForBBlist() assert(!block->KindIs(BBJ_CALLFINALLY)); #endif // FEATURE_EH_CALLFINALLY_THUNKS - GetEmitter()->emitLoopAlignment(DEBUG_ARG1(block->KindIs(BBJ_ALWAYS))); + GetEmitter()->emitLoopAlignment(DEBUG_ARG1(block->KindIs(BBJ_ALWAYS) && !removedJmp)); } if (!block->IsLast() && block->Next()->isLoopAlign())