This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[gfortran] Fix PR 17568: Shortcomings in ISHFT constant folder
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: GCC Fortran mailing list <fortran at gcc dot gnu dot org>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 02 Oct 2004 21:32:30 +0200
- Subject: [gfortran] Fix PR 17568: Shortcomings in ISHFT constant folder
Our implementation of ISHFT and ISHFTC had several issues which had to do with
not converting to/from two's complement correctly, and with not respecting the
bit width of the result. Attached patch fixes this.
It introduces a function twos_complement() which converts its argument to
two's complement, i.e. it checks if the highest bit is set and if it is set,
replaces its argument by the corresponding negative number.
This is used in the revised implementations of the ISHFT and ISHFTC folders
(which are straightforward), to get the correct result.
Patch attached, ChangeLog below. Built and tested.
(Other bitwise operations might still be faulty, I haven't checked them)
- Tobi
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.