function.h (struct function): New field calls_constant_p.
authorRoger Sayle <roger@eyesopen.com>
Sat, 25 Jan 2003 17:42:39 +0000 (17:42 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sat, 25 Jan 2003 17:42:39 +0000 (17:42 +0000)
* 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.

From-SVN: r61786

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

index 8f0f8bd6d0aa0fa408d468d448e5ef6c893f5586..942b37feabcc7b99291ddf29a79a54d66d5d36b8 100644 (file)
@@ -1,3 +1,15 @@
+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
index d544410cf0c93bef22ecf562d0c66255eff3ed40..95f9494e242587ca10e0a23690998d7e9ba29310 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 78347c9599d0189a67d19e0ee4ec00bac010792c..9e907ea310978233cb437ead28189f027db693ae 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 63e48f7db2996902a37b0147aa8f54ed35036ae0..22bb9da40179f8a3ca574ea17eff00c8adbc97aa 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 6eef65038fc3402a6fc7202ca26b4008ba576955..8ab4280efc9609a03677c4f715086b7454d73145 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 60370c29213bf59c4685a15769cac1f6e4aaf75f..a62492009d8775a9c26de48e91a04955ff880b7a 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.  */