[PATCH] D62430: [PPC] Correctly adjust branch probability in PPCReduceCRLogicals

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 24 15:20:36 PDT 2019


Carrot created this revision.
Carrot added reviewers: hfinkel, echristo, nemanjai, kbarton, xur.
Herald added subscribers: llvm-commits, jsji, kristina.
Herald added a project: LLVM.

In PPCReduceCRLogicals after splitting the original MBB into 2, the 2 impacted branches still use original branch probability. This is unreasonable. Suppose we have following code, and the probability of each successor is 50%.

  condc = conda || condb
  br condc, label %target, label %fallthrough

It can be transformed to following,

  br conda, label %target, label %newbb

newbb:

  br condb, label %target, label %fallthrough

Since each branch has a probability of 50% to each successor, the total probability to %fallthrough is 25% now, and the total probability to %target is 75%. This actually changed the original profiling data. A more reasonable probability can be set to 70% to the false side for each branch instruction, so the total probability to %fallthrough is close to 50%.

This patch assumes the two branches have same probability and computes new probability fore each target, and keep the total probability to original targets unchanged.


Repository:
  rL LLVM

https://reviews.llvm.org/D62430

Files:
  include/llvm/Support/BranchProbability.h
  lib/Target/PowerPC/PPCReduceCRLogicals.cpp
  test/CodeGen/PowerPC/reduce_cr.ll
  test/CodeGen/PowerPC/select-i1-vs-i1.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62430.201344.patch
Type: text/x-patch
Size: 6771 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190524/7d7290d6/attachment.bin>


More information about the llvm-commits mailing list