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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, it is then quite questionable.

It boils down to x86_64

[[gnu::noinline, gnu::noclone]] static float
foo (float *x)
{
  float r;
  asm ("movss 0(%2), %0; addss 4(%2), %0; addss 8(%2), %0; addss 12(%2), %0" :
"=&x" (r) : "m" (*x), "r" (x));
  return r;
}

int
bar (void)
{
  float a[4];
  a[0] = 1.0f;
  a[1] = 2.0f;
  a[2] = 3.0f;
  a[3] = 4.0f;
  return foo (a);
}

int
main ()
{
  if (bar () != 10.0f)
    __builtin_abort ();
}

IPA modref here thinks only x[0] is read.
If you instead describe what exactly is read, so change "m" (*x) to e.g. "m"
(*(float (*)[4]) x), then it works fine.
Clearly without even "m" (*x) the testcase is "miscompiled" even with
-fno-ipa-modref, "r" (x) is not enough to tell the compiler that what it points
to is dereferenced.
With just "r" (x) : "memory" it works though, as documented it tells the
compiler:
'"memory"'
     The '"memory"' clobber tells the compiler that the assembly code
     performs memory reads or writes to items other than those listed in
     the input and output operands (for example, accessing the memory
     pointed to by one of the input parameters)
So, I'd say this is OpenBLAS bug and it needs to either use "memory" clobber
(big hammer) or describe precisely what is being read and stored.

Reply via email to