[PATCH] D28460: getLoopEstimatedTripCount should really be called getLoopEstimatedBackedgeTakeCount.

Dehao Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 10:54:40 PST 2017


danielcdh added a comment.

cat b.cc
========

int bar(int);

void foo(int a) {

  while (a) {
    a = bar(a);
  }

}

#cat c.cc
void foo(int);

int bar(int x) {

  return x - 1;

}

int main() {
 foo(5);
 return 0;
}

#clang  -O2 -fprofile-generate=prof.raw b.cc c.cc -o instr_bin
#llvm-profdata merge prof.raw -o prof
#clang b.cc -c -O2 -fprofile-use=prof -emit-llvm
#opt -S b.bc |grep branch_weights
!29 = !{!"branch_weights", i32 1, i32 5}

Looks like (5 + 1/2) / 1 = 5 is the correct trip count?


https://reviews.llvm.org/D28460





More information about the llvm-commits mailing list