This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: fix opt/8634
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, rakdver at atrey dot karlin dot mff dot cuni dot cz
- Cc: glen at imodulo dot com
- Date: Mon, 7 Apr 2003 15:55:30 -0700
- Subject: Re: fix opt/8634
- References: <20030407214230.GN9659@redhat.com>
I should have looked closer at all this. Glen's post,
http://gcc.gnu.org/ml/gcc-patches/2002-12/msg00533.html
contains the exact same analysis I did, but goes on to notice
different combinations that generate actively incorrect rtl
from the very beginning.
I'm checking in his patch, with expanded commentary.
r~
Index: explow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/explow.c,v
retrieving revision 1.107
diff -c -p -d -r1.107 explow.c
*** explow.c 20 Mar 2003 22:51:39 -0000 1.107
--- explow.c 7 Apr 2003 22:43:20 -0000
*************** maybe_set_unchanging (ref, t)
*** 657,664 ****
/* We can set RTX_UNCHANGING_P from TREE_READONLY for decls whose
initialization is only executed once, or whose initializer always
has the same value. Currently we simplify this to PARM_DECLs in the
! first case, and decls with TREE_CONSTANT initializers in the second. */
if ((TREE_READONLY (t) && DECL_P (t)
&& (TREE_CODE (t) == PARM_DECL
|| (DECL_INITIAL (t) && TREE_CONSTANT (DECL_INITIAL (t)))))
|| TREE_CODE_CLASS (TREE_CODE (t)) == 'c')
--- 657,674 ----
/* We can set RTX_UNCHANGING_P from TREE_READONLY for decls whose
initialization is only executed once, or whose initializer always
has the same value. Currently we simplify this to PARM_DECLs in the
! first case, and decls with TREE_CONSTANT initializers in the second.
!
! We cannot do this for non-static aggregates, because of the double
! writes that can be generated by store_constructor, depending on the
! contents of the initializer. Yes, this does eliminate a good fraction
! of the number of uses of RTX_UNCHANGING_P for a language like Ada.
! It also eliminates a good quantity of bugs. Let this be incentive to
! eliminate RTX_UNCHANGING_P entirely in favour of a more reliable
! solution, perhaps based on alias sets. */
!
if ((TREE_READONLY (t) && DECL_P (t)
+ && (TREE_STATIC (t) || ! AGGREGATE_TYPE_P (TREE_TYPE (t)))
&& (TREE_CODE (t) == PARM_DECL
|| (DECL_INITIAL (t) && TREE_CONSTANT (DECL_INITIAL (t)))))
|| TREE_CODE_CLASS (TREE_CODE (t)) == 'c')