[PATCH] Allow 0-weight branches in BranchProbabilityInfo.

Diego Novillo dnovillo at google.com
Wed May 6 09:25:16 PDT 2015


Hi hansw,

When computing branch weights in BPI, we used to disallow branches with
weight 0. This is a minor nuisance, because a branch with weight 0 is
different to "don't have information". In the context of
instrumentation, it may mean "never executed", in the context of
sampling, it means "never or seldom executed".

In allowing 0 weight branches, I ran into issues with the switch
expansion code in selection DAG. It is currently hardwired to not handle
branches with weight 0. To maintain the current behaviour, I changed it
to use 1 when it finds 0, but perhaps the algorithm needs changes to
tolerate branches with weight zero.

Hans, could you take a look at the code I added to compensate for 0-weight
branches in the switch lowering code? I've tried to look for a better
place to add the flooring code, but couldn't find it.

The rest of the patch just mechanically adjusts for branches that now have
the correct weight set to 0.

http://reviews.llvm.org/D9533

Files:
  lib/Analysis/BranchProbabilityInfo.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  test/Transforms/SampleProfile/branch.ll
  test/Transforms/SampleProfile/calls.ll
  test/Transforms/SampleProfile/propagate.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9533.25056.patch
Type: text/x-patch
Size: 8592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150506/e564bc70/attachment.bin>


More information about the llvm-commits mailing list