This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] Fix PR 17568: Shortcomings in ISHFT constant folder
- From: Paul Brook <paul at codesourcery dot com>
- To: fortran at gcc dot gnu dot org
- Cc: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 4 Oct 2004 18:35:15 +0100
- Subject: Re: [gfortran] Fix PR 17568: Shortcomings in ISHFT constant folder
- Organization: CodeSourcery
- References: <415F024E.9040602@physik.uni-muenchen.de>
> (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