Bug 13765 - [tree-ssa] stores to different members of the same array should not alias
Summary: [tree-ssa] stores to different members of the same array should not alias
Status: RESOLVED DUPLICATE of bug 13761
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: tree-ssa
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: alias, missed-optimization, TREE
Depends on:
Blocks:
 
Reported: 2004-01-20 07:35 UTC by Dan Nicolaescu
Modified: 2004-10-28 20:34 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-10-14 02:04:56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Nicolaescu 2004-01-20 07:35:45 UTC
int foo (int * arr)
{
  arr[0] = 1;
  arr[1] = 2;
  if (arr[0] != 1)
    abort ();
  if (arr[1] != 2)
    abort ();
}

The first if is not optimized away because, presumably, the 2 stores are not
considered not to alias.

The .optimized dump:

foo (arr)
{
<bb 0>:
  *arr = 1;
  *(arr + 4B) = 2;
  if (*arr != 1) goto <L0>; else goto <L1>;

<L0>:;
  abort ();

<L1>:;
  return;

}
Comment 1 Andrew Pinski 2004-01-20 15:20:25 UTC
Confirmed, PTA does not help either.
Comment 2 Giovanni Bajo 2004-07-05 18:58:35 UTC
As requested.
Comment 3 Dan Nicolaescu 2004-07-12 21:40:47 UTC
Another testcase for whoever is going to fix this:

struct st
{
  int *arr;
  int c;
  int d;
  int fl;
};

void foo (struct st *s, int a, int b, int c, int d)
{
  *(s->arr) = a; s->arr++;
  *(s->arr) = b; s->arr++;
  *(s->arr) = c; s->arr++;
}

void foo2 (struct st *s, int a, int b, int c, int d)
{
  int *p = s->arr;
  *(p) = a; p++;
  *(p) = b; p++;
  *(p) = c; p++;
  s->arr = p;
}

The 2 functions above are compiled to the same assembly code by gcc-3.4 -O2, 
the .vars dump for them should be very similar too. It is not so currently. 
Comment 4 Diego Novillo 2004-07-13 00:08:38 UTC
Subject: Re:  [tree-ssa] stores to different
	members of the same array should not alias

On Mon, 2004-07-12 at 17:40, dann at godzilla dot ics dot uci dot edu
wrote:
> ------- Additional Comments From dann at godzilla dot ics dot uci dot edu  2004-07-12 21:40 -------
> Another testcase for whoever is going to fix this:
> 
Thanks.  I'll be looking at this after I'm done with the current pass
reorganization.


Diego.

Comment 5 Diego Novillo 2004-10-28 20:34:27 UTC
Dan, ISTR you saying that the field based stuff would also help with arrays.  Or
do we want to implement array-SSA?  (I'd rather not, in principle).

*** This bug has been marked as a duplicate of 13761 ***
Comment 6 Daniel Berlin 2004-10-28 21:57:53 UTC
Subject: Re:  [tree-ssa] stores to different
 members of the same array should not alias


>
> Dan, ISTR you saying that the field based stuff would also help with arrays.

Yes, i can make it happen on arrays as well (for fixed size arrays).

> Or
> do we want to implement array-SSA?  (I'd rather not, in principle).
I'd rather not either.