aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorJoey Ye <joey.ye@arm.com>2011-11-21 02:16:12 +0000
committerJoey Ye <jye2@gcc.gnu.org>2011-11-21 02:16:12 +0000
commite5fe4319e726b2b6baf4a31e42faa446eb6d00b4 (patch)
tree34dbbd53c18e02cc659b9d899a46473dc5ba47e8 /gcc/expr.c
parent25a96761979b320209f0b513ad364e5d9e5a05d6 (diff)
downloadgcc-e5fe4319e726b2b6baf4a31e42faa446eb6d00b4.zip
gcc-e5fe4319e726b2b6baf4a31e42faa446eb6d00b4.tar.gz
gcc-e5fe4319e726b2b6baf4a31e42faa446eb6d00b4.tar.bz2
expr.c (expand_expr_real_1): Correctly handle strict volatile bitfield loads smaller than mode size.
2011-11-20 Joey Ye <joey.ye@arm.com> * expr.c (expand_expr_real_1): Correctly handle strict volatile bitfield loads smaller than mode size. testsuite: * gcc.dg/volatile-bitfields-1.c: New. From-SVN: r181549
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 84cfe5c..8d3a0f6 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -9740,11 +9740,16 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
&& modifier != EXPAND_CONST_ADDRESS
&& modifier != EXPAND_INITIALIZER)
/* If the field is volatile, we always want an aligned
- access. Only do this if the access is not already naturally
+ access. Do this in following two situations:
+ 1. the access is not already naturally
aligned, otherwise "normal" (non-bitfield) volatile fields
- become non-addressable. */
+ become non-addressable.
+ 2. the bitsize is narrower than the access size. Need
+ to extract bitfields from the access. */
|| (volatilep && flag_strict_volatile_bitfields > 0
- && (bitpos % GET_MODE_ALIGNMENT (mode) != 0))
+ && (bitpos % GET_MODE_ALIGNMENT (mode) != 0
+ || (mode1 != BLKmode
+ && bitsize < GET_MODE_SIZE (mode1) * BITS_PER_UNIT)))
/* If the field isn't aligned enough to fetch as a memref,
fetch it as a bit field. */
|| (mode1 != BLKmode