------- Comment #3 from pthaugen at gcc dot gnu dot org 2010-01-13 22:11 ------- Created an attachment (id=19585) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19585&action=view) Testcase
Adding a shortened executable testcase that still fails. This looks like an aliasing issue. We're not creating a dependency between a store and load of a memory location which then allows the scheduler to reorder the insns. (insn 2 9 3 2 test.c:10 (set (mem/s/c:DI (plus:DI (reg/f:DI 67 ap) (const_int 48 [0x30])) [0 x+0 S8 A64]) (reg:DI 3 3)) 373 {*movdi_internal64} (expr_list:REG_DEAD (reg:DI 3 3) (nil))) ... (insn 11 8 12 2 test.c:10 (set (reg:DF 126 [ x$a ]) (mem/s/j/c:DF (plus:DI (reg/f:DI 67 ap) (const_int 48 [0x30])) [0 x.a+0 S8 A64])) 360 {*movdf_hardfloat64} (nil)) Some debug data along the dependency creation/alias checking path: Breakpoint 4, true_dependence (mem=0x40000357068, mem_mode=DImode, x=0x400003571d0, vari...@0x112aa168: 0x106737c4 <rtx_varies_p>) at /home/pthaugen/src/gcc/trunk/gcc/gcc/alias.c:2367 2367 return rtx_refs_may_alias_p (x, mem, true); (gdb) pr x (mem/s/j/c:DF (plus:DI (reg/f:DI 67 ap) (const_int 48 [0x30])) [0 x.a+0 S8 A64]) (gdb) pr mem (mem/s/c:DI (plus:DI (reg/f:DI 67 ap) (const_int 48 [0x30])) [0 x+0 S8 A64]) We then go through rtx_refs_may_alias_p() -> refs_may_alias_p_1() -> decl_refs_may_alias_p() which contains the following code where we return false. /* If both references are based on different variables, they cannot alias. */ if (!operand_equal_p (base1, base2, 0)) return false; Breakpoint 7, operand_equal_p (arg0=0x40000370110, arg1=0x40000370660, flags=0) at /home/pthaugen/src/gcc/trunk/gcc/gcc/fold-const.c:3160 3160 if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK) (gdb) prt arg0 <parm_decl 0x40000370110 x type <record_type 0x4000042cac8 Scf10 type_0 BLK size <integer_cst 0x400002d0e10 constant 256> unit size <integer_cst 0x400002d0460 constant 32> align 64 symtab 0 alias set -1 canonical type 0x4000042ca20 fields <field_decl 0x40000450c78 a type <complex_type 0x400003b1c38 complex double> DC file test.c line 2 col 19 size <integer_cst 0x400002d0a50 constant 128> unit size <integer_cst 0x400002d0a78 constant 16> align 64 offset_align 128 offset <integer_cst 0x400002d04b0 constant 0> bit offset <integer_cst 0x400002d0b90 constant 0> context <record_type 0x4000042ca20> chain <field_decl 0x40000450d10 b>> context <translation_unit_decl 0x400003d26d0 D.1272> pointer_to_this <pointer_type 0x4000042ce10> chain <type_decl 0x400003d2560 D.1257>> used BLK file test.c line 9 col 14 size <integer_cst 0x400002d0e10 256> unit size <integer_cst 0x400002d0460 32> align 64 context <function_decl 0x4000044a700 check> (mem/s/c:BLK (plus:DI (reg/f:DI 67 ap) (const_int 48 [0x30])) [0 x+0 S32 A64]) arg-type <record_type 0x4000042cac8 Scf10> incoming-rtl (reg:DI 3 3 [ x+-8 ]) chain <parm_decl 0x40000370198 y>> (gdb) prt arg1 <parm_decl 0x40000370660 x type <record_type 0x4000042cac8 Scf10 type_0 BLK size <integer_cst 0x400002d0e10 constant 256> unit size <integer_cst 0x400002d0460 constant 32> align 64 symtab 0 alias set -1 canonical type 0x4000042ca20 fields <field_decl 0x40000450c78 a type <complex_type 0x400003b1c38 complex double> DC file test.c line 2 col 19 size <integer_cst 0x400002d0a50 constant 128> unit size <integer_cst 0x400002d0a78 constant 16> align 64 offset_align 128 offset <integer_cst 0x400002d04b0 constant 0> bit offset <integer_cst 0x400002d0b90 constant 0> context <record_type 0x4000042ca20> chain <field_decl 0x40000450d10 b>> context <translation_unit_decl 0x400003d26d0 D.1272> pointer_to_this <pointer_type 0x4000042ce10> chain <type_decl 0x400003d2560 D.1257>> used BLK file test.c line 9 col 14 size <integer_cst 0x400002d0e10 256> unit size <integer_cst 0x400002d0460 32> align 64 context <function_decl 0x4000044a700 check> (mem/s/c:BLK (plus:DI (reg/f:DI 67 ap) (const_int 48 [0x30])) [0 x+0 S32 A64]) arg-type <record_type 0x4000042cac8 Scf10> incoming-rtl (reg:DI 3 3 [ x+-8 ]) chain <parm_decl 0x400003706e8 y>> In operand_equal_p() we get to the following which returns false: case tcc_declaration: /* Consider __builtin_sqrt equal to sqrt. */ return (TREE_CODE (arg0) == FUNCTION_DECL && DECL_BUILT_IN (arg0) && DECL_BUILT_IN (arg1) && DECL_BUILT_IN_CLASS (arg0) == DECL_BUILT_IN_CLASS (arg1) && DECL_FUNCTION_CODE (arg0) == DECL_FUNCTION_CODE (arg1)); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42248