[PATCH] D25626: [Inliner] Inlining to enable more loop unrolling
Robert Cox via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 14 09:44:08 PDT 2016
rcox2 created this revision.
rcox2 added reviewers: reames, chandlerc.
rcox2 added subscribers: zansari, llvm-commits.
Herald added subscribers: eraman, sanjoy.
This patch extends the inliner to give a stronger preference to inline functions which allow trip counts of inner loops to become small constants in the inlined code.
For example:
extern int foo(int m, int n, float b[n], float a[m][n]) {
for (i = 0; I < n; i++)
for (j = 0; j < m; j++)
a[i][j] = a[i][j] + b[i]
}
extern int main() {
float b[4], a[3,4];
…
foo(3, 4, b, a);
…
}
Inlining foo will expose the inner loop bound of 3. Such loops can be good candidates for complete unrolling.
The function convolve() in the geekbench benchmark sharpen_filter is another such example.
The max trip count value chosen is defined in include/llvm/Analysis/InlineCost.h as
const int SmallTripCountMax = 10;
to match the default value of UnrollMaxIterationsCountToAnalyze in lib/Transforms/Scalar/LoopUnrollPass.cpp.
The patch makes use of DominatorTree, LoopInfo, and ScalarExpansion to find loops and potential constant loop trip counts in the potentially inlined functions. An instance of InliningLoopInfoCache is used to cache results for functions and so that compile time is not spent recomputing the DominatorTree, LoopInfo, and ScalarExpansion info for functions into which no inlining has occurred. Our experiments show that this cache is an effective and essential mechanism to keep the inlining compile time low.
Patch by Robert Cox
https://reviews.llvm.org/D25626
Files:
include/llvm/Analysis/InlineCost.h
include/llvm/Transforms/IPO/InlinerPass.h
lib/Analysis/InlineCost.cpp
lib/Transforms/IPO/InlineSimple.cpp
lib/Transforms/IPO/Inliner.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25626.74704.patch
Type: text/x-patch
Size: 16212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161014/2f8e0cb3/attachment.bin>
More information about the llvm-commits
mailing list