This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: GCC Status Report (2004-03-09)
On Sat, Mar 20, 2004 at 12:04:02PM +0100, Eric Botcazou wrote:
> 2004-03-20 Eric Botcazou <ebotcazou@libertysurf.fr>
> Mark Mitchell <mark@codesourcery.com>
>
> PR optimization/13424
> * explow.c (maybe_set_unchanging): Revert 2003-04-07 patch.
> * tree.h (readwrite_fields_p): New prototype.
> * alias.c (readwrite_fields_p): New function.
> * expr.c (store_constructor): When clearing the aggregate because of
> an incomplete or mostly zero constructor, do not put the /u flag if the
> target is already unchanging. Record whether a non-unchanging
> aggregate containing read-write fields is cleared with the /u flag.
> In that case, emit a blockage right after the clearing.
Is this patch going to be used for gcc-3_4-branch or are we looking for a
different solution?
If the former, IMHO we need a small follow-up attached below.
If a decl is DECL_EXTERNAL, it probably has no DECL_INITIAL but still
is always ok to have RTX_UNCHANGING_P - it is not initialized in the current
routine.
2004-03-29 Jakub Jelinek <jakub@redhat.com>
PR optimization/12419
* explow.c (maybe_set_unchanging): Set RTX_UNCHANGING_P even for
read-only DECL_EXTERNAL decls.
* gcc.dg/20040302-1.c: New test.
--- gcc/explow.c.jj 2003-12-15 09:37:32.000000000 +0100
+++ gcc/explow.c 2004-03-02 12:07:55.034840235 +0100
@@ -600,7 +600,8 @@ maybe_set_unchanging (rtx ref, tree t)
first case, and decls with TREE_CONSTANT initializers in the second. */
if ((TREE_READONLY (t) && DECL_P (t)
- && (TREE_CODE (t) == PARM_DECL
+ && (DECL_EXTERNAL (t)
+ || TREE_CODE (t) == PARM_DECL
|| (DECL_INITIAL (t) && TREE_CONSTANT (DECL_INITIAL (t)))))
|| TREE_CODE_CLASS (TREE_CODE (t)) == 'c')
RTX_UNCHANGING_P (ref) = 1;
--- gcc/testsuite/gcc.dg/20040302-1.c.jj 2004-01-21 17:12:41.000000000 +0100
+++ gcc/testsuite/gcc.dg/20040302-1.c 2004-03-03 00:08:25.449237291 +0100
@@ -0,0 +1,18 @@
+/* PR optimization/12419 */
+/* Ensure external_const_array[0] is read just once. */
+/* { dg-do compile { target i?86-*-linux* x86_64-*-linux* } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler "external_const_array" } } */
+/* { dg-final { scan-assembler-not "external_const_array.*add\[^\\n\]*external_const_array" } } */
+
+extern const int external_const_array [];
+extern void foo (void);
+
+int
+bar (void)
+{
+ int n = external_const_array[0];
+ foo ();
+ n += external_const_array[0];
+ return n;
+}
Jakub