This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Re: [3.3/3.4/3.5 Regression] Performace regression: poor optimization of const memory


On Tue, Mar 02, 2004 at 09:46:22AM +0100, Jakub Jelinek wrote:
> But certainly maybe_set_unchanging should at least replace:
>   if ((TREE_READONLY (t) && DECL_P (t)
> -      && (TREE_STATIC (t) || ! AGGREGATE_TYPE_P (TREE_TYPE (t)))
> +      && (TREE_STATIC (t) || DECL_EXTERNAL (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')
>     RTX_UNCHANGING_P (ref) = 1;

Actually that is not enough, Jason in Dec, 2002 removed DECL_INITIAL (t) ==
NULL case.  But this certainly makes Andrew's testcase read from a only
once.

2004-03-02  Jakub Jelinek  <jakub@redhat.com>

	* explow.c (maybe_set_unchanging): Set RTX_UNCHANGING_P even for
	read-only DECL_EXTERNAL decls.

--- gcc/explow.c.jj	2003-12-15 09:37:32.000000000 +0100
+++ gcc/explow.c	2004-03-02 12:07:55.034840235 +0100
@@ -608,9 +608,11 @@ maybe_set_unchanging (rtx ref, tree t)
      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)))))
+       && (DECL_EXTERNAL (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')
     RTX_UNCHANGING_P (ref) = 1;
 }


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]