diff options
author | DJ Delorie <dj@redhat.com> | 2010-06-16 18:52:25 -0400 |
---|---|---|
committer | DJ Delorie <dj@gcc.gnu.org> | 2010-06-16 18:52:25 -0400 |
commit | 6a78b724701505a225b87a4915d4040217d5833d (patch) | |
tree | 3dd0caaaba78a7ab2d30d7b774f9c8f7ea157dc6 /gcc/fold-const.c | |
parent | f1071b127d01cbf763ae493b6d88ccc6185c3cdf (diff) | |
download | gcc-6a78b724701505a225b87a4915d4040217d5833d.zip gcc-6a78b724701505a225b87a4915d4040217d5833d.tar.gz gcc-6a78b724701505a225b87a4915d4040217d5833d.tar.bz2 |
common.opt (-fstrict-volatile-bitfields): new.
* common.opt (-fstrict-volatile-bitfields): new.
* doc/invoke.texi: Document it.
* fold-const.c (optimize_bit_field_compare): For volatile
bitfields, use the field's type to determine the mode, not the
field's size.
* expr.c (expand_assignment): Likewise.
(get_inner_reference): Likewise.
(expand_expr_real_1): Likewise.
* expmed.c (store_fixed_bit_field): Likewise.
(extract_bit_field_1): Likewise.
(extract_fixed_bit_field): Likewise.
* gcc.target/i386/volatile-bitfields-1.c: New.
* gcc.target/i386/volatile-bitfields-2.c: New.
From-SVN: r160865
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 9f2c250..9abc94e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3463,11 +3463,16 @@ optimize_bit_field_compare (location_t loc, enum tree_code code, /* See if we can find a mode to refer to this field. We should be able to, but fail if we can't. */ - nmode = get_best_mode (lbitsize, lbitpos, - const_p ? TYPE_ALIGN (TREE_TYPE (linner)) - : MIN (TYPE_ALIGN (TREE_TYPE (linner)), - TYPE_ALIGN (TREE_TYPE (rinner))), - word_mode, lvolatilep || rvolatilep); + if (lvolatilep + && GET_MODE_BITSIZE (lmode) > 0 + && flag_strict_volatile_bitfields > 0) + nmode = lmode; + else + nmode = get_best_mode (lbitsize, lbitpos, + const_p ? TYPE_ALIGN (TREE_TYPE (linner)) + : MIN (TYPE_ALIGN (TREE_TYPE (linner)), + TYPE_ALIGN (TREE_TYPE (rinner))), + word_mode, lvolatilep || rvolatilep); if (nmode == VOIDmode) return 0; |