This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fortran sizetype fix
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Subject: Re: Fortran sizetype fix
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Sat, 29 Apr 2000 09:57:07 -0700
- Cc: gcc-patches at gcc dot gnu dot org
- References: <10004291405.AA14019@vlsi1.ultra.nyu.edu>
On Sat, Apr 29, 2000 at 10:05:38AM -0400, Richard Kenner wrote:
> This patch seems to have disappeared into the black lagoon. It fixes
> some testsuite failures in Fortran. It's quite short but I would
> appreciate if someone who actually _understands_ the sizetype changes
> would review it.
>
> I certainly understand the sizetype changes, having written them,
> but what I can't figure out is that code in the Fortran front end.
> I can't figure out what the calls *expect* *offset to be! In at
> least one case, it's being assigned to a variable which is also
> being set in another case to size_zero_node. If that's correct (and
> he distinction between sizetype and bitsizetype predates my changes
> by quite a while), then your patch is wrong. If that's incorrect,
> then your patch needs to change it too. But I can't tell if that's
> wrong or not.
Just going on the number of places where *offset (or the variable it
points to) is assigned, I see one place where it's set to
size_zero_node and three places where it's set to bitsize_zero_node.
Also, the only place *offset is set to anything that's _not_
foo_zero_node are:
/* An offset into COMMON. */
*offset = fold (build (PLUS_EXPR, TREE_TYPE (*offset),
*offset, TREE_OPERAND (t, 1)));
/* Convert offset (presumably in bytes) into canonical units
(presumably bits). */
*offset = fold (build (MULT_EXPR, TREE_TYPE (*offset),
TYPE_SIZE (TREE_TYPE (TREE_TYPE (t))),
*offset));
break;
(perhaps this should be using size_binop?) and:
*offset
= size_binop (MULT_EXPR,
TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))),
convert (bitsizetype,
fold (build (MINUS_EXPR, TREE_TYPE (element),
element,
TYPE_MIN_VALUE
(TYPE_DOMAIN
(TREE_TYPE (array)))))));;
*offset = size_binop (PLUS_EXPR, init_offset, *offset);
both of which, I believe, are meant to come out in bits, and therefore
ought to be in bitsizetype.
I'm now testing this patch:
* f/com.c (ffecom_overlap_): Set source_offset to
bitsize_zero_node.
(ffecom_tree_canonize_ptr_): Use size_binop. Convert to
bitsizetype before multiplying by TYPE_SIZE.
(ffecom_tree_canonize_ref_) [case ARRAY_REF]: Break up offset
calculation. Use size_binop throughout. Convert to
bitsizetype before multiplying by TYPE_SIZE.
===================================================================
Index: f/com.c
--- f/com.c 2000/03/28 20:37:44 1.83
+++ f/com.c 2000/04/29 16:53:49
@@ -1712,7 +1712,7 @@ ffecom_overlap_ (tree dest_decl, tree de
return TRUE;
source_decl = source_tree;
- source_offset = size_zero_node;
+ source_offset = bitsize_zero_node;
source_size = TYPE_SIZE (TREE_TYPE (TREE_TYPE (source_tree)));
break;
@@ -9082,13 +9082,12 @@ ffecom_tree_canonize_ptr_ (tree *decl, t
if (TREE_CODE (TREE_OPERAND (t, 1)) == INTEGER_CST)
{
/* An offset into COMMON. */
- *offset = fold (build (PLUS_EXPR, TREE_TYPE (*offset),
- *offset, TREE_OPERAND (t, 1)));
+ *offset = size_binop (PLUS_EXPR, *offset, TREE_OPERAND (t, 1)));
/* Convert offset (presumably in bytes) into canonical units
(presumably bits). */
- *offset = fold (build (MULT_EXPR, TREE_TYPE (*offset),
- TYPE_SIZE (TREE_TYPE (TREE_TYPE (t))),
- *offset));
+ *offset = size_binop (MULT_EXPR,
+ convert (bitsizetype, *offset),
+ TYPE_SIZE (TREE_TYPE (TREE_TYPE (t))));
break;
}
/* Not a COMMON reference, so an unrecognized pattern. */
@@ -9249,18 +9248,17 @@ ffecom_tree_canonize_ref_ (tree *decl, t
|| (*decl == error_mark_node))
return;
- *offset
- = size_binop (MULT_EXPR,
- TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))),
- convert (sizetype,
- fold (build (MINUS_EXPR, TREE_TYPE (element),
- element,
- TYPE_MIN_VALUE
- (TYPE_DOMAIN
- (TREE_TYPE (array)))))));;
+ /* Calculate ((element - base) * NBBY) + init_offset. */
+ *offset = size_binop (MINUS_EXPR,
+ element,
+ TYPE_MIN_VALUE (TYPE_DOMAIN
+ (TREE_TYPE (array))));
+
+ *offset = size_binop (MULT_EXPR,
+ convert (bitsizetype, *offset),
+ TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))));
- *offset = size_binop (PLUS_EXPR, convert (sizetype, init_offset),
- *offset);
+ *offset = size_binop (PLUS_EXPR, init_offset, *offset);
*size = TYPE_SIZE (TREE_TYPE (t));
return;