This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fwd: Re: Create RECORD_NODE for COMMON blocks contain no EQUIVALENCE objects
- From: Canqun Yang <canqun at nudt dot edu dot cn>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 25 Mar 2005 10:12:59 +0800 (HKT)
- Subject: Fwd: Re: Create RECORD_NODE for COMMON blocks contain no EQUIVALENCE objects
- Reply-to: Canqun Yang <canqun at nudt dot edu dot cn>
Hi, Steven
I attached the new patch. What about this one?
2005-03-25 Canqun Yang <canqun@nudt.edu.cn>
* trans-common.c (create_common): Build
RECORD_NODE for common blocks
contain no equivalence objects.
(add_equivalences): New argument saw_equiv.
(translate_common, finish_equivalences): New
local variable saw_equiv.
>
> Looks like a good idea. A few comments:
>
I also tested the NAS benchmarks on IA-64 1.0GHz.
Three of them make a significant improvements.
with this patch
bt.W 33.11 22.08 (*)
cg.A 9.17 9.32
ep.W 12.19 12.21
ft.A 38.57 38.80
is.B 33.45 33.14
lu.W 33.75 29.67 (*)
mg.Z 21.43 21.44
sp.W 69.29 58.97 (*)
>
> gfortran prefers tabs over spaces.
>
The other statements in trans-common.c still have
spaces which should be tabs. Another patch to fix
this?
Canqun Yang
Creative Compiler Research Group.
National University of Defense Technology, China.
*** trans-common.c.save Thu Mar 24 21:30:24 2005
--- trans-common.c Fri Mar 25 09:45:43 2005
*************** build_common_decl (gfc_common_head *com,
*** 379,385 ****
backend declarations for all of the elements. */
static void
! create_common (gfc_common_head *com, segment_info * head)
{
segment_info *s, *next_s;
tree union_type;
--- 379,385 ----
backend declarations for all of the elements. */
static void
! create_common (gfc_common_head *com, segment_info * head, bool saw_equiv)
{
segment_info *s, *next_s;
tree union_type;
*************** create_common (gfc_common_head *com, seg
*** 388,395 ****
tree decl;
bool is_init = false;
! /* Declare the variables inside the common block. */
! union_type = make_node (UNION_TYPE);
rli = start_record_layout (union_type);
field_link = &TYPE_FIELDS (union_type);
--- 388,403 ----
tree decl;
bool is_init = false;
! /* Declare the variables inside the common block.
! If the current common block contains any equivalence object, then
! make a UNION_TYPE node, otherwise RECORD_TYPE. This will let the
! alias analyzer work well when there is no address overlapping for
! common variables in the current common block. */
! if (saw_equiv)
! union_type = make_node (UNION_TYPE);
! else
! union_type = make_node (RECORD_TYPE);
!
rli = start_record_layout (union_type);
field_link = &TYPE_FIELDS (union_type);
*************** find_equivalence (segment_info *n)
*** 703,709 ****
segment list multiple times to include indirect equivalences. */
static void
! add_equivalences (void)
{
segment_info *f;
bool more;
--- 711,717 ----
segment list multiple times to include indirect equivalences. */
static void
! add_equivalences (bool *saw_equiv)
{
segment_info *f;
bool more;
*************** add_equivalences (void)
*** 718,723 ****
--- 726,733 ----
{
f->sym->equiv_built = 1;
more = find_equivalence (f);
+ if (more)
+ *saw_equiv = true;
}
}
}
*************** translate_common (gfc_common_head *commo
*** 788,797 ****
--- 798,809 ----
HOST_WIDE_INT current_offset;
unsigned HOST_WIDE_INT align;
unsigned HOST_WIDE_INT max_align;
+ bool saw_equiv;
common_segment = NULL;
current_offset = 0;
max_align = 1;
+ saw_equiv = false;
/* Add symbols to the segment. */
for (sym = var_list; sym; sym = sym->common_next)
*************** translate_common (gfc_common_head *commo
*** 821,827 ****
/* Add all objects directly or indirectly equivalenced with this
symbol. */
! add_equivalences ();
if (current_segment->offset < 0)
gfc_error ("The equivalence set for '%s' cause an invalid "
--- 833,839 ----
/* Add all objects directly or indirectly equivalenced with this
symbol. */
! add_equivalences (&saw_equiv);
if (current_segment->offset < 0)
gfc_error ("The equivalence set for '%s' cause an invalid "
*************** translate_common (gfc_common_head *commo
*** 865,871 ****
common->name, &common->where, common_segment->offset);
}
! create_common (common, common_segment);
}
--- 877,883 ----
common->name, &common->where, common_segment->offset);
}
! create_common (common, common_segment, saw_equiv);
}
*************** finish_equivalences (gfc_namespace *ns)
*** 878,884 ****
--- 890,898 ----
gfc_symbol *sym;
HOST_WIDE_INT offset;
unsigned HOST_WIDE_INT align;
+ bool saw_equiv;
+ saw_equiv = false;
for (z = ns->equiv; z; z = z->next)
for (y = z->eq; y; y = y->eq)
{
*************** finish_equivalences (gfc_namespace *ns)
*** 888,894 ****
current_segment = get_segment_info (sym, 0);
/* All objects directly or indirectly equivalenced with this symbol. */
! add_equivalences ();
/* Align the block. */
offset = align_segment (&align);
--- 902,908 ----
current_segment = get_segment_info (sym, 0);
/* All objects directly or indirectly equivalenced with this symbol. */
! add_equivalences (&saw_equiv);
/* Align the block. */
offset = align_segment (&align);
*************** finish_equivalences (gfc_namespace *ns)
*** 899,905 ****
apply_segment_offset (current_segment, offset);
/* Create the decl. */
! create_common (NULL, current_segment);
break;
}
}
--- 913,919 ----
apply_segment_offset (current_segment, offset);
/* Create the decl. */
! create_common (NULL, current_segment, saw_equiv);
break;
}
}