Bug 22555 - array in struct disables salias subvars for other fields
Summary: array in struct disables salias subvars for other fields
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.1.0
: P2 enhancement
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: alias, missed-optimization, patch
Depends on:
Blocks: 22548 23111
  Show dependency treegraph
 
Reported: 2005-07-19 08:48 UTC by Richard Biener
Modified: 2006-01-05 15:32 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-11 18:23:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2005-07-19 08:48:09 UTC
struct {
        int i;
        int j;
        int x[2];
} a;

int foo(void)
{
        a.i = 1;
        a.j = 0;
        a.x[0] = 5;
        return a.i + a.j;
}

does not get optimized, because salias disables subvars for a
because it contains an array.  I have a simple patch in testing.
Comment 1 Richard Biener 2005-07-19 08:57:54 UTC
Which again uncovers latent bugs in IVOPTs.  Argh.
Comment 2 Andrew Pinski 2005-07-22 18:15:58 UTC
Confirmed, a slightly smaller testcase:
struct a
{
  int i;
  int j;
  int x[2];
} a;
int foo(void)
{
  a.i = 1;
  a.j = 0;
  return a.i + a.j;
}
Comment 3 Richard Biener 2005-08-11 13:39:01 UTC
Ok, patch finally has all latent problems fixed.  Maybe we can consider this for
4.2.
Comment 4 CVS Commits 2005-09-07 15:25:24 UTC
Subject: Bug 22555

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	improved-aliasing-branch
Changes by:	rguenth@gcc.gnu.org	2005-09-07 15:25:13

Modified files:
	gcc            : tree-dfa.c tree-ssa-alias.c 
	                 tree-ssa-loop-ivopts.c tree-ssa-loop.c 
	                 tree-ssa-operands.c tree-ssa-structalias.c 
Added files:
	gcc            : ChangeLog.iab 
	gcc/testsuite  : ChangeLog.iab 
	gcc/testsuite/gcc.dg/tree-ssa: alias-3.c 

Log message:
	2005-09-07  Richard Guenther  <rguenther@suse.de>
	
	PR tree-optimization/22555
	* tree-dfa.c (okay_component_ref_for_subvars): Do not give up,
	if one structure field is an array.
	* tree-ssa-alias.c (create_overlap_variables_for): Likewise.
	* tree-ssa-structalias.c (create_variable_info_for): Likewise.
	(get_constraint_for_component_ref): Do not assert we can not
	only be accessing padding if we deal with an ARRAY_REF.
	* tree-ssa-loop-ivopts.c (rewrite_use): Mark new vars in stmt
	for renaming.
	* tree-ssa-loop.c (pass_iv_optimize): Schedule TODO_update_ssa.
	* tree-ssa-operands.c (get_expr_operands): Continue scanning
	operands even if we found a subvar, but ignore VOPs in this
	case.
	
	* gcc.dg/tree-ssa/alias-3.c: New testcase.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.iab.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-dfa.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.63&r2=2.63.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-alias.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.109&r2=2.109.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-loop-ivopts.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.87&r2=2.87.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-loop.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.33.6.1&r2=2.33.6.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-operands.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.100&r2=2.100.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-structalias.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=2.27&r2=2.27.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.iab.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/alias-3.c.diff?cvsroot=gcc&only_with_tag=improved-aliasing-branch&r1=NONE&r2=1.1.2.1

Comment 5 Richard Biener 2006-01-05 15:30:47 UTC
Subject: Bug 22555

Author: rguenth
Date: Thu Jan  5 15:30:44 2006
New Revision: 109381

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109381
Log:
2006-01-05  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/22555
	* tree-ssa-alias.c (create_overlap_variables_for): Do not give up,
	if one structure field is an array.
	* tree-ssa-operands.c (get_expr_operands): Continue scanning
	operands even if we found a subvar, but ignore VOPs in this
	case.
	* tree-ssa-loop-ivopts.c (rewrite_use): Mark new vars in stmt
	for renaming.
	* tree-ssa-loop.c (pass_iv_optimize): Schedule TODO_update_ssa.

	* gcc.dg/tree-ssa/alias-3.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-alias.c
    trunk/gcc/tree-ssa-loop-ivopts.c
    trunk/gcc/tree-ssa-loop.c
    trunk/gcc/tree-ssa-operands.c

Comment 6 Richard Biener 2006-01-05 15:32:39 UTC
Fixed on the mainline.
Comment 7 Richard Biener 2006-01-14 14:30:40 UTC
Subject: Bug 22555

Author: rguenth
Date: Sat Jan 14 14:30:33 2006
New Revision: 109703

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109703
Log:
2006-01-14  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/22548
	PR tree-optimization/22555
	PR tree-optimization/22501
	* Makefile.in (tree-ssa-structalias.o): Depend on $(PARAMS_H).
	* params.def (salias-max-array-elements): New parameter.
	* params.h (SALIAS_MAX_ARRAY_ELEMENTS): Define.
	* doc/invoke.texi (salias-max-array-elements): Document.
	* tree-flow-inline.h (var_can_have_subvars): We also handle
	arrays now.
	* tree-ssa-alias.c (find_used_portions): Handle ARRAY_REF like
	COMPONENT_REF.
	* tree-ssa-structalias.c (params.h): Include.
	(push_fields_onto_fieldstack): Handle ARRAY_TYPE.
	(find_func_aliases): Handle multiple constraints from ARRAY_REF.
	(get_constraint_for): For ADDR_EXPR operating on something
	containing an ARRAY_REF, add all subvars to the solution.
	(handle_ptr_arith): Handle ARRAY_TYPE like RECORD_TYPE types.
	* tree-ssa-operands.c (parse_ssa_operands): Handle ARRAY_REF
	for creating MUST_DEFs.
	(get_expr_operands): Treat ARRAY_REF like COMPONENT_REF wrt subvars.

	* gcc.dg/tree-ssa/alias-4.c: New testcase.
	* gcc.dg/tree-ssa/alias-5.c: Likewise.
	* gcc.dg/tree-ssa/alias-6.c: Likewise.
	* gcc.dg/tree-ssa/alias-7.c: Likewise.
	* gcc.dg/tree-ssa/alias-8.c: Likewise.
	* gcc.dg/tree-ssa/alias-9.c: Likewise.
	* gcc.dg/tree-ssa/alias-10.c: Likewise.
	* gcc.dg/tree-ssa/alias-11.c: Likewise.
	* gcc.dg/tree-ssa/alias-12.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-10.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-11.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-12.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-4.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-5.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-6.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-7.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-8.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-9.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/doc/invoke.texi
    trunk/gcc/params.def
    trunk/gcc/params.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-flow-inline.h
    trunk/gcc/tree-ssa-alias.c
    trunk/gcc/tree-ssa-operands.c
    trunk/gcc/tree-ssa-structalias.c