aliasing bug of some sort in select_type_4.f90
Mike Stump
mikestump@comcast.net
Fri May 10 19:56:00 GMT 2013
So, I was tracking down a bug in gfortran.dg/select_type_4.f90 and it turns out that if I reschedule (I do this after loop optimizations and before web) the code, the code then fails at runtime. If I compile with -fno-strict-aliasing, the problem goes away. The change is to hoist a load up to the top of the basic block. I believe that that alias information is likely wrong. insn 231 is the hoisted load. I'm hoping a hand review of the source by a fortran expert and the alias sets involved { , 3, 12} can identify the part that went wrong.
(code_label 218 213 219 14 21 "" [1 uses])
(note 219 218 231 14 [bb 14] NOTE_INSN_BASIC_BLOCK)
(insn 231 219 232 14 (set (reg:DI 742 [ MEM[(struct __class_poly_list_Node_type &)&node]+8 ])
(mem/c:DI (plus:DI (reg/f:DI 1053)
(const_int 8 [0x8])) [12 MEM[(struct __class_poly_list_Node_type &)&node]+8 S8 A64])) t.f90:37 5 {*load}
(expr_list:REG_DEAD (reg/f:DI 1053)
(nil)))
(insn 232 231 220 14 (set (mem:DI (plus:DI (reg/v/f:DI 602 [ integer_node ])
(const_int 8 [0x8])) [3 MEM[(struct node_type *)integer_node_19].next+8 S8 A64])
(reg:DI 742 [ MEM[(struct __class_poly_list_Node_type &)&node]+8 ])) t.f90:37 65 {*store}
(expr_list:REG_DEAD (reg/v/f:DI 602 [ integer_node ])
(nil)))
(insn 220 232 247 14 (set (mem/f/c:DI (plus:DI (reg/f:DI 2134 IN2)
(const_int -560 [0xfffffffffffffdd0])) [3 MEM[(struct __class_poly_list_Node_type_p *)&node]+0 S8 A128])
(reg/f:DI 603 [ node ])) t.f90:37 65 {*store}
(nil))
(insn 247 220 774 14 (set (mem/c:DI (plus:DI (reg/f:DI 1046)
(const_int 8 [0x8])) [3 list.tail+8 S8 A64])
(reg:DI 742 [ MEM[(struct __class_poly_list_Node_type &)&node]+8 ])) t.f90:38 65 {*store}
(expr_list:REG_DEAD (reg:DI 742 [ MEM[(struct __class_poly_list_Node_type &)&node]+8 ])
(nil)))
(insn 774 247 248 14 (set (reg/f:DI 735)
(reg/f:DI 1045)) t.f90:37 3335 {mymovdi}
(expr_list:REG_EQUAL (symbol_ref:DI ("__poly_list_MOD___vtab_poly_list_Node_type") [flags 0x2] <var_decl 0x7fc2cfd4e720 __vtab_poly_list_Node_type>)
(nil)))
(insn 248 774 224 14 (set (reg:DI 3678 $r4)
(const_int 24 [0x18])) t.f90:136 3181 {mymovdi}
(nil))
(insn 224 248 245 14 (set (mem/f/c:DI (plus:DI (reg/f:DI 2134 IN2)
(const_int -552 [0xfffffffffffffdd8])) [3 MEM[(struct __class_poly_list_Node_type_p *)&node + 8B]+0 S8 A64])
(reg/f:DI 1045)) t.f90:37 65 {*store}
(nil))
(insn 245 224 812 14 (set (mem/c:DI (plus:DI (reg/f:DI 1057)
(const_int 16 [0x10])) [3 list.tail+0 S8 A64])
(reg/f:DI 603 [ node ])) t.f90:38 65 {*store}
(nil))
(insn 812 245 230 14 (set (reg/f:DI 743)
(reg/f:DI 1057)) t.f90:38 3335 {mymovdi}
(expr_list:REG_EQUAL (symbol_ref:DI ("list.5265") [flags 0x2] <var_decl 0x7fc2cfd62ed8 list>)
(nil)))
(insn 230 812 249 14 (set (mem:DI (reg/v/f:DI 602 [ integer_node ]) [3 MEM[(struct node_type *)integer_node_19].next+0 S8 A64])
(reg/f:DI 603 [ node ])) t.f90:37 65 {*store}
(nil))
(call_insn 249 230 250 14 (set (reg:DI 3678 $r4)
(call (mem:DI (symbol_ref:DI ("malloc") [flags 0x41] <function_decl 0x7fc2cfe76700 __builtin_malloc>) [0 __builtin_malloc S8 A64])
(const_int 0 [0]))) t.f90:136 3156 {*_call_value}
(expr_list:REG_EH_REGION (const_int 0 [0])
(nil))
(expr_list:REG_CC_SETTER (use (reg:DI 3678 $r4))
(nil)))
That is the version that will fail. The code that is fine is:
(code_label 218 213 219 14 21 "" [1 uses])
(note 219 218 220 14 [bb 14] NOTE_INSN_BASIC_BLOCK)
(insn 220 219 248 14 (set (mem/f/c:DI (plus:DI (reg/f:DI 2134 IN2)
(const_int -560 [0xfffffffffffffdd0])) [3 MEM[(struct __class_poly_list_Node_type_p *)&node]+0 S8 A128])
(reg/f:DI 603 [ node ])) t.f90:37 65 {*store}
(nil))
(insn 248 220 774 14 (set (reg:DI 3678 $r4)
(const_int 24 [0x18])) t.f90:136 3181 {mymovdi}
(nil))
(insn 774 248 245 14 (set (reg/f:DI 735)
(reg/f:DI 1045)) t.f90:37 3335 {mymovdi}
(expr_list:REG_EQUAL (symbol_ref:DI ("__poly_list_MOD___vtab_poly_list_Node_type") [flags 0x2] <var_decl 0x7f25a3607720 __vtab_poly_list_Node_type>)
(nil)))
(insn 245 774 224 14 (set (mem/c:DI (plus:DI (reg/f:DI 1057)
(const_int 16 [0x10])) [3 list.tail+0 S8 A64])
(reg/f:DI 603 [ node ])) t.f90:38 65 {*store}
(nil))
(insn 224 245 812 14 (set (mem/f/c:DI (plus:DI (reg/f:DI 2134 IN2)
(const_int -552 [0xfffffffffffffdd8])) [3 MEM[(struct __class_poly_list_Node_type_p *)&node + 8B]+0 S8 A64])
(reg/f:DI 1045)) t.f90:37 65 {*store}
(nil))
(insn 812 224 231 14 (set (reg/f:DI 743)
(reg/f:DI 1057)) t.f90:38 3335 {mymovdi}
(expr_list:REG_EQUAL (symbol_ref:DI ("list.5265") [flags 0x2] <var_decl 0x7f25a361bed8 list>)
(nil)))
(insn 231 812 232 14 (set (reg:DI 742 [ MEM[(struct __class_poly_list_Node_type &)&node]+8 ])
(mem/c:DI (plus:DI (reg/f:DI 1053)
(const_int 8 [0x8])) [12 MEM[(struct __class_poly_list_Node_type &)&node]+8 S8 A64])) t.f90:37 5 {*load}
(expr_list:REG_DEAD (reg/f:DI 1053)
(nil)))
(insn 232 231 247 14 (set (mem:DI (plus:DI (reg/v/f:DI 602 [ integer_node ])
(const_int 8 [0x8])) [3 MEM[(struct node_type *)integer_node_19].next+8 S8 A64])
(reg:DI 742 [ MEM[(struct __class_poly_list_Node_type &)&node]+8 ])) t.f90:37 65 {*store}
(expr_list:REG_DEAD (reg/v/f:DI 602 [ integer_node ])
(nil)))
(insn 247 232 230 14 (set (mem/c:DI (plus:DI (reg/f:DI 1046)
(const_int 8 [0x8])) [3 list.tail+8 S8 A64])
(reg:DI 742 [ MEM[(struct __class_poly_list_Node_type &)&node]+8 ])) t.f90:38 65 {*store}
(expr_list:REG_DEAD (reg:DI 742 [ MEM[(struct __class_poly_list_Node_type &)&node]+8 ])
(nil)))
(insn 230 247 249 14 (set (mem:DI (reg/v/f:DI 602 [ integer_node ]) [3 MEM[(struct node_type *)integer_node_19].next+0 S8 A64])
(reg/f:DI 603 [ node ])) t.f90:37 65 {*store}
(nil))
(call_insn 249 230 250 14 (set (reg:DI 3678 $r4)
(call (mem:DI (symbol_ref:DI ("malloc") [flags 0x41] <function_decl 0x7f25a372f700 __builtin_malloc>) [0 __builtin_malloc S8 A64])
(const_int 0 [0]))) t.f90:136 3156 {*_call_value}
(expr_list:REG_EH_REGION (const_int 0 [0])
(nil))
(expr_list:REG_CC_SETTER (use (reg:DI 3678 $r4))
(nil)))
More information about the Fortran
mailing list