<div dir="ltr">What kind of speedup are we talking, like approx % on + - % * for bignum integers and bignum rationals, of size ~10^25/~10^25?<div><br></div><div>For bignum rationals I guess GCD calculation is what really the heaviest work; will this make GCD calculation faster too?<br><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-01-18 2:49 GMT+05:30 Bradley Lucier <span dir="ltr"><<a href="mailto:lucier@math.purdue.edu" target="_blank">lucier@math.purdue.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    I just noticed this in<br>
    <br>
    <a href="https://gcc.gnu.org/gcc-5/changes.html" target="_blank">https://gcc.gnu.org/gcc-5/changes.html</a><br>
    <br>
    <div>
      <div>
        <li>A new set of built-in functions for arithmetics with
          overflow checking has been added: <code>__builtin_add_overflow</code>,
          <code>__builtin_sub_overflow</code> and <code>__builtin_mul_overflow</code>
          and for compatibility with clang also other variants. These
          builtins have two integral arguments (which don't need to have
          the same type), the arguments are extended to infinite
          precision signed type, <code>+</code>, <code>-</code> or <code>*</code>
          is performed on those, and the result is stored in an integer
          variable pointed to by the last argument. If the stored value
          is equal to the infinite precision result, the built-in
          functions return <code>false</code>, otherwise <code>true</code>.
          The type of the integer variable that will hold the result can
          be different from the types of the first two arguments. The
          following snippet demonstrates how this can be used in
          computing the size for the <code>calloc</code> function:
          <blockquote>
            <pre>void *
calloc (size_t x, size_t y)
{
  size_t sz;
  if (__builtin_mul_overflow (x, y, &sz))
    return NULL;
  void *ret = malloc (sz);
  if (ret) memset (res, 0, sz);
  return ret;
}
</pre>
          </blockquote>
          On e.g. i?86 or x86-64 the above will result in a <code>mul</code>
          instruction followed by a jump on overflow. </li>
      </div>
    </div>
    <br>
    Maybe we can exploit this to improve the speed of bignum arithmetic.<br>
    <br>
    Brad<br>
  </div>

<br>_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca" target="_blank">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
<br></blockquote></div><br></div></div></div>