[gfortran] Make gfortran pass g77 test f90-intrinsic-bit.f90
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Tue Dec 14 20:59:00 GMT 2004
This required a number of changes/fixes:
1. ISHFT had an implementation error: in the case where the shift width was
equal to the arguments bit width, we would give an erroneous result, as this
case is not specified for gcc's {L|R}SHIFT_EXPR, but required by the Fortran
standard. I also removed the shortcut for 0-bit shifts, as I figured that
it's the optimizers job to figure these things out.
2. Our implementation of ISHFT was, even though valid, incompatible with other
compilers: we were doing arithmetic shifts, where other compilers do logical
shifts. Fixed. While I was touching this code I also added calls to fold
where appropriate.
3. we didn't have library implementations ISHFTC for INTEGER*1 or INTEGER*2
arguments. Instead of adding library implementations for these, I chose to
convert the argument to INTEGER*4, and convert the function's result back to
the original type. While I was doing this, I also cononicalized the second
and third argument to INTEGER*4 where they were previously converted to the
type of the first argument. While I was touching this code I also added calls
to fold where appropriate. (I didn't remove the 0-bit shift shortcut here, as
I noticed this only after I had tested the patch.)
4. I added library implementations for the INTEGER*1 and INTEGER*2 variants of
MVBITS. Unfortunately, this can't be implemented by the same typecasting
trickery as I did for ISHFT, as for some reason I don't understand MVBITS is a
subroutine.
Bubblestrapped and regtested, diff attached. I also attached the new testcase.
Ok?
- Tobi
2004-12-14 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
libgfortran/:
* intrinsics/ishftc.c: Update copyright years.
(ishftc8): Change 'shift' and 'size' to GFC_INTEGER_4.
* intrinsics/mvbits.c: Correcty non-ASCII character in my name. Add
implementations for GFC_INTEGER_{1|2}.
gcc/fortran/:
* trans-intrinsic.c (gfc_conv_intrinsic_ishft): Change to logical
shift. Call fold. Remove 0-bit shift shortcut.
(gfc_conv_intrinsic_ishftc): Convert first argument to at least 4
bytes bits. Convert 2nd and 3rd argument to 4 bytes. Convert result
if width(arg 1) < 4 bytes. Call fold.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bitops.diff
Type: text/x-patch
Size: 10208 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20041214/692f294d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f90-intrinsic-bit.f
Type: text/x-fortran
Size: 16171 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20041214/692f294d/attachment-0001.bin>
More information about the Fortran
mailing list