[PATCH] D98898: [SimplifyCFG] use profile metadata to refine merging branch conditions

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 18 14:22:44 PDT 2021


spatel created this revision.
spatel added reviewers: Carrot, lebedev.ri, pengfei, craig.topper, RKSimon.
Herald added subscribers: wenlei, hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.

This is one step towards solving:
https://llvm.org/PR49336

In that example, we disregard the recommended usage of builtin_expect, so an expensive (unpredictable) branch is folded into another branch that is guarding it.
Here, we read the profile metadata to see if the 1st (predecessor) condition is likely to cause execution to bypass the 2nd (successor) condition before merging conditions by using logic ops.

Part of this patch is moving the Likely/Unlikely variables to make them visible to SimplifyCFG. We could do that as a preliminary step (if I got that right).


https://reviews.llvm.org/D98898

Files:
  llvm/include/llvm/Analysis/BranchProbabilityInfo.h
  llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
  llvm/lib/Analysis/BranchProbabilityInfo.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Transforms/PGOProfile/chr.ll
  llvm/test/Transforms/SimplifyCFG/preserve-branchweights.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98898.331687.patch
Type: text/x-patch
Size: 19066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210318/824d48a3/attachment.bin>


More information about the llvm-commits mailing list