http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50067

--- Comment #14 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-22 
09:38:43 UTC ---
Testcase which shows that mixing array and base access fns leads to bogus
results (obfuscated, SCEV doesn't handle ADDR_EXPRs well ...):

extern int memcmp(const void *, const void *, __SIZE_TYPE__);
extern void abort (void);
short a[33] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
short b[33] = { 0, };
volatile char *ap_ = &a[0];
int main()
{
  int i;
  char *ap = ap_;
  for (i = 0; i < 64; ++i)
    {
      (*((char(*)[])&ap[i+2]))[0] = (*((char(*)[])&ap[0]))[i+1];
    }
  if (memcmp (&a, &b, sizeof (a)) != 0)
    abort ();
  return 0;
}

Here we will end up with

(Data Dep:
#(Data Ref:
#  bb: 3
#  stmt: D.2743_8 = MEM[(char[<unknown>] *)ap_2][i_7];
#  ref: MEM[(char[<unknown>] *)ap_2][i_7];
#  base_object: MEM[(char[<unknown>] *)ap_2];
#  Access function 0: {1, +, 1}_1
#  Access function 1: 0B
#)
#(Data Ref:
#  bb: 3
#  stmt: MEM[(char[<unknown>] *)D.2741_6][0] = D.2743_8;
#  ref: MEM[(char[<unknown>] *)D.2741_6][0];
#  base_object: MEM[(char[<unknown>] *)ap_2];
#  Access function 0: 0
#  Access function 1: {2B, +, 1}_1
#)
    (no dependence)

which is obviously broken - those two access functions for the
respective ref are _not_ independent.

Reply via email to