[PATCH] D147036: [GuardWidening] Use BFI to reject obviously unprofitable widening

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 28 02:37:25 PDT 2023


mkazantsev created this revision.
mkazantsev added reviewers: skatkov, apilipenko, anna, reames.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Existing profitability model in guard widening is naive. In particular, it assumes
that whenever we can widen the guard away from the loop, we should do it, even
if the loop is never entered. As result, we can end up with conditions widened from
cold (sometimes dynamically dead) code into hot code.

This patch reject grossly unprofitable cases of this using BFI. The heuristic is "if the
destination is at least 2x hotter than the source, reject".


https://reviews.llvm.org/D147036

Files:
  llvm/lib/Transforms/Scalar/GuardWidening.cpp
  llvm/test/Transforms/GuardWidening/basic_widenable_condition_guards.ll
  llvm/test/Transforms/GuardWidening/profile-based-profitability-intrinsics.ll
  llvm/test/Transforms/GuardWidening/profile-based-profitability_explicit.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147036.508939.patch
Type: text/x-patch
Size: 15037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230328/31bf90bf/attachment.bin>


More information about the llvm-commits mailing list