dead code in div_q.c?

Niels Möller nisse at lysator.liu.se
Fri Apr 27 19:50:16 UTC 2018


nisse at lysator.liu.se (Niels Möller) writes:

> --- a/tests/mpn/t-div.c	Wed Apr 25 07:38:14 2018 +0200
> +++ b/tests/mpn/t-div.c	Wed Apr 25 22:19:17 2018 +0200
> @@ -445,6 +445,7 @@ main (int argc, char **argv)
>  	      alloc = itch + 1;
>  	    }
>  	  scratch[itch] = ran;
> +	  MPN_COPY (qp, junkp, nn - dn + 1);
>  	  mpn_div_q (qp, np, nn, dup, dn, scratch);
>  	  ASSERT_ALWAYS (ran == scratch[itch]);
>  	  ASSERT_ALWAYS (qp[-1] == qran0);  ASSERT_ALWAYS (qp[nn - dn + 1] == qran1);

Committed.

> *** /tmp/extdiff.0aBNfO/gmp.765c2c27523b/mpn/generic/div_q.c	2018-04-25 21:55:51.457769871 +0200
> --- /home/nisse/hack/gmp/mpn/generic/div_q.c	2018-04-25 21:18:01.516501993 +0200
> *************** mpn_div_q (mp_ptr qp,
> *** 171,184 ****
>   	  if (cy == 0)
>   	    qp[qn - 1] = qh;
> ! 	  else if (UNLIKELY (qh != 0))
> ! 	    {
> ! 	      /* This happens only when the quotient is close to B^n and
> ! 		 mpn_*_divappr_q returned B^n.  */
> ! 	      mp_size_t i, n;
> ! 	      n = new_nn - dn;
> ! 	      for (i = 0; i < n; i++)
> ! 		qp[i] = GMP_NUMB_MAX;
> ! 	      qh = 0;		/* currently ignored */
> ! 	    }
>   	}
>         else  /* divisor is already normalised */
> --- 171,176 ----
>   	  if (cy == 0)
>   	    qp[qn - 1] = qh;
> ! 	  else
> ! 	    ASSERT_ALWAYS (qh == 0);
>   	}
>         else  /* divisor is already normalised */

And committed this first part (but with ASSERT instead of ASSERT_ALWAYS);.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list