This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] Fix PR 17568: Shortcomings in ISHFT constant folder


> (Other bitwise operations might still be faulty, I haven't checked them)

They probably are faulty.

> 2004-10-02  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
>
>  PR fortran/17568
>  * simplify.c (twos_complement): New function.
>  (gfc_simplify_ishft, gfc_simplify_ishftc): Revise.

You twos_complement routine is flawed:

> + static void
> + twos_complement (mpz_t x, int bitsize)
> + {
> + ? mpz_t mask;
> + ? unsigned long mask_i;
> + 
> + ? if (mpz_tstbit (x, bitsize - 1) == 1)
> + ? ? {
> + ? ? ? mask_i = (bitsize == sizeof(long) * 8) ? ~0 : (1 << bitsize) - 1;

Doesn't work when bitsize > sizeof(long)*8. 

Other than that, looks ok.

Paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]