[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reading uninitialized memory
From: |
Andrew Vaught |
Subject: |
Re: Reading uninitialized memory |
Date: |
Sat, 26 Jan 2002 14:45:56 -0700 (MST) |
On 27 Jan 2002, Kevin Ryde wrote:
> The question is basically whether to add a conditional jump over the
> read. I think on the important processors it's best to avoid
> conditionals wherever possible.
No, I'm just saying move the read. The original code looks like:
mp_size_t size = op->_mp_size;
mp_limb_t low_limb = op->_mp_d[0];
if (size > 0)
return low_limb % ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1));
else if (size < 0)
/* This convoluted expression is necessary to properly handle 0x80000000 */
return ~((low_limb - 1) % ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1)));
else
return 0;
I'm advocating changing it to
mp_size_t size = op->_mp_size;
if (size > 0)
return op->_mp_d[0] % ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1));
else if (size < 0)
/* This convoluted expression is necessary to properly handle
0x80000000 */
return ~((op->_mp_d[0] - 1) % ((mp_limb_t) 1 << (BITS_PER_MP_LIMB -1)));
else
return 0;
ie, don't read the word until you need to.
> It's also worth remembering that the only time the load is not wanted
> is when the value in the mpz_t is zero, and I think non-zero is
> probably the more common case.
Right, and that's why I'm not saying that the conditional should be
rewritten. The least common case should be last.
Andy
----------------- XOLD(K,IC,I)=
Andy Vaught .... DO ITERS=1, 10 XOLD(K,IC,I)
address@hidden | | /CALLMSOLVE(A,B,X,I,ITERS,TOL)+(RANNYU(0)
Arizona State University ======|WRITE(6,'(I5,2X,F12.6)')ITERS,TOL -HALF)
Tempe, Arizona USA OOOOOO \ENDDORETURN PARAMETER(ZERO=1.D0)*TENTH*DELTA
- Reading uninitialized memory, Andrew Vaught, 2002/01/25
- Re: Reading uninitialized memory, Torbjorn Granlund, 2002/01/25
- Re: Reading uninitialized memory, Andrew Vaught, 2002/01/25
- Re: Reading uninitialized memory, Torbjorn Granlund, 2002/01/25
- Re: Reading uninitialized memory, Kevin Ryde, 2002/01/25
- Re: Reading uninitialized memory, Andrew Vaught, 2002/01/26
- Re: Reading uninitialized memory, Kevin Ryde, 2002/01/26
- Re: Reading uninitialized memory,
Andrew Vaught <=
- Re: Reading uninitialized memory, Torbjorn Granlund, 2002/01/26
- Re: Reading uninitialized memory, Kevin Ryde, 2002/01/26
- Re: Reading uninitialized memory, Andrew Vaught, 2002/01/26
- Re: Reading uninitialized memory, Torbjorn Granlund, 2002/01/26
- Re: Reading uninitialized memory, Andrew Vaught, 2002/01/26