[Bug target/63661] [4.9/5 Regression] -O2 miscompiles on OSX 10.10 Yosemite

2014-11-02 Thread mednafen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63661

mednafen at gmail dot com changed:

   What|Removed |Added

 CC||mednafen at gmail dot com

--- Comment #19 from mednafen at gmail dot com ---
Created attachment 33870
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33870&action=edit
Simplified testcase.

Simplified testcase, tested to be broken on x86_64 Linux.

$ /usr/local/gcc-4.9.2/bin/gcc -O2 -fpic -o testcase-alt testcase-alt.c &&
./testcase-alt 
A: 0x7fffd8416f60
B: 0x4014  5


$ /usr/local/gcc-4.9.2/bin/gcc -O2 -fpic -mtune=nehalem -o testcase-alt
testcase-alt.c && ./testcase-alt 
A: 0x7fffc9fb1730
B: 0x7fffc9fb1730  6.95331e-310
Aborted


[Bug target/63661] [4.9/5 Regression] -O2 miscompiles on OSX 10.10 Yosemite

2014-10-31 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63661

--- Comment #18 from Martin Jambor  ---
(In reply to Jakub Jelinek from comment #14)
> Started with r204698 , you can use -O2 -fpic -mtune=corei7 in compilers that
> don't grok -mtune=nehalem.

So it's probably mine.  I will take a look but please be patient, it
may take a week or probably two.


[Bug target/63661] [4.9/5 Regression] -O2 miscompiles on OSX 10.10 Yosemite

2014-10-30 Thread vbraun.name at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63661

Volker Braun  changed:

   What|Removed |Added

  Known to fail||4.9.2

--- Comment #17 from Volker Braun  ---
Bug is still in gcc 4.9.2


[Bug target/63661] [4.9/5 Regression] -O2 miscompiles on OSX 10.10 Yosemite

2014-10-30 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63661

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|4.9.2   |4.9.3

--- Comment #16 from Jakub Jelinek  ---
GCC 4.9.2 has been released.


[Bug target/63661] [4.9/5 Regression] -O2 miscompiles on OSX 10.10 Yosemite

2014-10-29 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63661

--- Comment #15 from Jakub Jelinek  ---
Slightly reduced testcase:
static void
foo (double a, double q, double xx, double *ff, double *gx, int e, int ni)
{
  int ii, nn;
  double g1 = *gx;
  ff[ni] = xx;
  if (e == 0)
{
  for (ii = 0; ii < ni; ii++)
{
  nn = 100 - ii - 1;
  ff[ni - ii - 1]
= -1.0 / ((4 * (nn + 1) * (nn + 1) - a) / q + ff[ni - ii]);
}
}
  else
{
  for (ii = 0; ii < ni; ii++)
{
  nn = 100 - ii - 1;
  ff[ni - ii - 1]
= -1.0 / (((2 * nn + 1) * (2 * nn + 1) - a) / q + ff[ni - ii]);
}
}
  *gx = ff[0] - g1;
}

int
bar (int order, double q, double a, double c[])
{
  int ni, nn, i, e;
  double eps, g1, g2, x1, x2, e1, e2, de, xh, s, ratio, ff[100];
  eps = 1e-10;
  c[0] = 1.0;
  e = 0;
  if (order % 2 != 0)
e = 1;
  if (q == 0.0)
{
  for (i = 0; i < 100; i++)
c[i] = 0.0;
  c[(order - 1) / 2] = 1.0;
  return 0;
}
  if (order < 5)
{
  nn = 0;
  s = 0.0;
  if (e == 0)
ratio = (a - 4) / q;
  else
ratio = (a - 1 - q) / q;
}
  else
{
  if (e == 0)
{
  c[1] = (a - 4) / q;
  s = 2 * c[0] + 4 * c[1];
  for (i = 2; i < order / 2; i++)
{
  c[i] = (a - 4 * i * i) / q * c[i - 1] - c[i - 2];
  s += 2 * (i + 1) * c[i];
}
}
  else
{
  c[1] = (a - 1) / q + 1;
  s = c[0] + 3 * c[1];
  for (i = 2; i < order / 2 + 1; i++)
{
  c[i] = (a - (2 * i - 1) * (2 * i - 1)) / q * c[i - 1] - c[i - 2];
  s += (2 * (i + 1) - 1) * c[i];
}
}
  nn = i - 1;
  ratio = c[nn] / c[nn - 1];
}
  ni = 100 - nn - 1;
  if (e == 0)
x1 = -q / (4.0 * (100 + 1.0) * (100 + 1.0));
  else
x1 = -q / ((2.0 * 100 + 1.0) * (2.0 * 100 + 1.0));
  g1 = ratio;
  foo (a, q, x1, ff, &g1, e, ni);
  x2 = g1;
  g2 = ratio;
  while (1)
{
  __builtin_printf ("loop %g\n", g2);
  e1 = g1 - x1;
  e2 = g2 - x2;
  de = e1 - e2;
  if (__builtin_fabs (de) < eps)
break;
  xh = (e1 * x2 - e2 * x1) / de;
  x1 = x2;
  g1 = g2;
  x2 = xh;
  g2 = ratio;
  foo (a, q, x2, ff, &g2, e, ni);
}
  s += 2 * (nn + 1) * c[nn];
  for (i = nn + 1; i < 100; i++)
{
  c[i] = ff[i - nn - 1] * c[i - 1];
  s += 2 * (i + 1) * c[i];
  if (__builtin_fabs (c[i]) < 1e-20)
for (; i < 100;)
  c[i++] = 0.0;
}
  for (i = 0; i < 100; i++)
c[i] /= s;
  return 0;
}

int
main ()
{
  double c[100];
  bar (1, 5.0, -5.790080598637771, c);
  return 0;
}


[Bug target/63661] [4.9/5 Regression] -O2 miscompiles on OSX 10.10 Yosemite

2014-10-29 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63661

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||jamborm at gcc dot gnu.org,
   ||vmakarov at gcc dot gnu.org

--- Comment #14 from Jakub Jelinek  ---
Started with r204698 , you can use -O2 -fpic -mtune=corei7 in compilers that
don't grok -mtune=nehalem.


[Bug target/63661] [4.9/5 Regression] -O2 miscompiles on OSX 10.10 Yosemite

2014-10-28 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63661

Richard Biener  changed:

   What|Removed |Added

  Known to work||4.8.3
   Target Milestone|--- |4.9.2
Summary|-O2 miscompiles on OSX  |[4.9/5 Regression] -O2
   |10.10 Yosemite  |miscompiles on OSX 10.10
   ||Yosemite
  Known to fail||4.9.1, 5.0

--- Comment #13 from Richard Biener  ---
4.8 doesn't know nehalem but works with -mtune=native (where 4.9 and 5 break).