[PATCH] Quick look-up for block in loop

Wan, Xiaofei xiaofei.wan at intel.com
Thu Oct 24 06:06:36 PDT 2013


Hi atrick,

In LoopInfo.cpp and LoopInfoImpl.h, it is frequently to judge a specified block is in a loop or not, eg. getExitBlocks();

Currently the implementation is like this:
a. Copy all blocks into a vector and sort it, then use binary search to look up it.
b. Construct SmallPtrSet to implement quick search, when the set is small, it is same as the linear search in vector.

These two ways are proven very inefficient, it causes 2~4% performance penalty of llc for the cases with many loops; such as 458.sjeng, 429.mcf, 456.hmmer in CPUSpec2006.

This patch implement quick_contains() to look up a block in loop:
1. when the block size is small, look up the block vector directly to avoid construction of any other data container.
2. otherwise construct DenseSet to implement quick look-up.

This patch could introduce 2~3% compilation time improvement in llc for the benchmark with many loops. 

http://llvm-reviews.chandlerc.com/D2014

Files:
  include/llvm/Analysis/LoopInfo.h
  include/llvm/Analysis/LoopInfoImpl.h
  lib/Analysis/LoopInfo.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2014.1.patch
Type: text/x-patch
Size: 9317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131024/ee0a0c15/attachment.bin>


More information about the llvm-commits mailing list