<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On May 16, 2013, at 5:07 PM, Paul Sokolovsky <<a href="mailto:pmiscml@gmail.com">pmiscml@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hello,<br><br>I'd be interested in knowing which pass performs loop inversion, i.e.<br>transforms while loop into do/while wrapped with if. So, it's pretty<br>easy to understand concept,<span class="Apple-converted-space"> </span><a href="http://en.wikipedia.org/wiki/Loop_inversion">http://en.wikipedia.org/wiki/Loop_inversion</a><br>provides description of how its done and motivation, googling gives<br>several relevant references, i.e. it's pretty settled term.<br><br>I also see this transform to be actually performed on trivial strlen<br>function by clang -O2. However opt --help or grepping LLVM doesn't give<br>any hints.<br><br>However, -loop-rotate calls attention, described as "A simple loop<br>rotation transformation." However, Wikipedia doesn't gives hits for<br>that related to compilation/optimization theory, nor google hits are<br>relevant either - mostly LLVM-related hits just mentioning the term.<br><br>Trying -loop-rotate, I see loop being converted to post-condition, but<br>don't see if wrapper around it.<br><br>So, can anyone suggest if LLVM loop rotation is related to loop<br>inversion in Wikipedia terms, and if not, what it is.<br></div></blockquote><div><br></div><div>On simple ‘for’ loops, rotation degenerates to inversion. Rotation is a more general transform that spans the range from inversion to loop peeling...</div><div><br></div><div>loop:</div><div>A</div><div>br X</div><div>B</div><div>br loop, Y</div><div><br></div><div>A’</div><div>br X</div><div>loop:</div><div>B</div><div>br Y</div><div>A</div><div>br loop, X</div><div><br></div><div>Sorry I don’t know of a text-book reference off-hand. I’ve seen it in practice before and assumed it was pretty standard. In LLVM it’s mostly used to put loops in a canonical form, but it’s also a cheap and dirty way to expose LICM. Another benefit is simplifying trip count expressions.</div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">And I hope that this feedback will allow maintainers to make<br>documentation clearer and more user-friendly.<br></div></blockquote><div><br></div><div>Me too :) Not sure if I’ll get around to it, but I’d be happy to review a patch.</div><div><br></div>-Andy</div><div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Thanks,<br>Paul <a href="mailto:pmiscml@gmail.com">mailto:pmiscml@gmail.com</a><br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span> <a href="http://llvm.cs.uiuc.edu/">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></blockquote></div><br></body></html>