Bug 36327 - SCCVN should look through struct copies
Summary: SCCVN should look through struct copies
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Richard Biener
URL:
Keywords: missed-optimization
: 18268 40122 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-05-25 17:20 UTC by Richard Biener
Modified: 2009-05-25 15:21 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-05-25 17:20:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2008-05-25 17:20:24 UTC
struct X { int i; int j; };
void bar (struct X *);
int foo (struct X *p)
{
  struct X x;
  p->i = 1;
  x = *p;
  x.j = 2;
  return p->i - x.i;
}

this should be optimized to return zero.  -fno-tree-sra required to show
the missed optimization.
Comment 1 Andrew Pinski 2008-12-28 03:11:29 UTC
*** Bug 18268 has been marked as a duplicate of this bug. ***
Comment 2 Andrew Pinski 2009-05-12 15:24:17 UTC
*** Bug 40122 has been marked as a duplicate of this bug. ***
Comment 3 Richard Biener 2009-05-25 15:18:37 UTC
Subject: Bug 36327

Author: rguenth
Date: Mon May 25 15:18:21 2009
New Revision: 147851

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

	PR tree-optimization/36327
	* tree-ssa-alias.c (walk_non_aliased_vuses): Add second walker
	callback for reference translation or lookup at the point
	of may-defs.
	* tree-ssa-alias.h (walk_non_aliased_vuses): Adjust prototype.
	* tree-ssa-sccvn.c (get_ref_from_reference_ops): Bail out
	for union COMPONENT_REFs.
	(vn_reference_lookup_3): New callback.  Lookup from memset
	and CONSTRUCTOR assignment, translate through struct copies.
	(vn_reference_lookup_pieces): Make sure to not free the
	passed operands array.  Adjust walk_non_aliased_vuses call.
	(vn_reference_lookup): Adjust walk_non_aliased_vuses call,
	make sure we do not leak memory.

	* gcc.dg/tree-ssa/ssa-fre-24.c: New testcase.
	* gcc.dg/tree-ssa/ssa-fre-25.c: Likewise.
	* gcc.dg/tree-ssa/sra-2.c: Disable FRE.
	* gcc.dg/vect/no-vfa-vect-43.c: Adjust.
	* gcc.dg/vect/vect-40.c: Likewise.
	* gcc.dg/vect/vect-42.c: Likewise.
	* gcc.dg/vect/vect-46.c: Likewise.
	* gcc.dg/vect/vect-76.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-24.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-25.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/sra-2.c
    trunk/gcc/testsuite/gcc.dg/vect/no-vfa-vect-43.c
    trunk/gcc/testsuite/gcc.dg/vect/vect-40.c
    trunk/gcc/testsuite/gcc.dg/vect/vect-42.c
    trunk/gcc/testsuite/gcc.dg/vect/vect-46.c
    trunk/gcc/testsuite/gcc.dg/vect/vect-76.c
    trunk/gcc/tree-ssa-alias.c
    trunk/gcc/tree-ssa-alias.h
    trunk/gcc/tree-ssa-sccvn.c

Comment 4 Richard Biener 2009-05-25 15:21:39 UTC
Fixed (mostly).