[llvm-commits] [patch] ThreeStageLoopUnroll

Daniel Nicácio dnicacios at gmail.com
Fri Sep 23 11:07:49 PDT 2011


This Patch improves the LoopUnroll Pass.

First it identifies special cases where a three stage loop unrolling is
desired. For example, if a loop updates an unaligned region of a bit array,
it is desired that this pass generates a first loop that updates just some
bits on the first word, a main loop that updates all intermediate words and
a final loop that updates just some bits on the last word. This way, the
main loop can be made canonical and further optimized.

After splitting the loop into the three stage loops, it unrolls the main
loop by a factor of 32, 64 or any other number that can generate further
optimization opportunities. Hopefully, those optimizations will collapse the
unrolled loop into a more efficient and smaller loop.

This first version simply identifies loops that contain a "lshr X, 5" or
"lshr X, 6" instruction and the result of that instruction is used to index
an array.

The heuristic to find loop candidates for this special unrolling can (and
must) be further improved, since this special three stage unrolling is going
to be very useful for vectorization passes and can also be used in other
cases, like a memcopy and so on.

The very purpose of this first patch is to get a feedback from the community
on the idea of the three stage loop unrolling. Comments and Critics are very
welcome.
The next step is going to make the code much more generic.

Thanks

Daniel Nicacio

ps: I still have to come up with a simpler test case, it is in my TODO list
;)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110923/01ce674b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: threeStageUnroll.diff
Type: application/octet-stream
Size: 47675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110923/01ce674b/attachment.obj>


More information about the llvm-commits mailing list