http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47958

           Summary: [x32] reload generates invalid address reference
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: hjl.to...@gmail.com


[hjl@gnu-6 ilp32-27]$ cat x.i
void (*foo[6][6]) (int);
void bar (hdR)
    int hdR;
{ }
void xxx ()
{
    unsigned int i, j;
    for (i = 0; i < 6; ++i)
    for (j = 0; j < 6; ++j)
            foo [i][j] = bar;
}
[hjl@gnu-6 ilp32-27]$ make x.o
/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -S -o x.s -mx32 -O3  x.i
/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -mx32 -O3  -c -o x.o x.s
x.s: Assembler messages:
x.s:39: Error: cannot represent relocation type BFD_RELOC_64 in x32 mode
make: *** [x.o] Error 1
[hjl@gnu-6 ilp32-27]$ cat x.s
    .file    "x.i"
    .text
    .p2align 4,,15
    .globl    bar
    .type    bar, @function
bar:
.LFB0:
    .cfi_startproc
    rep
    ret
    .cfi_endproc
.LFE0:
    .size    bar, .-bar
    .p2align 4,,15
    .globl    xxx
    .type    xxx, @function
xxx:
.LFB1:
    .cfi_startproc
    movd    .LC0(%rip), %xmm1
    pshufd    $0, %xmm1, %xmm0
    movdqa    %xmm0, foo(%rip)
    movdqa    %xmm0, foo+16(%rip)
    movdqa    %xmm0, foo+32(%rip)
    movdqa    %xmm0, foo+48(%rip)
    movdqa    %xmm0, foo+64(%rip)
    movdqa    %xmm0, foo+80(%rip)
    movdqa    %xmm0, foo+96(%rip)
    movdqa    %xmm0, foo+112(%rip)
    movdqa    %xmm0, foo+128(%rip)
    ret
    .cfi_endproc
.LFE1:
    .size    xxx, .-xxx
    .comm    foo,144,32
    .section    .rodata.cst8,"aM",@progbits,8
    .align 8
.LC0:
    .quad    bar
    .ident    "GCC: (GNU) 4.6.0 20110301 (experimental)"
    .section    .note.GNU-stack,"",@progbits
[hjl@gnu-6 ilp32-27]$ 

We have

(insn 6 2 7 2 (set (reg/f:DI 60 [ pretmp.6 ])
        (symbol_ref:DI ("bar") [flags 0x3]  <function_decl 0x7ffff0cebf00
bar>)) x.i:6 62 {*movdi_internal_rex64}
     (nil))

Reload calls force_const_mem (DImode, op) on symbol_ref:DI ("bar").
The address reference in memory should be SImode/ptr_mode.

Reply via email to