<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="">Ping?<div class=""><br class=""></div><div class="">Aditya<br class=""><div style=""><blockquote type="cite" class=""><div class="">On Jul 2, 2015, at 6:05 PM, Aditya Nandakumar <<a href="mailto:aditya_nandakumar@apple.com" class="">aditya_nandakumar@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10904&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=5-RRC9r0s-Q0lLlak-uzCG7183zyd5M8H9E8g_P5zx8&s=scMfXxEAiLlqHvt3VJ2KrsEBzpaUsGBUGWFyUV6OZLs&e=" class="">http://reviews.llvm.org/D10904</a><div class=""><br class=""></div><div class="">Added to phabricator.</div><div class=""><br class=""></div><div class="">Aditya<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jul 2, 2015, at 12:26 PM, Aditya Nandakumar <<a href="mailto:aditya_nandakumar@apple.com" class="">aditya_nandakumar@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi All<div class=""><br class=""></div><div class="">I think the handling of special case of divide by 1 is incorrect in udivsi3.c (compiler-rt) and it’s equivalent in llvm/lib/Transforms/Utils/IntegerDivision.cpp</div><div class=""><br class=""></div><div class="">I think we want to check if the clz(divisor) == (Num_word_bits - 1) rather than checking</div><div class="">(clz(divisor) - clz(dividend)) == (Num_word_bits - 1)</div><div class=""><br class=""></div><div class="">I also think compiler-rt should be updated - </div><div class=""><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_svn_llvm-2Dproject_compiler-2Drt_trunk_lib_builtins_udivsi3.c&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pW4Q1JdZMBOl8hRJ5f7uP2klbSmXe6EUr3CajMv6lhQ&s=YhRty41MrEPazrXTJ1lTya7lpHm4bykiDBdAK8w2OtU&e=" class="">http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/builtins/udivsi3.c</a></div><div class=""><br class=""></div><div class=""><pre style="word-wrap: break-word; white-space: pre-wrap;" class="">sr = __builtin_clz(d) - __builtin_clz(n);
    /* 0 <= sr <= n_uword_bits - 1 or sr large */
    if (sr > n_uword_bits - 1)  /* d > r */
        return 0;
    if (sr == n_uword_bits - 1)  /* d == 1 */
        return n;</pre><div class="">The last line should be replaced with </div></div><div class=""><span class="Apple-tab-span" style="white-space:pre">     </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre">  </span>if ( __buildin_clz(d) == n_uword_bits - 1)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>return n;</div><div class=""><br class=""></div><div class="">I have attached the LLVM patch here for the same.</div><div class=""></div></div><span id="cid:7F4CC9B4-D657-4AFF-A207-59D0E8CCC8AB@apple.com" class=""><DiffIntUnsignedDivision.patch></span><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""></div><div class=""><br class=""></div><div class="">Thanks</div><div class="">Aditya</div></div>_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class=""><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br class=""></div></blockquote></div><br class=""></div></body></html>