<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">More generally, for any lane-predicated architecture, the introduction of a fixup loop is generally a bad idea.<div class=""><br class=""></div><div class="">—Owen</div><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Apr 4, 2016, at 1:52 PM, via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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; float: none; display: inline !important;" class="">Oh, absolutely; it seems reasonable for runtime unrolling (since usually with runtime unrolling you can’t avoid a fixup loop at all unless you actually know the trip count is divisible by some N, which seems fairly unlikely). I can see partial unrolling being useful in this way in some cases, but it’s not what we want (and not what it did before); do you need partial unrolling to work this way for your target?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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; float: none; display: inline !important;" class="">—escha<span class="Apple-converted-space"> </span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class="">On Apr 4, 2016, at 1:45 PM, Evgeny Stupachenko <<a href="mailto:evstupac@gmail.com" class="">evstupac@gmail.com</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">if (Count <= 1 && Unrolling == Runtime) {<br class=""></blockquote>for sure I mean this somewhere else in code.<br class="">Just allow this type of unrolling when unroll runtime is set.<br class=""><br class=""><br class=""><br class=""><br class="">On Mon, Apr 4, 2016 at 1:42 PM, Fiona Glaser <<a href="mailto:fglaser@apple.com" class="">fglaser@apple.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="">On Apr 4, 2016, at 1:41 PM, via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>><br class="">wrote:<br class=""><br class=""><br class="">On Apr 4, 2016, at 1:35 PM, Evgeny Stupachenko <<a href="mailto:evstupac@gmail.com" class="">evstupac@gmail.com</a>> wrote:<br class=""><br class="">Before the patch the loop<br class="">for (i = 0; i < 15; i++)<br class="">loop_body;<br class="">was not unrolled,<br class=""><br class="">the loop<br class="">for (i = 0; i < 16; i++)<br class="">loop_body;<br class="">was unrolled<br class=""><br class="">the loop<br class="">for (i = 0; i < n; i++)<br class="">loop_body;<br class="">was unrolled<br class=""><br class="">Why we should avoid unrolling if threshold let us unroll a loop?<br class="">The sense of unrolling (right now) is to reduce induction variable and<br class="">compare/branch costs.<br class=""><br class="">One of possible solutions is to add " && Unrolling == Runtime":<br class=""><br class="">   if (Count <= 1 && Unrolling == Runtime) {<br class=""><br class=""><br class=""><br class="">What do you mean? That code is already under this branch:<br class=""><br class="">if (Unrolling == Partial) {<br class=""><br class="">So it would never trigger, if I’m reading this right.<br class=""><br class="">However I still do not understand why we should avoid unrolling if<br class="">threshold let us unroll a loop?<br class="">For the cases where unroll is unprofitable there should be<br class="">corresponding heuristics.<br class="">What is your case?<br class=""><br class=""><br class="">You’ve changed the definition of “partial” unrolling from what it did<br class="">before, which makes me someone nervous in general. Our specific use-case for<br class="">partial unrolling is that GPUs want to reduce latency, so a big loop with<br class="">high-latency memory operations in it (too big to fully unroll) should be<br class="">partially unrolled to trade some number of registers for some amount of<br class="">latency reduction. However, suppose the following case occurs:<br class=""><br class="">Trip count: 15<br class="">Max unroll count: 8<br class=""><br class="">This means we unroll 8 times, then create a fixup loop that runs 7 times<br class="">afterwards. Now we have the absolute worst of both worlds: our register<br class="">count has gone up a lot because of the unroll, but we still have a lot of<br class="">latency because of the fixup loop, so we’ll probably end up losing<br class="">performance overall.<br class=""><br class="">—escha<br class=""><br class=""><br class="">Corrected example:<br class=""><br class="">Trip count: 13<br class="">Max unroll count: 8<br class="">Fixup loop size: 5<br class=""><br class="">(The 15 case wouldn’t happen because it’d do a modulo-unroll of size 5).<br class=""><br class="">—escha<br class=""><br class=""></blockquote></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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; float: none; display: inline !important;" class="">llvm-commits mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><a href="mailto:llvm-commits@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class="">llvm-commits@lists.llvm.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; 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;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a></div></blockquote></div><br class=""></div></div></body></html>