[PATCH] D156837: [AArch64][CodeGen] Avoid inverting hot branches during relaxation

Daniel Hoekwater via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 11:30:10 PDT 2023


dhoekwater created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
dhoekwater added reviewers: MaskRay, efriedma, arsenm, snehasish, mingmingl.
dhoekwater updated this revision to Diff 546953.
dhoekwater added a comment.
dhoekwater updated this revision to Diff 546955.
dhoekwater updated this revision to Diff 546960.
dhoekwater published this revision for review.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Add exhaustive tests


dhoekwater added a comment.

Remove debug lines


dhoekwater added a comment.

Rebase onto up-to-date parent


Current behavior for relaxing out-of-range conditional branches
is to invert the conditional and insert a fallthrough unconditional
branch to the original destination. This approach biases the branch
predictor in the wrong direction, which can degrading performance.

Machine function splitting introduces many rarely-taken cross-section
conditional branches, which are improperly relaxed. Avoid inverting
these branches; instead, retarget them to trampolines at the end of the
function. Doing so increases the runtime cost of jumping to cold code
but eliminates the misprediction cost of jumping to hot code.

Depends on D145211 <https://reviews.llvm.org/D145211>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156837

Files:
  llvm/lib/CodeGen/BranchRelaxation.cpp
  llvm/test/CodeGen/AArch64/branch-relax-cross-section.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156837.546960.patch
Type: text/x-patch
Size: 14560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230803/a034a866/attachment.bin>


More information about the llvm-commits mailing list