diff options
author | Richard Henderson <rth@redhat.com> | 2015-11-09 01:18:59 -0800 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2015-11-09 01:18:59 -0800 |
commit | 6626f97034083631b76c3db092f4bf1156d9d078 (patch) | |
tree | 9ced0fef02073054fa60b803b27fbf06077574a7 /gcc/fold-const.c | |
parent | bd68a3a7e74c8a034dab3efd84c09c4fed066fc1 (diff) | |
download | gcc-6626f97034083631b76c3db092f4bf1156d9d078.zip gcc-6626f97034083631b76c3db092f4bf1156d9d078.tar.gz gcc-6626f97034083631b76c3db092f4bf1156d9d078.tar.bz2 |
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.
From-SVN: r229999
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d8a45d9..8b437ab 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1545,7 +1545,11 @@ const_unop (enum tree_code code, tree type, tree arg0) return fold_convert_const (code, type, arg0); case ADDR_SPACE_CONVERT_EXPR: - if (integer_zerop (arg0)) + /* If the source address is 0, and the source address space + cannot have a valid object at 0, fold to dest type null. */ + if (integer_zerop (arg0) + && !(targetm.addr_space.zero_address_valid + (TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (arg0)))))) return fold_convert_const (code, type, arg0); break; |