OSDN Git Service

* function.h (struct function): New field calls_constant_p.
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 25 Jan 2003 17:42:39 +0000 (17:42 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 25 Jan 2003 17:42:39 +0000 (17:42 +0000)
(current_function_calls_constant_p): New macro for above.
* function.c (prepare_function_start): Initialize calls_eh_return
and calls_constant_p.
* builtins.c (expand_builtin_constant_p): Set calls_constant_p.
* toplev.c (rest_of_compilation): Only call purge_builtin_constant_p
when the current_function_calls_constant_p.
* integrate.c (expand_inline_function): Set calls_constant_p if
the function being inlined has calls_constant_p set.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@61786 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c
gcc/function.c
gcc/function.h
gcc/integrate.c
gcc/toplev.c

index 8f0f8bd..942b37f 100644 (file)
@@ -1,5 +1,17 @@
 2002-01-25  Roger Sayle  <roger@eyesopen.com>
 
+       * function.h (struct function): New field calls_constant_p.
+       (current_function_calls_constant_p): New macro for above.
+       * function.c (prepare_function_start): Initialize calls_eh_return
+       and calls_constant_p.
+       * builtins.c (expand_builtin_constant_p): Set calls_constant_p.
+       * toplev.c (rest_of_compilation): Only call purge_builtin_constant_p
+       when the current_function_calls_constant_p.
+       * integrate.c (expand_inline_function): Set calls_constant_p if
+       the function being inlined has calls_constant_p set.
+
+2002-01-25  Roger Sayle  <roger@eyesopen.com>
+
        * cse.c (fold_rtx): Instantiate CONSTANT_P_RTX to 0 when not
        optimizing, even if flag_gcse is true.
        * toplev.c (rest_of_compilation): purge_builtin_constant_p
index d544410..95f9494 100644 (file)
@@ -1469,6 +1469,8 @@ expand_builtin_constant_p (exp)
      case is not obvious, so emit (constant_p_rtx (ARGLIST)) and let CSE
      get a chance to see if it can deduce whether ARGLIST is constant.  */
 
+  current_function_calls_constant_p = 1;
+
   tmp = expand_expr (arglist, NULL_RTX, VOIDmode, 0);
   tmp = gen_rtx_CONSTANT_P_RTX (value_mode, tmp);
   return tmp;
index 78347c9..9e907ea 100644 (file)
@@ -6166,6 +6166,8 @@ prepare_function_start ()
   current_function_calls_longjmp = 0;
 
   current_function_calls_alloca = 0;
+  current_function_calls_eh_return = 0;
+  current_function_calls_constant_p = 0;
   current_function_contains_functions = 0;
   current_function_is_leaf = 0;
   current_function_nothrow = 0;
index 63e48f7..22bb9da 100644 (file)
@@ -413,6 +413,9 @@ struct function GTY(())
   /* Nonzero if the function calls __builtin_eh_return.  */
   unsigned int calls_eh_return : 1;
 
+  /* Nonzero if the function calls __builtin_constant_p.  */
+  unsigned int calls_constant_p : 1;
+
   /* Nonzero if function being compiled receives nonlocal gotos
      from nested functions.  */
   unsigned int has_nonlocal_label : 1;
@@ -518,6 +521,7 @@ extern int virtuals_instantiated;
 #define current_function_calls_alloca (cfun->calls_alloca)
 #define current_function_calls_longjmp (cfun->calls_longjmp)
 #define current_function_calls_eh_return (cfun->calls_eh_return)
+#define current_function_calls_constant_p (cfun->calls_constant_p)
 #define current_function_has_computed_jump (cfun->has_computed_jump)
 #define current_function_contains_functions (cfun->contains_functions)
 #define current_function_is_thunk (cfun->is_thunk)
index 6eef650..8ab4280 100644 (file)
@@ -899,6 +899,11 @@ expand_inline_function (fndecl, parms, target, ignore, type,
   if (inl_f->needs_context)
     static_chain_value = lookup_static_chain (fndecl);
 
+  /* If the inlined function calls __builtin_constant_p, then we'll
+     need to call purge_builtin_constant_p on this function.  */
+  if (inl_f->calls_constant_p)
+    current_function_calls_constant_p = 1;
+
   if (GET_CODE (parm_insns) == NOTE
       && NOTE_LINE_NUMBER (parm_insns) > 0)
     {
index 60370c2..a624920 100644 (file)
@@ -2925,7 +2925,7 @@ rest_of_compilation (decl)
     }
 
   /* Instantiate any remaining CONSTANT_P_RTX nodes.  */
-  if (optimize > 0 && flag_gcse)
+  if (optimize > 0 && flag_gcse && current_function_calls_constant_p)
     purge_builtin_constant_p ();
 
   /* Move constant computations out of loops.  */