[llvm-dev] Loop Unrolling Fail in Simple Vectorized loop

Charith Mendis via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 12 16:35:06 PDT 2016


Hi all,

Attached herewith is a simple vectorized function with loops performing a
simple shuffle.

I want all loops (inner and outer) to be unrolled by 2 and as such used
-unroll-count=2
The inner loops(with k as the induction variable and having constant trip
counts) unroll fully, but the outer loop with (j) fails to unroll.

The llvm code is also attached with inner loops fully unrolled.

To inspect further, I added the following to the PassManagerBuilder.cpp to
run some canonicalization routines and redo unrolling again. I have set
partial unrolling on + have a huge threshold + allows expensive loop trip
counts. Still it didn't unroll by 2.

MPM.add(createLoopUnrollPass());

MPM.add(createCFGSimplificationPass());

MPM.add(createLoopSimplifyPass());

MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));

MPM.add(createLCSSAPass());

MPM.add(createIndVarSimplifyPass());        // Canonicalize indvars

MPM.add(createLoopUnrollPass());


Digging deeper I found, that it fails in UnrollRuntimeLoopRemainder
function, where it is unable to calculate the BackEdge taken amount.

Can anybody explain what is need to get the outer loop unrolled by 2? It
would be a great help.

Thanks.
-- 
Kind regards,
Charith Mendis

Graduate Student,
CSAIL,
Massachusetts Institute of Technology
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161012/1efd6500/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_unroll_sse2.c
Type: text/x-csrc
Size: 1431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161012/1efd6500/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: out.ll
Type: application/octet-stream
Size: 6090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161012/1efd6500/attachment.obj>


More information about the llvm-dev mailing list