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]

[tree-ssa] accept string+cst as gimple constants


This is a minor tweak I found while fixing other things.  It allows the
optimizers to consider "foo" + 1 as an unchanging expression which is
then propagated by CCP and the dominator optimizers.

Bootstrapped and tested x86 and amd64.


Diego.


	* tree-simple.c (is_gimple_const): Accept CONST + CONST expressions
	as GIMPLE constants.

Index: tree-simple.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-simple.c,v
retrieving revision 1.1.4.46
diff -d -u -p -r1.1.4.46 tree-simple.c
--- tree-simple.c	24 Jul 2003 22:51:42 -0000	1.1.4.46
+++ tree-simple.c	30 Jul 2003 22:15:01 -0000
@@ -580,6 +580,12 @@ is_gimple_const (tree t)
       && TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST)
     return 1;
 
+  if (TREE_CODE (t) == PLUS_EXPR
+      && TREE_CONSTANT (t)
+      && is_gimple_const (TREE_OPERAND (t, 0))
+      && is_gimple_const (TREE_OPERAND (t, 1)))
+    return 1;
+
   return (TREE_CODE (t) == INTEGER_CST
 	  || TREE_CODE (t) == REAL_CST
 	  || TREE_CODE (t) == STRING_CST



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