<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 15, 2017 at 2:28 PM, Stephen Canon 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"><span class="">On Feb 15, 2017, at 2:22 PM, Bagel via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
<br>
> I suggest that LLVM needs intrinsics for add/sub with carry, e.g.<br>
><br>
>  declare {T, i1} @llvm.addc.T(T %a, T %b, i1 c)<br>
><br>
> The current multiprecision clang intrinsics example:<br>
>  void foo(unsigned *x, unsigned *y, unsigned *z)<br>
>  { unsigned carryin = 0;<br>
>    unsigned carryout;<br>
>    z[0] = __builtin_addc(x[0], y[0], carryin, &carryout);<br>
>    carryin = carryout;<br>
>    z[1] = __builtin_addc(x[1], y[1], carryin, &carryout);<br>
>    carryin = carryout;<br>
>    z[2] = __builtin_addc(x[2], y[2], carryin, &carryout);<br>
>    carryin = carryout;<br>
>    z[3] = __builtin_addc(x[3], y[3], carryin, &carryout);<br>
>  }<br>
> uses the LLVM intrinsic "llvm.uadd.with.overflow" and generates<br>
> horrible code that doesn't use the "adc" x86 instruction.<br>
><br>
> What is the current thinking on improving multiprecision arithmetic?<br>
<br>
</span>Why do you think this requires new intrinsics instead of teaching the optimizer what to do with the existing intrinsics?<br></blockquote><div><br></div><div>In general, it is harder to reason about memory. Also, you are forced to allocate memory for the carryout even if you are not interested in using it.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
– Steve<br>
<div class="HOEnZb"><div class="h5">______________________________<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>
</div></div></blockquote></div><br></div></div>