[llvm-commits] [llvm] r171436 - in /llvm/trunk/lib/Transforms/Vectorize: LoopVectorize.cpp LoopVectorize.h

Nadav Rotem nrotem at apple.com
Wed Jan 2 17:55:33 PST 2013


On Jan 2, 2013, at 5:12 PM, Hal Finkel <hfinkel at anl.gov> wrote:

> Interesting. Can you please explain your motivation for doing this? 


Hi Hal!

The loop vectorizer can now generate multiple vectors for each scalar instruction. You are right that we could have used the loop unrolled for some cases. Basically we could have duplicated the loop basic block and added a new kind of alias analysis to tell the scheduler that memory operations from consecutive iterations do not alias.  However, this approach would fail for code such as this one:

    for (int i = 0; i < n; ++i)
        sum += A[i];
 
The 'sum' variable is a reduction variable. In order to increase ILP we'd like to have two variables that accumulate the content of A.  The LoopVectorizer has all of the information and infrastructure to allow the partial unrolling of loops. 
Maybe the name 'unrolling' is misleading. We can think of it as wider vectors that are somehow split to legal register sizes.  

The next step would be to write code that calculates the register pressure in order to estimate the profitability of this transformation. 

Nadav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130102/a86b94fd/attachment.html>


More information about the llvm-commits mailing list