diff options
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/builtins.c | 2 | ||||
-rw-r--r-- | gcc/function.c | 2 | ||||
-rw-r--r-- | gcc/function.h | 4 | ||||
-rw-r--r-- | gcc/integrate.c | 5 | ||||
-rw-r--r-- | gcc/toplev.c | 2 |
6 files changed, 26 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f0f8bd6d0a..942b37feabc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/builtins.c b/gcc/builtins.c index d544410cf0c..95f9494e242 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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; diff --git a/gcc/function.c b/gcc/function.c index 78347c9599d..9e907ea3109 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -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; diff --git a/gcc/function.h b/gcc/function.h index 63e48f7db29..22bb9da4017 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -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) diff --git a/gcc/integrate.c b/gcc/integrate.c index 6eef65038fc..8ab4280efc9 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -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) { diff --git a/gcc/toplev.c b/gcc/toplev.c index 60370c29213..a62492009d8 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -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. */ |