bridge/class-master/depend/pari/src/modules/mpqs.c
/* Could make shameless use of the fact that M is divisible by 4, but
 * let the compiler worry about loop unrolling.  Indeed I wonder whether
 * modern compilers woudln't have an easier time optimizing this if it
 * were written as array accesses.  Doing so. */
Could make shameless use of the fact that M is divisible by 4, but
let the compiler worry about loop unrolling.  Indeed I wonder whether
modern compilers woudln't have an easier time optimizing this if it
were written as array accesses.  Doing so.
Could make shameless use of the fact that M is divisible by 4 but let the compiler worry about loop unrolling . Indeed I wonder whether modern compilers woudln ' t have an easier time optimizing this if it were written as array accesses . Doing so .
static long
mpqs_eval_sieve(mpqs_handle_t *h)
{
  long x = 0, count = 0, M_2 = h->M << 1;
  unsigned char th = h->sieve_threshold;
  unsigned char *sieve_array = h->sieve_array;
  long *candidates = h->candidates;
  while (count < MPQS_CANDIDATE_ARRAY_SIZE - 1)
  {
    while (sieve_array[x] < th) x++;
    if (x >= M_2) break;
    candidates[count++] = x++;
  }
  candidates[count] = 0; return count;
}
static long mpqs_eval_sieve ( mpqs_handle_t * h ) { long x = 0 , count = 0 , M_2 = h -> M << 1 ; unsigned char th = h -> sieve_threshold ; unsigned char * sieve_array = h -> sieve_array ; long * candidates = h -> candidates ; while ( count < MPQS_CANDIDATE_ARRAY_SIZE - 1 ) { while ( sieve_array [ x ] < th ) x ++ ; if ( x >= M_2 ) break ; candidates [ count ++ ] = x ++ ; } candidates [ count ] = 0 ; return count ; }
Could make shameless use of the fact that M is divisible by 4, but
 let the compiler worry about loop unrolling.
Could make shameless use of the fact that M is divisible by 4 but let the compiler worry about loop unrolling .
/* TODO: replace the following by an auto-adjusting threshold driven
   * by histogram yield measurements */ /* The following variation on the original is marginally faster with a
   * good optimizing compiler.  Exploiting the sentinel, we don't need to
   * check for x < M_2 in the inner while loop - this more than makes up
   * for the "lack" of explicit unrolling.  Optimizations like loop
   * unrolling are best left to the compiler anyway... */