Branch: Tag:

2015-08-06

2015-08-06 21:23:39 by Per Hedbor <ph@opera.com>

Todays micro-optimization: avoid re-doing overflowing multiplications.

Use the full 128-bit result from imul. Not really all that much of an
improvement in most cases, presumably.

The same thing can however also be done for + and -, at a minimum.

In general more mpz operations could be inlined where it makes sense
(the operators, mainly).

470:    return 1;   }    + PMOD_EXPORT struct object *create_double_bignum( INT_TYPE low, INT_TYPE high ) + { +  struct object *res = fast_clone_object( bignum_program ); +  MP_INT *mpz = (MP_INT*)res->storage; +  INT_TYPE data[2]; +  if( UNLIKELY(high < 0) ) +  { +  data[0] = -low; +  data[1] = -high; +  mpz_import( mpz, 2, -1, sizeof(INT_TYPE), 0, 0, data ); +  mpz_neg( mpz,mpz ); +  } +  else +  { +  data[0] = low; +  data[1] = high; +  mpz_import( mpz, 2, -1, sizeof(INT_TYPE), 0, 0, data ); +  } +  return res; + } +    /* Converts an svalue, located on the stack, to an mpz object */   MP_INT *debug_get_mpz(struct svalue *s,    int throw_error, const char *arg_func, int arg, int args)