This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gfortran] Updates to ISHFT translation
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Richard Henderson <rth at redhat dot com>
- Cc: GCC Fortran mailing list <fortran at gcc dot gnu dot org>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 11 Jan 2005 13:57:53 +0100
- Subject: Re: [gfortran] Updates to ISHFT translation
- References: <41E15E09.6050105@physik.uni-muenchen.de> <20050111074925.GB26815@redhat.com>
Richard Henderson wrote:
> On Sun, Jan 09, 2005 at 05:38:33PM +0100, Tobias Schlüter wrote:
>>+ convert (type, integer_zero_node), tmp));
>
> build_int_cst (type, 0);
I modeled this after the rest of the code in trans-intrinsic.c, where the
former is prefered, but here's an updated patch anyway.
Is a followup patch which standardizes trans-intrinsic.c to use build_int_cst
instead of converting integer_zero_node to the required type pre-approved?
Bubblestrapped and regtested. Ok?
- Tobi
2005-01-11 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* trans-intrinsic.c (gfc_conv_intrinsic_ishft): Fix signed / unsigned
issue. Use build_int_cst instead of converting integer_zero_node.
Remove unnecessary conversion.
Index: trans-intrinsic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-intrinsic.c,v
retrieving revision 1.38
diff -u -p -r1.38 trans-intrinsic.c
--- trans-intrinsic.c 8 Jan 2005 21:47:36 -0000 1.38
+++ trans-intrinsic.c 11 Jan 2005 12:53:48 -0000
@@ -1785,34 +1785,31 @@ gfc_conv_intrinsic_ishft (gfc_se * se, g
type = TREE_TYPE (arg);
utype = gfc_unsigned_type (type);
- /* We convert to an unsigned type because we want a logical shift.
- The standard doesn't define the case of shifting negative
- numbers, and we try to be compatible with other compilers, most
- notably g77, here. */
- arg = convert (utype, arg);
width = fold (build1 (ABS_EXPR, TREE_TYPE (arg2), arg2));
/* Left shift if positive. */
lshift = fold (build2 (LSHIFT_EXPR, type, arg, width));
- /* Right shift if negative. */
- rshift = convert (type, fold (build2 (RSHIFT_EXPR, utype, arg, width)));
+ /* Right shift if negative.
+ We convert to an unsigned type because we want a logical shift.
+ The standard doesn't define the case of shifting negative
+ numbers, and we try to be compatible with other compilers, most
+ notably g77, here. */
+ rshift = fold_convert (type, build2 (RSHIFT_EXPR, utype,
+ convert (type, arg), width));
tmp = fold (build2 (GE_EXPR, boolean_type_node, arg2,
- convert (TREE_TYPE (arg2), integer_zero_node)));
+ build_int_cst (TREE_TYPE (arg2), 0)));
tmp = fold (build3 (COND_EXPR, type, tmp, lshift, rshift));
/* The Fortran standard allows shift widths <= BIT_SIZE(I), whereas
gcc requires a shift width < BIT_SIZE(I), so we have to catch this
special case. */
- num_bits = convert (TREE_TYPE (arg2),
- build_int_cst (NULL, TYPE_PRECISION (type)));
- cond = fold (build2 (GE_EXPR, boolean_type_node, width,
- convert (TREE_TYPE (arg2), num_bits)));
+ num_bits = build_int_cst (TREE_TYPE (arg2), TYPE_PRECISION (type));
+ cond = fold (build2 (GE_EXPR, boolean_type_node, width, num_bits));
se->expr = fold (build3 (COND_EXPR, type, cond,
- convert (type, integer_zero_node),
- tmp));
+ build_int_cst (type, 0), tmp));
}
/* Circular shift. AKA rotate or barrel shift. */