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

            Bug ID: 79032
           Summary: Unaligned memory access in code generated for sparc 32
                    with LRA
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cederman at gaisler dot com
  Target Milestone: ---
            Target: sparc

Hi,

The following code compiled with -O2 -mcpu=v8 -mlra causes an unaligned memory
access:

typedef struct {
  short a;
  long long b;
  short c;
  _Bool d;
  unsigned short e;
  long *f
} g;

h(g *i) {
  long a = 1;
  a /= i->e;
  i->f[a]--;
  return 0;
}

With -mlra:

        mov     1, %g1
        sra     %g1, 31, %g2
        wr      %g2, 0, %y
        ld      [%o0+18], %g2 <- unaligned
        nop
        nop
        sdiv    %g1, %g2, %g1

With -mno-lra:

        lduh    [%o0+20], %g2 <- aligned
        ld      [%o0+24], %g3
        mov     1, %g1
        mov     0, %o0
        sra     %g1, 31, %g4
        wr      %g4, 0, %y
        nop
        nop
        nop
        sdiv    %g1, %g2, %g1

Reply via email to