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

            Bug ID: 80292
           Summary: __m64 type-attribute may_alias ignored
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bernd.edlinger at hotmail dot de
  Target Milestone: ---

In the following program both may_alias attribute
on j, k and the may_alias type-attribute is ignored:

cat t1.c
#include <x86intrin.h>

__m64 j __attribute__((may_alias)), k __attribute__((may_alias));
long  *jj,*kk;

__m64 __attribute__((noinline, noclone))
test()
{
 j = k;
 *jj = *kk;
 return j;
}

int main()
{
  asm("":"=m"(j), "=m"(k), "=m"(jj), "=m"(kk));
  test();
}

gcc -O3 -S t1.c

compiler output:

test:
.LFB4953:
        .cfi_startproc
        movq    kk(%rip), %rax
        movq    k(%rip), %xmm0
        movq    %xmm0, j(%rip)
        movq    (%rax), %rdx
        movq    jj(%rip), %rax
        movq    %rdx, (%rax)
        ret
        .cfi_endproc

but *kk may alias j, thus value in xmm0 is stale.

Reply via email to