[Bug rtl-optimization/42952] [4.5 Regression] possible integer wrong code bug
--- Comment #1 from rguenth at gcc dot gnu dot org 2010-02-04 10:03 --- Confirmed. Fails with -O -fno-tree-pta as well. extern void abort (void); static int g[1]; static int *p = g[0]; static int *q = g[0]; int main(void) { g[0] = 1; *p = 0; *p = *q; if (g[0] != 0) abort (); return 0; } -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |NEW Component|middle-end |rtl-optimization Ever Confirmed|0 |1 GCC build triplet|i686-pc-linux-gnu | GCC host triplet|i686-pc-linux-gnu | GCC target triplet|i686-pc-linux-gnu |i?86-*-* x86_64-*-* Priority|P3 |P1 Last reconfirmed|-00-00 00:00:00 |2010-02-04 10:03:02 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42952
[Bug rtl-optimization/42952] [4.5 Regression] possible integer wrong code bug
--- Comment #3 from rguenth at gcc dot gnu dot org 2010-02-04 10:33 --- Well, dse puts (mem/u/f/c/i:DI (symbol_ref:DI (q) [flags 0x2] var_decl 0x75ae7140 q) [0 q+0 S8 A64]) (mem/u/f/c/i:DI (symbol_ref:DI (p) [flags 0x2] var_decl 0x75ae70a0 p) [0 p+0 S8 A64]) into different groups: **scanning insn=9 cselib value 2 0x10f8e58 (reg/f:DI 63 [ q ]) cselib lookup (reg/f:DI 63 [ q ]) = 2 mem: (reg/f:DI 63 [ q ]) after canon_rtx address: (mem/u/f/c/i:DI (symbol_ref:DI (q) [flags 0x2] var_decl 0x75ae7140 q) [0 q+0 S8 A64]) gid=2 offset=0 processing const load gid=2[0..4) mems_found = 0, cannot_delete = true cselib lookup (mem:SI (reg/f:DI 63 [ q ]) [0 S4 A32]) = 0 **scanning insn=10 cselib lookup (reg/f:DI 58 [ p.0 ]) = 1 mem: (reg/f:DI 58 [ p.0 ]) after canon_rtx address: (mem/u/f/c/i:DI (symbol_ref:DI (p) [flags 0x2] var_decl 0x75ae70a0 p) [0 p+0 S8 A64]) gid=1 offset=0 processing const base store gid=1[0..4) trying store in insn=7 gid=1[0..4) just because the addresses are MEM_READONLY_P. But that obviously does not mean they do not point to the same thing - no idea what implementor had in mind here. Kenny? The following fixes this for me: Index: dse.c === --- dse.c (revision 156468) +++ dse.c (working copy) @@ -1015,9 +1015,6 @@ const_or_frame_p (rtx x) { switch (GET_CODE (x)) { -case MEM: - return MEM_READONLY_P (x); - case CONST: case CONST_INT: case CONST_DOUBLE: -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||zadeck at gcc dot gnu dot ||org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42952
[Bug rtl-optimization/42952] [4.5 Regression] possible integer wrong code bug
--- Comment #4 from rguenth at gcc dot gnu dot org 2010-02-04 10:36 --- The only addresses treated as the dse constant kind should be symbol-refs. Or we need to lookup the constant initializer the constant mem refers to and use that (but I have no idea if that's easily possible on RTL). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42952
[Bug rtl-optimization/42952] [4.5 Regression] possible integer wrong code bug
--- Comment #5 from zadeck at naturalbridge dot com 2010-02-04 14:57 --- Richi, you are, of course, correct. kenny -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42952
[Bug rtl-optimization/42952] [4.5 Regression] possible integer wrong code bug
--- Comment #6 from matz at gcc dot gnu dot org 2010-02-04 15:03 --- Re comment #4, there are two possibilities to fix this: 1) as you say, don't regard MEM addresses (i.e. used in double indirection) as const_or_frame_p, because that would put different (but runtime-same) bases into different groups, or 2) fix this marvel in check_mem_read_rtx: if (group_id == store_info-group_id) ... /* else The else case that is missing here is that the bases are constant but different. There is nothing to do here because there is no overlap. */ Clearly the comment is wrong, base addresses can be constant, different for rtx_equal purposes, but still be the same at runtime. When going the (2) way we would need to ask the oracle, which most of the time would probably say don't know anyway, and be slow. Hence not regarding such base addresses as interesting for the global problem seems to be the better fix. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42952