[PATCH] instcombine: Only create library call simplifier once

Meador Inge meadori at codesourcery.com
Mon Mar 11 06:29:41 PDT 2013


On 03/07/2013 07:37 PM, Nadav Rotem wrote:

> Hi Meador, 
> 
> I spoke with Bill about this and I now think that your proposal to initialize
> the SimplifyLibCalls on the first invocation of runOnFunction is correct. The
> only exception is LTO build. On LTO builds we can change the TargetData and TLI
> per-function. So, on each runOnFunction we need to check of the current TLI and
> DataLayout is the same as the previous run. If it is not the we need to
> re-initialize the SimpLibCalls, rehash the table, etc. 

Hi Nadav,

After thinking about this a little more caching the LibCallSimplifier object on
the first call makes me a little nervous and I agree with the original
objections to it.  This motivated me to try something different.  The attached
patch drops the hash table and does an explicit lookup for each of the lib call
simplifier optimizers.

This should alleviate Michael's concerns about caching the object in
runOnFunction, short circuits the intrinsic case Michael is interested in,
avoid repeatedly building and destroying the hash table, and benefits all
clients of LibCallSimplifier.

There is a slight overhead for the new lookup function, but it is still much
better than the current approach.  On a benchmark containing 100,000 calls
where *none* of them are simplified I noticed a 30% speedup.  On a benchmark
containing 100,000 calls where *all* of them are simplified I noticed an 8%
speedup.  The original LibCallSimplifier caching patch also obtained a 30%
speedup in the case where nothing was simplified and a 13% speedup when all
calls where simplified.  I am comfortable that the new patch is slightly slower
for some cases (this is on average.  I saw a few runs where the too approaches
gave equivalent speedups).

Comments?  Would you all mind trying this patch for the benchmarks that you all
are interested in?  I personally like the new patch better.

-- 
Meador Inge
CodeSourcery / Mentor Embedded
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-LibCallSimplifier-optimize-speed-for-short-lived-ins.patch
Type: text/x-patch
Size: 16320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130311/64f09db2/attachment.bin>


More information about the llvm-commits mailing list