<div dir="ltr">divq only produces a 64-bit result. There's way for the compiler to know you didn't divide a greater than 64-bit number by 1 or some other value that required a large result.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Thu, Oct 19, 2017 at 1:47 PM, Paweł Bylica via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi there,<div><br></div><div>Let's have this C code:</div><div><br></div><div><div style="line-height:19px"><div style="color:rgb(0,0,0);font-family:"Fira Mono";font-size:14px;white-space:pre-wrap;background-color:rgb(255,255,254)"><span style="color:rgb(0,0,255)">unsigned</span> <span style="color:rgb(0,0,255)">long</span> div(<span style="color:rgb(0,0,255)">unsigned</span> <span style="color:rgb(0,0,255)">__int128</span> n, <span style="color:rgb(0,0,255)">unsigned</span> <span style="color:rgb(0,0,255)">long</span> d)</div><div style="color:rgb(0,0,0);font-family:"Fira Mono";font-size:14px;white-space:pre-wrap;background-color:rgb(255,255,254)">{</div><div style="color:rgb(0,0,0);font-family:"Fira Mono";font-size:14px;white-space:pre-wrap;background-color:rgb(255,255,254)"> <span style="color:rgb(0,0,255)">return</span> n / d;</div><div style="color:rgb(0,0,0);font-family:"Fira Mono";font-size:14px;white-space:pre-wrap;background-color:rgb(255,255,254)">}</div><div style="color:rgb(0,0,0);font-family:"Fira Mono";font-size:14px;white-space:pre-wrap;background-color:rgb(255,255,254)"><br></div><div><span style="background-color:rgb(255,255,255)">I would assume that the divq is the perfect match here. But the compiler generates the</span></div><div><span style="background-color:rgb(255,255,255)">code that calls the </span>__udivti3 procedure which performs 128-bit by 128-bit division.</div><div><br></div><div>Why is divq not used here?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>- Paweł</div></font></span></div></div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>