This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/17679] New: Aliasing problem with ivopts


The following testcase is misscompiled with -O2 -ftree-loop-ivcanon.  The
reason is that ivopts rewrite the first loop into (equivalent of)

b[0] = 1;
b[1] = 2;
b[2] = 3;
for (tmp = &a, cnt = 3; cnt != 0; tmp += 4B, cnt--)
  if (*tmp != *(tmp - &a + &b))
    { puts ("ERR 1"); break; }

Rtl alias analysis concludes that "a" is base for the register in that
(tmp - &a + &b) is computed.  Store motion than decides that the stores
to "b" before the loop are not used inside loop and moves them after the loop,
thus causing the error.

Reason for this behavior is that the code above is illegal in C (you cannot
take difference of two different arrays).  However ivopts needs to produce
this type of expressions.

int a[3] = {1,2,3};
int c[3] = {4,5,6};

int main(void)
{
  int b[3];
  int i;

  b[0] = 1;
  b[1] = 2;
  b[2] = 3;

  for (i = 0; i < 3; i++)
    if (a[i] != b[i])
      {
        puts ("ERR 1");
        break;
      }

  b[0] = 4;
  b[1] = 5;
  b[2] = 6;

  for (i = 0; i < 3; i++)
    if (c[i] != b[i])
      {
        puts ("ERR 2");
        break;
      }

  return 0;
}

-- 
           Summary: Aliasing problem with ivopts
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: rakdver at gcc dot gnu dot org
        ReportedBy: rakdver at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]