Commit 3c82efd9 by Richard Guenther Committed by Richard Biener

builtins.c (get_object_alignment_2): Correct offset handling when using type…

builtins.c (get_object_alignment_2): Correct offset handling when using type alignment of a MEM_REF kind base.

2012-07-20  Richard Guenther  <rguenther@suse.de>

	* builtins.c (get_object_alignment_2): Correct offset handling
	when using type alignment of a MEM_REF kind base.

From-SVN: r189704
parent 83c8cdd7
2012-07-20 Richard Guenther <rguenther@suse.de>
* builtins.c (get_object_alignment_2): Correct offset handling
when using type alignment of a MEM_REF kind base.
2012-07-20 Kirill Yukhin <kirill.yukhin@intel.com> 2012-07-20 Kirill Yukhin <kirill.yukhin@intel.com>
PR target/53877 PR target/53877
......
...@@ -346,12 +346,10 @@ get_object_alignment_2 (tree exp, unsigned int *alignp, ...@@ -346,12 +346,10 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
known_alignment known_alignment
= get_pointer_alignment_1 (addr, &ptr_align, &ptr_bitpos); = get_pointer_alignment_1 (addr, &ptr_align, &ptr_bitpos);
bitpos += ptr_bitpos;
align = MAX (ptr_align, align); align = MAX (ptr_align, align);
if (TREE_CODE (exp) == MEM_REF /* The alignment of the pointer operand in a TARGET_MEM_REF
|| TREE_CODE (exp) == TARGET_MEM_REF) has to take the variable offset parts into account. */
bitpos += mem_ref_offset (exp).low * BITS_PER_UNIT;
if (TREE_CODE (exp) == TARGET_MEM_REF) if (TREE_CODE (exp) == TARGET_MEM_REF)
{ {
if (TMR_INDEX (exp)) if (TMR_INDEX (exp))
...@@ -369,9 +367,19 @@ get_object_alignment_2 (tree exp, unsigned int *alignp, ...@@ -369,9 +367,19 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
/* When EXP is an actual memory reference then we can use /* When EXP is an actual memory reference then we can use
TYPE_ALIGN of a pointer indirection to derive alignment. TYPE_ALIGN of a pointer indirection to derive alignment.
Do so only if get_pointer_alignment_1 did not reveal absolute Do so only if get_pointer_alignment_1 did not reveal absolute
alignment knowledge. */ alignment knowledge and if using that alignment would
if (!addr_p && !known_alignment) improve the situation. */
align = MAX (TYPE_ALIGN (TREE_TYPE (exp)), align); if (!addr_p && !known_alignment
&& TYPE_ALIGN (TREE_TYPE (exp)) > align)
align = TYPE_ALIGN (TREE_TYPE (exp));
else
{
/* Else adjust bitpos accordingly. */
bitpos += ptr_bitpos;
if (TREE_CODE (exp) == MEM_REF
|| TREE_CODE (exp) == TARGET_MEM_REF)
bitpos += mem_ref_offset (exp).low * BITS_PER_UNIT;
}
} }
else if (TREE_CODE (exp) == STRING_CST) else if (TREE_CODE (exp) == STRING_CST)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment