This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[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.


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