[PATCH] D35804: [BPI] Detect branches in loops that make themselves not taken

John Brawn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 09:24:50 PDT 2017


john.brawn created this revision.

If we have a loop like this:

  int n = 0;
  while (...) {
   if (++n >= MAX) {
     n = 0;
   }
  }

then the body of the 'if' statement will only be executed once every MAX iterations. Detect this by looking for branches in loops where taking the branch makes the branch condition evaluate to 'not taken' in the next iteration of the loop, and reduce the probability of such branches.

This slightly improves EEMBC benchmarks on cortex-m4/cortex-m33 due to making better choices in if-conversion, but has no effect on any other cpu/benchmark that I could detect.


Repository:
  rL LLVM

https://reviews.llvm.org/D35804

Files:
  lib/Analysis/BranchProbabilityInfo.cpp
  test/Analysis/BranchProbabilityInfo/loop.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35804.107916.patch
Type: text/x-patch
Size: 11497 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170724/a5be97c4/attachment.bin>


More information about the llvm-commits mailing list