[PGO] Control Height Reduction
authorHiroshi Yamauchi <yamauchi@google.com>
Tue, 4 Sep 2018 17:19:13 +0000 (17:19 +0000)
committerHiroshi Yamauchi <yamauchi@google.com>
Tue, 4 Sep 2018 17:19:13 +0000 (17:19 +0000)
commit9775a620b0f6f5d3379eead8fdcfa3465782caf5
tree1e7707069bcc7751811291f5c3448c90d15e8ed5
parent24568789c4160182c44fa382138a19943f244083
[PGO] Control Height Reduction

Summary:
Control height reduction merges conditional blocks of code and reduces the
number of conditional branches in the hot path based on profiles.

if (hot_cond1) { // Likely true.
  do_stg_hot1();
}
if (hot_cond2) { // Likely true.
  do_stg_hot2();
}

->

if (hot_cond1 && hot_cond2) { // Hot path.
  do_stg_hot1();
  do_stg_hot2();
} else { // Cold path.
  if (hot_cond1) {
    do_stg_hot1();
  }
  if (hot_cond2) {
    do_stg_hot2();
  }
}

This speeds up some internal benchmarks up to ~30%.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: xbolva00, dmgreen, mehdi_amini, llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D50591

llvm-svn: 341386
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/LinkAllPasses.h
llvm/include/llvm/Transforms/Instrumentation/ControlHeightReduction.h [new file with mode: 0644]
llvm/include/llvm/Transforms/Utils.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/Instrumentation/CMakeLists.txt
llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp [new file with mode: 0644]
llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
llvm/test/Transforms/PGOProfile/chr.ll [new file with mode: 0644]