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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-11-08 
14:39:51 UTC ---
The problem seems to be that on the c.f90:

...
  D.1548.i.data = 0B;
  atmp.7.dtype = 3113;
  atmp.7.dim[0].stride = 1;
  atmp.7.dim[0].lbound = 0;
  atmp.7.dim[0].ubound = 1;
  D.1691_62 = (void * restrict) &A.8[0];
  atmp.7.data = D.1691_62;
  atmp.7.offset = 0;
  D.1692_63 = atmp.7.data;
  MEM[(struct a[2] *)D.1692_63][0] = x[0];
  D.1693_64 = atmp.7.data;
  MEM[(struct a[2] *)D.1693_64][1] = x[1];

Partition 10: size 96 align 16
        A.8, offset 0
        A.20, offset 0
        a.0, offset 0
        D.1548, offset 0

(thus D.1548 and A.8 share stack slot) and we have in *.asmcons:

// This is D.1548.i.data = 0B;
(insn 250 249 251 18 (set (mem/s/f/c:DI (plus:DI (reg/f:DI 20 frame)
                (const_int -384 [0xfffffffffffffe80])) [3 D.1548.i.data+0 S8
A64])
        (const_int 0 [0])) c.f90:5 62 {*movdi_internal_rex64}
     (nil))
...
// This is D.1691_62 = (void * restrict) &A.8[0];
(insn 255 254 256 18 (parallel [
            (set (reg/f:DI 116 [ D.1691 ])
                (plus:DI (reg/f:DI 20 frame)
                    (const_int -384 [0xfffffffffffffe80])))
            (clobber (reg:CC 17 flags))
        ]) c.f90:6 253 {*adddi_1}
     (nil))

// This is atmp.7.data = D.1691_62;
(insn 256 255 257 18 (set (mem/s/f/c:DI (plus:DI (reg/f:DI 20 frame)
                (const_int -192 [0xffffffffffffff40])) [3 atmp.7.data+0 S8
A64])
        (reg/f:DI 116 [ D.1691 ])) c.f90:6 62 {*movdi_internal_rex64}
     (nil))
...
// This is D.1692_63 = atmp.7.data;
(insn 258 257 260 18 (set (reg/f:DI 117 [ D.1692 ])
        (mem/s/f/c:DI (plus:DI (reg/f:DI 20 frame)
                (const_int -192 [0xffffffffffffff40])) [3 atmp.7.data+0 S8
A64])) c.f90:6 62 {*movdi_internal_rex64}
     (nil))

// These two are start of MEM[(struct a[2] *)D.1692_63][0] = x[0];
(insn 260 258 261 18 (set (reg:DI 332)
        (mem/s:DI (symbol_ref:DI ("x.1518") [flags 0x2]  <var_decl
0x7ff967060140 x>) [6 x+0 S8 A256])) c.f90:6 62 {*movdi_internal_rex64}
     (nil))

(insn 261 260 262 18 (set (mem/s:DI (reg/f:DI 117 [ D.1692 ]) [6 MEM[(struct
a[2] *)D.1692_63]+0 S8 A64])
        (reg:DI 332)) c.f90:6 62 {*movdi_internal_rex64}
     (nil))

Now sched1 unfortunately schedules insn 250 after insn 261 (and whole bunch of
other insns) and as D.1548 and A.8 share stack space, this means overwriting
first 8 bytes in A.8 with NULL.

This all is with current trunk, ./f951 -quiet -fdump-tree-optimized -g
-fipa-reference -fschedule-insns -fno-schedule-insns2 -fstrict-aliasing
-fverbose-asm c.f90 on x86_64-linux.

D.1548 is:
 <var_decl 0x7ffff1ac9140 D.1548
    type <record_type 0x7ffff1cd69d8 a asm_written BLK
        size <integer_cst 0x7ffff1cccb40 constant 384>
        unit size <integer_cst 0x7ffff1cc7dc0 constant 48>
        align 64 symtab -238246416 alias set 6 canonical type 0x7ffff1cd69d8
        fields <field_decl 0x7ffff1cd85f0 i type <record_type 0x7ffff1cd6dc8
array1_integer(kind=4)>
            BLK file c.f90 line 1 col 0 size <integer_cst 0x7ffff1cccb40 384>
unit size <integer_cst 0x7ffff1cc7dc0 48>
            align 64 offset_align 128
            offset <integer_cst 0x7ffff1bdb438 constant 0>
            bit offset <integer_cst 0x7ffff1bdbb40 constant 0> context
<record_type 0x7ffff1cd69d8 a>>
        pointer_to_this <pointer_type 0x7ffff1abf690> chain <type_decl
0x7ffff1abd170 D.1516>>
    used ignored BLK file c.f90 line 5 col 0 size <integer_cst 0x7ffff1cccb40
384> unit size <integer_cst 0x7ffff1cc7dc0 48>
    align 64 context <function_decl 0x7ffff1cd7100 MAIN__>
    (mem/s/c:BLK (plus:DI (reg/f:DI 54 virtual-stack-vars)
        (const_int -384 [0xfffffffffffffe80])) [6 D.1548+0 S48 A64]) chain
<var_decl 0x7ffff1ac1aa0 a.3>>
.

In the MEM[(struct a[2] *)D.1692_63][0] = x[0]; stmt LHS is:
 <array_ref 0x7ffff1c14630
    type <record_type 0x7ffff1cd69d8 a asm_written BLK
        size <integer_cst 0x7ffff1cccb40 constant 384>
        unit size <integer_cst 0x7ffff1cc7dc0 constant 48>
        align 64 symtab -238246416 alias set 6 canonical type 0x7ffff1cd69d8
        fields <field_decl 0x7ffff1cd85f0 i type <record_type 0x7ffff1cd6dc8
array1_integer(kind=4)>
            BLK file c.f90 line 1 col 0 size <integer_cst 0x7ffff1cccb40 384>
unit size <integer_cst 0x7ffff1cc7dc0 48>
            align 64 offset_align 128
            offset <integer_cst 0x7ffff1bdb438 constant 0>
            bit offset <integer_cst 0x7ffff1bdbb40 constant 0> context
<record_type 0x7ffff1cd69d8 a>>
        pointer_to_this <pointer_type 0x7ffff1abf690> chain <type_decl
0x7ffff1abd170 D.1516>>

    arg 0 <mem_ref 0x7ffff1adca80
        type <array_type 0x7ffff1ac63f0 type <record_type 0x7ffff1cd69d8 a>
            BLK
            size <integer_cst 0x7ffff1cccbb8 constant 768>
            unit size <integer_cst 0x7ffff1cc7e38 constant 96>
            align 64 symtab 0 alias set 6 canonical type 0x7ffff1ac63f0 domain
<integer_type 0x7ffff1abf888>
            pointer_to_this <pointer_type 0x7ffff1ac6498>>

        arg 0 <ssa_name 0x7ffff1b135d8 type <pointer_type 0x7ffff1bfce70>
            visited var <var_decl 0x7ffff1aea6e0 D.1692>def_stmt D.1692_63 =
atmp.7.data;

            version 63>
        arg 1 <integer_cst 0x7ffff1ac82d0 constant 0>
        c.f90:6:0>
    arg 1 <integer_cst 0x7ffff1bfe528 type <integer_type 0x7ffff1beb5e8
integer(kind=8)> constant 0>
    c.f90:6:0>
and the type of MEM_REF's arg1 is:
 <pointer_type 0x7ffff1ac6540
    type <array_type 0x7ffff1ac63f0
        type <record_type 0x7ffff1cd69d8 a asm_written BLK
            size <integer_cst 0x7ffff1cccb40 constant 384>
            unit size <integer_cst 0x7ffff1cc7dc0 constant 48>
            align 64 symtab -238246416 alias set 6 canonical type
0x7ffff1cd69d8 fields <field_decl 0x7ffff1cd85f0 i>
            pointer_to_this <pointer_type 0x7ffff1abf690> chain <type_decl
0x7ffff1abd170 D.1516>>
        BLK
        size <integer_cst 0x7ffff1cccbb8 constant 768>
        unit size <integer_cst 0x7ffff1cc7e38 constant 96>
        align 64 symtab 0 alias set 6 canonical type 0x7ffff1ac63f0
        domain <integer_type 0x7ffff1abf888 type <integer_type 0x7ffff1beb5e8
integer(kind=8)>
            public DI
            size <integer_cst 0x7ffff1bdb7d0 constant 64>
            unit size <integer_cst 0x7ffff1bdb7f8 constant 8>
            align 64 symtab 0 alias set -1 canonical type 0x7ffff1abf888
precision 64 min <integer_cst 0x7ffff1bfe528 0> max <integer_cst 0x7ffff1cd5640
1>>
        pointer_to_this <pointer_type 0x7ffff1ac6498>>
    public unsigned restrict DI size <integer_cst 0x7ffff1bdb7d0 64> unit size
<integer_cst 0x7ffff1bdb7f8 8>
    align 64 symtab 0 alias set -1 canonical type 0x7ffff1ac6540>

So alias set 6 for the aggregate copy is fine and so is 3 for the void * type
(which is part of array_descriptor1 aggregate, which is part of struct a).
So it must be the alias oracle saying these two can't alias, perhaps related
somehow to the restrict or something.  Richard, can you have a look at this?

Reply via email to