[PATCH] Quick look-up for block in loop
Hal Finkel
hfinkel at anl.gov
Thu Oct 24 06:23:04 PDT 2013
Wan,
Do you think that it would be worthwhile to cache the DenseSet once constructed?
Also, in LCSSA, we currently keep a cache of the sorted loop blocks array, solely for the purpose of this function:
/// inLoop - returns true if the given block is within the current loop
bool inLoop(BasicBlock *B) const {
return std::binary_search(LoopBlocks.begin(), LoopBlocks.end(), B);
}
With this new, more-efficient, functionality in LoopInfo, especially if we cache the resulting set, I think that it would make sense to remove this inLoop implementation from LCSSA and let it call the regular contains(BB) function.
Finally, when you post patches to llvm-reviews, please generate them with -U999999 so that we can see the full context in the web interface.
Thanks,
Hal
----- Original Message -----
> 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
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-commits
mailing list