diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2011-09-25 15:42:00 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2011-09-25 15:42:00 +0000 |
commit | dea976c48066580dff56c1055027d7398072bfc9 (patch) | |
tree | ded5b46f411df22844abab53b3af309efe8c7a34 /gcc/ada/gcc-interface/decl.c | |
parent | 960dcaf528c16597fc89da7e0fa6ec75038a8e87 (diff) | |
download | gcc-dea976c48066580dff56c1055027d7398072bfc9.zip gcc-dea976c48066580dff56c1055027d7398072bfc9.tar.gz gcc-dea976c48066580dff56c1055027d7398072bfc9.tar.bz2 |
decl.c (gnat_to_gnu_entity): Do not promote the alignment if this doesn't prevent BLKmode access to the object.
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Do not promote
the alignment if this doesn't prevent BLKmode access to the object.
From-SVN: r179167
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index a6bfd37..d96f683 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -817,16 +817,30 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && No (Address_Clause (gnat_entity)))) && TREE_CODE (TYPE_SIZE (gnu_type)) == INTEGER_CST) { - /* No point in jumping through all the hoops needed in order + unsigned int size_cap, align_cap; + + /* No point in promoting the alignment if this doesn't prevent + BLKmode access to the object, in particular block copy, as + this will for example disable the NRV optimization for it. + No point in jumping through all the hoops needed in order to support BIGGEST_ALIGNMENT if we don't really have to. So we cap to the smallest alignment that corresponds to a known efficient memory access pattern of the target. */ - unsigned int align_cap = Is_Atomic (gnat_entity) - ? BIGGEST_ALIGNMENT - : get_mode_alignment (ptr_mode); + if (Is_Atomic (gnat_entity)) + { + size_cap = UINT_MAX; + align_cap = BIGGEST_ALIGNMENT; + } + else + { + size_cap = MAX_FIXED_MODE_SIZE; + align_cap = get_mode_alignment (ptr_mode); + } if (!host_integerp (TYPE_SIZE (gnu_type), 1) - || compare_tree_int (TYPE_SIZE (gnu_type), align_cap) >= 0) + || compare_tree_int (TYPE_SIZE (gnu_type), size_cap) > 0) + align = 0; + else if (compare_tree_int (TYPE_SIZE (gnu_type), align_cap) > 0) align = align_cap; else align = ceil_alignment (tree_low_cst (TYPE_SIZE (gnu_type), 1)); |