https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110888

--- Comment #5 from Rimvydas (RJ) <rimvydas.jas at gmail dot com> ---
It is more like this problem:
$ cat foo.c
void foo_(double *x, double *y, double *z)
{
  int i;
  __builtin_memset(z, 0, 8); /* z[0] = 0.0; */
  for (i=0; i<1 ; i++)
    z[0] += x[0] * y[0];
}

$ gcc -O2 -Wall -Wextra -c foo.c -S -fdump-tree-optimized
  <bb 2> [local count: 536870913]:
  __builtin_memset (z_9(D), 0, 8);
  _17 = *x_11(D);
  _18 = *y_12(D);
  _19 = _17 * _18;
  _20 = _19 + 0.0;
  *z_9(D) = _20;
  return;

It would be beneficial for all frontends if the use of __builtin_memset() to
zero out accumulators would be be considered as !HONOR_SIGNED_ZEROS at least
during PRE pass in the middle-end.  If that would complicate things, then
easier solution is to add special case in gfortran frontend-passes that simply
transforms expression to drop accumulator: z[0] = x[0] * y[0];

* side note, in C the redundant __builtin_memset() does not get optimized out,
unlike in gfortran "zero" expr version.  Might be middle-end optimization
passes ordering issue.  At least PRE pass does take accumulator zeroing into
account.

Reply via email to