From 40f94f7d731023b1461887dec0e1e9a57daa8343 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Wed, 29 Oct 2014 12:33:42 -0400 Subject: [PATCH] expmed.c (strict_volatile_bitfield_p): Fix off-by-one error. * expmed.c (strict_volatile_bitfield_p): Fix off-by-one error. * gcc.dg/20141029-1.c: New. From-SVN: r216844 --- gcc/ChangeLog | 4 ++++ gcc/expmed.c | 2 +- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/20141029-1.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/20141029-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 59e562c111b..138fecd1d88 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2014-10-29 DJ Delorie + + * expmed.c (strict_volatile_bitfield_p): Fix off-by-one error. + 2014-10-29 Martin Liska PR ipa/63587 diff --git a/gcc/expmed.c b/gcc/expmed.c index 2f53ecff102..7dabe75c8f4 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -457,7 +457,7 @@ strict_volatile_bitfield_p (rtx op0, unsigned HOST_WIDE_INT bitsize, /* Check for cases where the C++ memory model applies. */ if (bitregion_end != 0 && (bitnum - bitnum % modesize < bitregion_start - || bitnum - bitnum % modesize + modesize > bitregion_end)) + || bitnum - bitnum % modesize + modesize - 1 > bitregion_end)) return false; return true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2e4073fa08c..2955cfd58e3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-10-29 DJ Delorie + + * gcc.dg/20141029-1.c: New. + 2014-10-29 Martin Liska PR ipa/63587 diff --git a/gcc/testsuite/gcc.dg/20141029-1.c b/gcc/testsuite/gcc.dg/20141029-1.c new file mode 100644 index 00000000000..b25af576967 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20141029-1.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-volatile-bitfields -fdump-rtl-final" } */ + +#define PERIPH (*(volatile struct system_periph *)0x81234) + +struct system_periph { + union { + unsigned short WORD; + struct { + unsigned short a:1; + unsigned short b:1; + unsigned short :5; + unsigned short c:1; + unsigned short :8; + } BIT; + } ALL; +}; + +void +foo() +{ + while (1) + { + PERIPH.ALL.BIT.a = 1; + } +} +/* { dg-final { scan-rtl-dump-times "mem/v(/.)*:HI" 4 "final" } } */ +/* { dg-final { cleanup-rtl-dump "final" } } */ -- 2.30.2