<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="">Hi,<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 9, 2016, at 6:39 PM, Alexandre Isoard via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello,<div class=""><br class=""></div><div class="">I was doing some experiments with SCEV and especially the loop trip count.</div><div class="">Sorry for the dumb question, what is the easiest way to dump SCEV analysis results on a .bc file?</div></div></div></blockquote>opt -analyze -scalar-evolution < file.bc</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">On a side note, I wanted to see if we could optimize this function:</div><div class=""><br class=""></div><div class=""><div class=""><font face="monospace, monospace" class="">unsigned long kernel(long w, long h, long d) {</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">     </span>unsigned long count = 0;</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">      </span>for(int i = 0; i < w; ++i)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">         </span>for(int j = i; j < h; ++j)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">                 </span>for(int k = j; k < d; ++k)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">                         </span>++count;</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">      </span>return count;</font></div><div class=""><font face="monospace, monospace" class="">}</font></div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><br class=""></div><div class="">into this (it might not take into account overflows, it was generated using the barvinok library):</div></div></div></div></blockquote>Looks like we can not, but I haven’t examined why. Overflows might indeed get into the way.</div><div><br class=""></div><div>Michael</div><div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><font face="monospace, monospace" class="">unsigned long kernel2(long w, long h, long d) {</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">       </span>return</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">                </span>(-1 + w >= 0 && -1 - w + h >= 0 && -1 - h + d >= 0)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">          </span>? (((((2 * w - 3 * w*w + w*w*w) + 3 * w * h + -3 * w * h*h) + ((3 * w - 3 * w*w) + 6 * w * h) * d))/6)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">                </span>: (-1 + w >= 0 && -1 - w + d >= 0 && h - d >= 0)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">             </span>? ((((2 * w - 3 * w*w + w*w*w) + (6 * w - 3 * w*w) * d + 3 * w * d*d))/6)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">             </span>: (-1 + h >= 0 && w - h >= 0 && -1 - h + d >= 0)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">             </span>? ((((2 * h - 2 * h*h*h) + (3 * h + 3 * h*h) * d))/6)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">         </span>: (-1 + d >= 0 && h - d >= 0 && w - d >= 0)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">          </span>? (((2 * d + 3 * d*d + d*d*d))/6)</font></div><div class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">             </span>: 0;</font></div><div class=""><font face="monospace, monospace" class="">}</font></div></div><div class=""><br class=""></div><div class="">I am not sure how advanced are SCEV-based trip counts.</div><div class=""><br class=""></div><div class="">Best regards.</div><div class=""><br class="">-- </div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><b class="">Alexandre Isoard</b><br class=""></div></div>
</div></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>