Bug 26421

Summary: tree-ssa-alias.c:find_used_portions considers foo(&var) use all elements of var
Product: gcc Reporter: Richard Biener <rguenth>
Component: tree-optimizationAssignee: Richard Biener <rguenth>
Status: RESOLVED FIXED    
Severity: normal CC: dberlin, gcc-bugs
Priority: P3 Keywords: alias, compile-time-hog, memory-hog, patch
Version: 4.2.0   
Target Milestone: 4.2.0   
URL: http://gcc.gnu.org/ml/gcc-patches/2006-02/msg01803.html
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2006-02-23 13:45:49
Bug Depends on: 26439    
Bug Blocks:    

Description Richard Biener 2006-02-22 15:57:16 UTC
The function in question should ignore ADDR_EXPRs that appear inside CALL_EXPR parameter lists so that we, for

typedef struct {
  int i;
  int j;
  int k;
} Foo;

void bar(Foo*);
void foo(void)
{
  Foo a;
  a.i = 1;
  bar(&a);
}

do not create SFTs for all elements of a, but only for the first.  This
will reduce clobbers at call sites from

<bb 2>:
  #   SFT.2_2 = V_MUST_DEF <SFT.2_1>;
  a.i = 1;
  #   SFT.0_5 = V_MAY_DEF <SFT.0_3>;
  #   SFT.1_6 = V_MAY_DEF <SFT.1_4>;
  #   SFT.2_7 = V_MAY_DEF <SFT.2_2>;
  bar (&a);

to

<bb 2>:
  #   SFT.2_2 = V_MUST_DEF <SFT.2_1>;
  a.i = 1;
  #   SFT.2_7 = V_MAY_DEF <SFT.2_2>;
  bar (&a);

it especially would reduce the amounts of SFTs we generate for gfortran
struct st_parm, which usually only gets a few fields written to and then
it's address is passed to a function.
Comment 1 Andrew Pinski 2006-02-22 16:02:42 UTC
Really for this example:
For this case V_MAY_DEF's are dead anyways at least for the other SFT's besides the one for a.i.

Try thinking what about:
typedef struct {
  int i;
  int j;
  int k;
} Foo;

void bar(Foo*);
void bar1(Foo);
void foo(void)
{
  Foo a;
  a.i = 1;
  bar(&a);
  bar1(a);
}
Comment 2 Richard Biener 2006-02-22 16:23:31 UTC
I get

<bb 2>:
  #   SFT.0D.1534_2 = V_MUST_DEF <SFT.0D.1534_1>;
  aD.1532.iD.1521 = 1;
  #   SFT.0D.1534_3 = V_MAY_DEF <SFT.0D.1534_2>;
  bar (&aD.1532);
  #   SFT.0D.1534_4 = V_MAY_DEF <SFT.0D.1534_3>;
  bar2 (aD.1532);

for this case.
Comment 3 Richard Biener 2006-02-22 21:32:00 UTC
Patch posted, but now stdarg-5.c ICEs.
Comment 4 Richard Biener 2006-02-23 13:45:49 UTC
ICE is because of PR26439
Comment 5 patchapp@dberlin.org 2006-02-23 15:00:19 UTC
Subject: Bug number PR26421

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-02/msg01803.html
Comment 6 Richard Biener 2006-02-26 16:17:08 UTC
updated patch was posted.
Comment 7 Richard Biener 2006-02-26 21:02:47 UTC
Subject: Bug 26421

Author: rguenth
Date: Sun Feb 26 21:02:43 2006
New Revision: 111461

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

	PR tree-optimization/26421
	* tree-ssa-alias.c (find_used_portions): Don't treat parameters
	in function calls that are ADDR_EXPRs as using the whole structure.

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

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr26421.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-alias.c

Comment 8 Richard Biener 2006-02-26 21:19:53 UTC
Fixed.
Comment 9 Andrew Pinski 2006-02-28 14:19:37 UTC
This testcase fails on the mainline.
Comment 10 Richard Biener 2006-02-28 14:40:03 UTC
It will stop failing once I revert my bandaid fix, but I'll just fix the testcase.