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

            Bug ID: 112417
           Summary: expand_builtin_return shoud check alignment for the
                    memory reference
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: guihaoc at gcc dot gnu.org
  Target Milestone: ---

//test.c

void * foo (void * p)
{
  if (p)
    __builtin_return (p);
}


when compiling it with mno-vsx on ppc64, it generates 16-byte aligned vector
load instructions for the memory reference which is 1-byte aligned.

(insn 28 27 30 4 (set (reg:V4SF 66 2)
        (mem:V4SF (plus:DI (reg/v/f:DI 118 [ p ])
                (reg:DI 120)) [0  S16 A8])) "test4.c":4:5 1676
{*altivec_movv4sf}

It's unsafe as 16-byte aligned vector load instuction does an "AND -16" on the
memory address by itself. I think expand_builtin_return should check the
alignment and call misaligned_mem_ref expand to load the memory reference.

Reply via email to