[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Bug tree-optimization/18694] [4.0 regression] loop miscompilation at -O1 (-ftree-ch)



------- Additional Comments From steven at gcc dot gnu dot org  2004-12-04 14:40 -------
Simpler test case:

#include <stdlib.h>
#include <stdio.h>
typedef long *GEN;

static inline long *
stoi(long n)
{
  long * z=(long *)malloc(sizeof(long));
  *z=n;
  return z;
}

void
divisors_bug(long * *t, long e)
{
  long j;
  long **d, **old_d, **act_d, **tmp;

  d = t;
  *++d = stoi(1);
  for (old_d=t,j=e; j; j--)
    {
      for (act_d=d, tmp=old_d; tmp < act_d; )
        *++d = stoi(**++tmp * 2);
      old_d=act_d;
    }
}

int main(void)
{
  long *t[4];
  long i;

  divisors_bug(t,2);
  for(i=1;i<4;i++)
    printf("%ld ",*t[i]);
  printf("\n");
  return 0;
}

When I comment out the first PHI-OPT pass, this gives:
1 2 4

With PHI-OPT not commented out, I get:
1 2 0


-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



Reply to: