OSDN Git Service

[PowerPC] Check hot loop exit edge in PPCCTRLoops
authorHiroshi Inoue <inouehrs@jp.ibm.com>
Mon, 5 Feb 2018 12:25:29 +0000 (12:25 +0000)
committerHiroshi Inoue <inouehrs@jp.ibm.com>
Mon, 5 Feb 2018 12:25:29 +0000 (12:25 +0000)
commit8041c24c9530539f3e4ddafae5470b3e6930c7c6
treea5081314e4ee6fb1f337d668df5df000fa2833db
parent703a63c82facf99524c5a9e5e10af6cda8d33864
[PowerPC] Check hot loop exit edge in PPCCTRLoops

PPCCTRLoops transform loops using mtctr/bdnz instructions if loop trip count is known and big enough to compensate for the cost of mtctr.
But if there is a loop exit edge which is known to be frequently taken (by builtin_expect or by PGO), we should not transform the loop to avoid the cost of mtctr instruction. Here is an example of a loop with hot exit edge:

for (unsigned i = 0; i < TripCount; i++) {
  // do something
  if (__builtin_expect(check(), 1))
    break;
  // do something
}

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324229 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCCTRLoops.cpp
test/CodeGen/PowerPC/ctrloops-hot-exit.ll [new file with mode: 0644]