diff options
author | Jason Merrill <jason@casey.soma.redhat.com> | 2000-06-06 03:37:50 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2000-06-05 23:37:50 -0400 |
commit | 258a120bab5d85ac9541551620ff0fc24de1c354 (patch) | |
tree | f6353c2b2d7aabfa8a09b3b3da4ca7183de48eab /gcc/explow.c | |
parent | c9d8a8136198b464ef8de88f9ea5d8364d848e8b (diff) | |
download | gcc-258a120bab5d85ac9541551620ff0fc24de1c354.zip gcc-258a120bab5d85ac9541551620ff0fc24de1c354.tar.gz gcc-258a120bab5d85ac9541551620ff0fc24de1c354.tar.bz2 |
explow.c (maybe_set_unchanging): New function, broken out from...
* explow.c (maybe_set_unchanging): New function, broken out from...
(set_mem_attributes): Here.
* expr.h: Declare it.
* stmt.c (expand_decl): Call it.
From-SVN: r34421
Diffstat (limited to 'gcc/explow.c')
-rw-r--r-- | gcc/explow.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/gcc/explow.c b/gcc/explow.c index 6ca93bc..9f7eada 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -628,6 +628,27 @@ validize_mem (ref) return change_address (ref, GET_MODE (ref), XEXP (ref, 0)); } +/* Given REF, either a MEM or a REG, and T, either the type of X or + the expression corresponding to REF, set RTX_UNCHANGING_P if + appropriate. */ + +void +maybe_set_unchanging (ref, t) + rtx ref; + tree t; +{ + /* We can set RTX_UNCHANGING_P from TREE_READONLY for decls whose + initialization is only executed once, or whose initializer always + has the same value. Currently we simplify this to PARM_DECLs in the + first case, and decls with TREE_CONSTANT initializers in the second. */ + if ((TREE_READONLY (t) && DECL_P (t) + && (TREE_CODE (t) == PARM_DECL + || DECL_INITIAL (t) == NULL_TREE + || TREE_CONSTANT (DECL_INITIAL (t)))) + || TREE_CODE_CLASS (TREE_CODE (t)) == 'c') + RTX_UNCHANGING_P (ref) = 1; +} + /* Given REF, a MEM, and T, either the type of X or the expression corresponding to REF, set the memory attributes. OBJECTP is nonzero if we are making a new object of this type. */ @@ -642,8 +663,12 @@ set_mem_attributes (ref, t, objectp) /* Get the alias set from the expression or type (perhaps using a front-end routine) and then copy bits from the type. */ + + /* It is incorrect to set RTX_UNCHANGING_P from TREE_READONLY (type) + here, because, in C and C++, the fact that a location is accessed + through a const expression does not mean that the value there can + never change. */ MEM_ALIAS_SET (ref) = get_alias_set (t); - RTX_UNCHANGING_P (ref) = TYPE_READONLY (type); MEM_VOLATILE_P (ref) = TYPE_VOLATILE (type); MEM_IN_STRUCT_P (ref) = AGGREGATE_TYPE_P (type); @@ -657,8 +682,7 @@ set_mem_attributes (ref, t, objectp) if (TYPE_P (t)) return; - if (TREE_READONLY (t) || TREE_CODE_CLASS (TREE_CODE (t)) == 'c') - RTX_UNCHANGING_P (ref) = 1; + maybe_set_unchanging (ref, t); if (TREE_THIS_VOLATILE (t)) MEM_VOLATILE_P (ref) = 1; |