[llvm-dev] Implement Loop Fusion Pass
Vikram TV via llvm-dev
llvm-dev at lists.llvm.org
Thu Feb 18 09:21:14 PST 2016
I have created a patch (up for review at: http://reviews.llvm.org/D17386)
that does Loop Fusion implementation.
Legality: Currently it can fuse two adjacent loops whose iteration spaces
are same and are at same depth.
Dependence legality: Currently, dependence legality cannot be checked
across loops. Hence the loops are cloned along a versioned path,
unconditionally fused along that path and then the dependence legality is
checked on the fused loop keeping the instructions from original loops in
context. Fusion is illegal if there is a backward dependence between memory
accesses whose source was in first loop and sink was in second loop.
Currently, LoopAccessAnalysis is used to check dependence legality.
A basic diagram below tries to explain the approach taken to test
dependence legality on two adjacent loops (L1 and L2).
L1PH (PH: Preheader)
CB (L1Exit/L2PH: ConnectingBlock (CB) )
is versioned as:
And fused as:
| | \
CB L2Blocks |
| | |/
Profitability: Yet to be added.
Further, based on legality and profitability success, the fused loop is
either retained or removed. If runtime checks are necessary, both original
and fused loops are retained; otherwise the original loops are removed.
Currently, I have scheduled the fusion pass after distribution pass. Such a
schedule negates the effect of the other pass, but given that the
distribution (and fusion) pass is experimental and off by default, I felt
it was okay to schedule that way till a global profitability is implemented.
Please share your feedback about the design and implementation.
Mysore, Karnataka, INDIA
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev