diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-12-03 18:06:24 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-12-03 18:06:24 +0000 |
commit | 2c98350fcb269a653b11f73ca0175679aa29977a (patch) | |
tree | 534ac9a3aa65dae82b9fb9147b106d537ec913b9 /gcc/cfgexpand.c | |
parent | e93b5262fdec906660ce7b7763d0e76e705f0803 (diff) |
Mark constant-sized objects as addressable if they have poly-int accesses
If SVE code is written for a specific vector length, it might load from
or store to fixed-sized objects. This needs to work even without
-msve-vector-bits=N (which should never be needed for correctness).
There's no way of handling a direct poly-int sized reference to a
fixed-size register; it would have to go via memory. And in that
case it's more efficient to mark the fixed-size object as
addressable from the outset, like we do for array references
with non-constant indices.
2019-12-03 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* cfgexpand.c (discover_nonconstant_array_refs_r): If an access
with POLY_INT_CST size is made to a fixed-size object, force the
object to live in memory.
gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/deref_1.c: New test.
From-SVN: r278941
Diffstat (limited to 'gcc/cfgexpand.c')
-rw-r--r-- | gcc/cfgexpand.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index e8bed2504bf..bb31fef7014 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -6133,6 +6133,21 @@ discover_nonconstant_array_refs_r (tree * tp, int *walk_subtrees, *walk_subtrees = 0; } + /* References of size POLY_INT_CST to a fixed-size object must go + through memory. It's more efficient to force that here than + to create temporary slots on the fly. */ + else if ((TREE_CODE (t) == MEM_REF || TREE_CODE (t) == TARGET_MEM_REF) + && TYPE_SIZE (TREE_TYPE (t)) + && POLY_INT_CST_P (TYPE_SIZE (TREE_TYPE (t)))) + { + tree base = get_base_address (t); + if (base + && DECL_P (base) + && DECL_MODE (base) != BLKmode + && GET_MODE_SIZE (DECL_MODE (base)).is_constant ()) + TREE_ADDRESSABLE (base) = 1; + *walk_subtrees = 0; + } return NULL_TREE; } |