aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 4dc8a15..5f53342 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -473,6 +473,28 @@ get_pointer_alignment_1 (tree exp, unsigned int *alignp,
if (TREE_CODE (exp) == ADDR_EXPR)
return get_object_alignment_2 (TREE_OPERAND (exp, 0),
alignp, bitposp, true);
+ else if (TREE_CODE (exp) == POINTER_PLUS_EXPR)
+ {
+ unsigned int align;
+ unsigned HOST_WIDE_INT bitpos;
+ bool res = get_pointer_alignment_1 (TREE_OPERAND (exp, 0),
+ &align, &bitpos);
+ if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
+ bitpos += TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)) * BITS_PER_UNIT;
+ else
+ {
+ unsigned int trailing_zeros = tree_ctz (TREE_OPERAND (exp, 1));
+ if (trailing_zeros < HOST_BITS_PER_INT)
+ {
+ unsigned int inner = (1U << trailing_zeros) * BITS_PER_UNIT;
+ if (inner)
+ align = MIN (align, inner);
+ }
+ }
+ *alignp = align;
+ *bitposp = bitpos & (align - 1);
+ return res;
+ }
else if (TREE_CODE (exp) == SSA_NAME
&& POINTER_TYPE_P (TREE_TYPE (exp)))
{