From e5fe4319e726b2b6baf4a31e42faa446eb6d00b4 Mon Sep 17 00:00:00 2001 From: Joey Ye Date: Mon, 21 Nov 2011 02:16:12 +0000 Subject: expr.c (expand_expr_real_1): Correctly handle strict volatile bitfield loads smaller than mode size. 2011-11-20 Joey Ye * 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 --- gcc/expr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/expr.c') 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 -- cgit v1.1