diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-09 09:18:59 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-09 09:18:59 +0000 |
commit | 9cb8965443df874b84e1841b6956c05e01f2f986 (patch) | |
tree | 9ced0fef02073054fa60b803b27fbf06077574a7 /gcc/gimple.c | |
parent | 849f490c8626ad1e05e73a4ab69fc07477a35321 (diff) | |
download | gcc-9cb8965443df874b84e1841b6956c05e01f2f986.tar.gz |
Add TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID
* gimple.c (check_loadstore): Return false when 0 is a valid address.
* fold-const.c (const_unop) [ADDR_SPACE_CONVERT_EXPR]: Do not fold
null when 0 is valid in the source address space.
* target.def (TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID): New.
* targhooks.c (default_addr_space_zero_address_valid): New.
* targhooks.h (default_addr_space_zero_address_valid): Declare.
* doc/tm.texi.in (TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID): Mark it.
* doc/tm.texi: Rebuild.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229999 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r-- | gcc/gimple.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c index 4ce38dadf2f..706b126e5bb 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-iterator.h" #include "gimple-walk.h" #include "gimplify.h" +#include "target.h" /* All the tuples have their operand vector (if present) at the very bottom @@ -2624,9 +2625,15 @@ nonfreeing_call_p (gimple *call) static bool check_loadstore (gimple *, tree op, tree, void *data) { - if ((TREE_CODE (op) == MEM_REF || TREE_CODE (op) == TARGET_MEM_REF) - && operand_equal_p (TREE_OPERAND (op, 0), (tree)data, 0)) - return true; + if (TREE_CODE (op) == MEM_REF || TREE_CODE (op) == TARGET_MEM_REF) + { + /* Some address spaces may legitimately dereference zero. */ + addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (op)); + if (targetm.addr_space.zero_address_valid (as)) + return false; + + return operand_equal_p (TREE_OPERAND (op, 0), (tree)data, 0); + } return false; } |