aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 3e8ea95..277bbe8 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -248,7 +248,7 @@ static bool
get_object_alignment_2 (tree exp, unsigned int *alignp,
unsigned HOST_WIDE_INT *bitposp, bool addr_p)
{
- HOST_WIDE_INT bitsize, bitpos;
+ poly_int64 bitsize, bitpos;
tree offset;
machine_mode mode;
int unsignedp, reversep, volatilep;
@@ -373,8 +373,17 @@ get_object_alignment_2 (tree exp, unsigned int *alignp,
}
}
+ /* Account for the alignment of runtime coefficients, so that the constant
+ bitpos is guaranteed to be accurate. */
+ unsigned int alt_align = ::known_alignment (bitpos - bitpos.coeffs[0]);
+ if (alt_align != 0 && alt_align < align)
+ {
+ align = alt_align;
+ known_alignment = false;
+ }
+
*alignp = align;
- *bitposp = bitpos & (*alignp - 1);
+ *bitposp = bitpos.coeffs[0] & (align - 1);
return known_alignment;
}