Skip to content

Commit

Permalink
JIT: Enable jump-to-next removal optimization in MinOpts (#95340)
Browse files Browse the repository at this point in the history
Follow-up to #94239. In MinOpts scenarios, we should remove branches to the next block regardless of whether BBF_NONE_QUIRK is set, as this yields code size and TP improvements.
  • Loading branch information
amanasifkhalid authored Nov 30, 2023
1 parent 5ea898e commit 4cb123a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/coreclr/jit/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,12 @@ bool BasicBlock::IsFirstColdBlock(Compiler* compiler) const
// compiler - current compiler instance
//
// Returns:
// true if the peephole optimization is enabled,
// and block is a BBJ_ALWAYS to the next block that we can fall through into
// true if block is a BBJ_ALWAYS to the next block that we can fall into
//
bool BasicBlock::CanRemoveJumpToNext(Compiler* compiler)
{
assert(KindIs(BBJ_ALWAYS));
const bool tryJumpOpt = compiler->opts.OptimizationEnabled() || ((bbFlags & BBF_NONE_QUIRK) != 0);
const bool skipJump = tryJumpOpt && JumpsToNext() && !hasAlign() && ((bbFlags & BBF_KEEP_BBJ_ALWAYS) == 0) &&
!compiler->fgInDifferentRegions(this, bbJumpDest);
return skipJump;
return JumpsToNext() && !hasAlign() && !compiler->fgInDifferentRegions(this, bbJumpDest);
}

//------------------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/jit/codegenlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,7 @@ void CodeGen::genCodeForBBlist()

case BBJ_ALWAYS:
{
// Peephole optimization: If this block jumps to the next one, skip emitting the jump
// (unless we are jumping between hot/cold sections, or if we need the jump for EH reasons)
// (Skip this if optimizations are disabled, unless the block shouldn't have a jump in the first place)
// If this block jumps to the next one, we might be able to skip emitting the jump
if (block->CanRemoveJumpToNext(compiler))
{
#ifdef TARGET_AMD64
Expand Down

0 comments on commit 4cb123a

Please sign in to comment.